]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/main.cc
release: 0.1.7
[lilypond.git] / lily / main.cc
index 1576773e860582bfc50b6c3969d48930087a55df..eff3d6cc811f3244dd57a039a9284ffb18264adc 100644 (file)
@@ -1,7 +1,7 @@
 /*
   main.cc -- implement main: entrypoints
 
-  source file of the LilyPond music typesetter
+  source file of the GNU LilyPond music typesetter
 
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 #include "path.hh"
 #include "config.hh"
 #include "source.hh"
+#include "debug.hh"
 #include "my-lily-parser.hh"
 
 Sources* source_l_g = 0;
 bool only_midi = false;
+bool version_ignore_b_ = false;
+int exit_status_i_;
 
+void destill_inname( String &name_str_r);
 
-void
-destill_inname( String &name_str_r);
 Long_option_init theopts[] = {
-    1, "output", 'o',
-    0, "warranty", 'w',
-    0, "help", 'h',
-    0, "debug", 'd',
-    1, "init", 'i',
-    1, "include", 'I',
-    0, "midi", 'M',
-    0,0,0
+    {1, "output", 'o'},
+    {0, "warranty", 'w'},
+    {0, "help", 'h'},
+    {0, "debug", 'd'},
+    {1, "init", 'i'},
+    {1, "include", 'I'},
+    {0, "midi", 'M'},
+    {0, "ignore-version", 'V'},
+    {0,0,0}
 };
 
 void
@@ -44,15 +47,16 @@ usage()
        "Typeset and or produce midi output from mudela-file or stdin\n"
        "\n"
        "Options:\n"
-       "  -d, --debug         enable debugging output\n"
-        "  -I, --include=DIR   add DIR to search path\n"
-       "  -i, --init=FILE     use FILE as init file\n"
-       "  -h, --help          this help\n"
-       "  -w, --warranty      show warranty and copyright\n"
-       "  -o, --output=FILE   set FILE as default output\n"
-       "  -M, --midi          produce midi output only\n"
+       "  -d, --debug            enable debugging output\n"
+        "  -I, --include=DIR      add DIR to search path\n"
+       "  -i, --init=FILE        use FILE as init file\n"
+       "  -h, --help             this help\n"
+       "  -w, --warranty         show warranty and copyright\n"
+       "  -o, --output=FILE      set FILE as default output\n"
+       "  -M, --midi             produce midi output only\n"
+       "  -V, --ignore-version   ignore mudela version\n"
        "\n"
-       "LilyPond was compiled with the following settings:\n"
+       "GNU LilyPond was compiled with the following settings:\n"
 #ifdef NDEBUG
        "NDEBUG "       
 #endif
@@ -62,7 +66,10 @@ usage()
 #ifdef STRING_UTILS_INLINED
        "STRING_UTILS_INLINED "
 #endif
-       "datadir= " DIR_DATADIR "\n" 
+       "datadir= " DIR_DATADIR 
+
+       "\n";
+       
        ;
     
     
@@ -73,12 +80,10 @@ notice()
 {
     cout <<
        "\n"
-       "LilyPond, a music typesetter.\n"
-       "Copyright (C) 1996,97 by\n"
+       "GNU LilyPond -- The GNU Project music typesetter.\n"
+       "Copyright 1996,97 by\n"
        "  Han-Wen Nienhuys <hanwen@stack.nl>\n"
        "  Jan Nieuwenhuizen <jan@digicash.com>\n"
-       "Contributors\n"
-       "  Mats Bengtsson <matsb@s3.kth.se>\n"
        "\n"
        "    This program is free software; you can redistribute it and/or\n"
        "modify it under the terms of the GNU General Public License version 2\n"
@@ -95,16 +100,27 @@ notice()
        "USA.\n";
 }
 
-static File_path * path_l =0;
+
+static File_path path;
 
 void
 do_one_file(String init_str, String file_str)
 {
+    if ( init_str != "" && "" == path.find( init_str ) ) {
+       error ( "Can not find `" + init_str +"\'");
+       return ;
+    }
+    if ( file_str!= "" && path.find( file_str ) == "" ) {
+       error ( "Can not find `" + file_str + "'");
+       return ;
+    }
+    
     Sources sources;
     source_l_g = &sources; 
-    source_l_g->set_path(path_l);
+    source_l_g->set_path(&path);
     {
        My_lily_parser parser(source_l_g);
+       parser.set_version_check(version_ignore_b_);
        parser.parse_file(init_str, file_str);
     }
     do_scores();
@@ -115,38 +131,44 @@ int
 main (int argc, char **argv)
 {    
     debug_init();              // should be first
-    File_path path(String(DIR_DATADIR)+"/init/") ;
-    path_l = & path;
-    path_l->push(DIR_DATADIR );
 
+
+    // must override (come before) "/usr/local/share/lilypond"!
     char const * env_l=getenv("LILYINCLUDE");
     if (env_l) {
        path.add(env_l);
     }
+    path.add( "" );
+    path.add( String( DIR_DATADIR ) + "/init/" );
     
+    path.push(DIR_DATADIR );
+
     Getopt_long oparser(argc, argv,theopts);
     cout << get_version_str() << endl;
-    String init_str("symbol.ini");
+    String init_str("symbol.ly");
     
-    while (Long_option_init * opt = oparser()) {
+    while (Long_option_init const * opt = oparser()) {
        switch ( opt->shortname){
        case 'o':
-           set_default_output(oparser.optarg);
+           set_default_output(oparser.optional_argument_ch_C_);
            break;
        case 'w':
            notice();
            exit(0);
            break;
        case 'I':
-           path.push(oparser.optarg);
+           path.push(oparser.optional_argument_ch_C_);
            break;
        case 'i':
-           init_str = oparser.optarg;
+           init_str = oparser.optional_argument_ch_C_;
            break;
        case 'h':
            usage();
            exit(0);
            break;
+       case 'V':
+           version_ignore_b_ = true;
+           break;
        case 'd':
            set_debug(true);
            break;
@@ -160,7 +182,7 @@ main (int argc, char **argv)
     }
 
     int p=0;
-    char *arg ;
+    const char *arg ;
     while ( (arg= oparser.get_next_arg()) ) {
        String f(arg);
        destill_inname(f);
@@ -171,7 +193,7 @@ main (int argc, char **argv)
        do_one_file(init_str, "");      
     }
 
-    return 0;
+    return exit_status_i_;
 }
 
 /// make input file name: add default extension. "" is stdin.