Esempio n. 1
0
main(int argc, Char *argv[])
{  /* ---- Main program ------------------------ */
  PASCAL_MAIN(argc, argv);
  strcpy(this_version, version);
  strcpy(this_version_date, version_date);
  printf("==> This is M-Tx %s (Music from TeXt) %s\n", version, version_date);

  mtxLevel(version);
  OpenFiles();
  no_commands_yet = true;
  preambleDefaults();
  no_report_errors = false;
  topOfPMXfile();
  do {
    readParagraph(P, orig_line_no, &para_len);
    control_paragraph = isControlParagraph(P, para_len);
    if (control_paragraph) {
      augmentPreamble(no_report_errors);
      no_report_errors = true;
      if (para_len == 0)
	error("No music paragraphs!", !print);
    }
  } while (control_paragraph);
  doPreamble();
  doMusic();
  if (!pmx_preamble_done)
    error("No music paragraphs!", !print);
  putLine("% Coded by M-Tx");
  CloseFiles();
  printf("PrePMX done.  Now run PMX.\n");
  _Escape(0);
  exit(EXIT_SUCCESS);
}
Esempio n. 2
0
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *
 *   MAIN
 */
int
main(int argc, char ** argv)
{
    FILE* outFp;

    optionProcess(&getdefsOptions, argc, argv);
    validateOptions();

    outFp = startAutogen();

    doPreamble(outFp);

    /*
     *  Process each input file
     */
    {
        int    ct  = STACKCT_OPT(INPUT);
        char const ** ppz = STACKLST_OPT(INPUT);

        do  {
            processFile(*ppz++);
        } while (--ct > 0);
    }

    /*
     *  IF we don't have an ordering file, but we do have a "first index",
     *  THEN alphabetize by definition name.
     */
    if ((pzIndexText == NULL) && HAVE_OPT(FIRST_INDEX)) {
        qsort((void*)papzBlocks, blkUseCt, sizeof(char*), compar_defname);
        set_first_idx();
    }

    else if (ENABLED_OPT(ORDERING) && (blkUseCt > 1))
        qsort((void*)papzBlocks, blkUseCt, sizeof(char*), &compar_text);

    printEntries(outFp);
    fclose(outFp);

    /*
     *  IF output is to a file
     *  THEN set the permissions and modification times
     */
    if (  (WHICH_IDX_AUTOGEN == INDEX_OPT_OUTPUT)
       && (outFp != stdout) )  {
        struct utimbuf tbuf;
        tbuf.actime  = time((time_t*)NULL);
        tbuf.modtime = modtime + 1;
        utime(OPT_ARG(OUTPUT), &tbuf);
        chmod(OPT_ARG(OUTPUT), S_IRUSR|S_IRGRP|S_IROTH);
    }

    /*
     *  IF we are keeping a database of indexes
     *     AND we have augmented the contents,
     *  THEN append the new entries to the file.
     */
    if ((pzIndexText != NULL) && (pzEndIndex != pzIndexEOF))
        updateDatabase();

    if (agPid != -1)
        return awaitAutogen();

    return EXIT_SUCCESS;
}