void setOnly(Char *line_) { Char line[256]; short num, num1, num2, l; Char s[256]; Char STR1[256]; strcpy(line, line_); if (*line == '\0') return; if (startsWithIgnoreCase(line, "only")) GetNextWord(STR1, line, colon_, dummy); for (l = 0; l <= lines_in_paragraph - 1; l++) omit_line[l] = true; do { GetNextWord(s, line, blank_, comma_); if (*s == '\0') return; curtail(s, comma_); if (pos1('-', s) == 0) { getNum(s, &num); if (num > 0 && num <= lines_in_paragraph) omit_line[num-1] = false; else warning("Invalid line number in Only: is skipped", print); } else { getTwoNums(s, &num1, &num2); if (num1 > 0 && num2 <= lines_in_paragraph) { for (num = num1 - 1; num <= num2 - 1; num++) omit_line[num] = false; } else warning("Invalid line range in Only: is skipped", print); } } while (true); }
Local void output(Char *note_, struct LOC_processLine *LINK) { Char note[256]; Char STR2[256]; strcpy(note, note_); if (*note != '\0') { /* pretex is saved up until a spacing note or rest comes */ if (endsWith(note, "\\") && note[1] != '\\') { curtail(note, '\\'); strcat(LINK->pretex, note); *note = '\0'; return; } if (*LINK->pretex != '\0' && isNoteOrRest(note)) { sprintf(note, "%s\\ %s", LINK->pretex, strcpy(STR2, note)); *LINK->pretex = '\0'; } if (outlen > 0 && note[0] != ' ') sprintf(note, " %s", strcpy(STR2, note)); put(note, nospace); } if (thisNote(LINK->voice) == nextvoice) putLine(""); }
Static command_type findCommand(Char *command) { command_type j; curtail(command, ':'); if (equalsIgnoreCase(command, "STYLE")) style_supplied = true; for (j = c1; j <= cn; j = (command_type)((long)j + 1)) { if (equalsIgnoreCase(command, commands[(long)j])) return j; } return none; }
Static void setVoices(Char *line) { short k; Char s[256], w[256]; Char STR1[256]; short FORLIM; nvoices = 0; nstaves = 0; do { GetNextWord(s, line, blank_, dummy); if (*s != '\0') { nstaves++; k = 0; first_on_stave[nstaves-1] = nvoices + 1; do { GetNextWord(w, s, blank_, comma_); curtail(w, comma_); if (*w != '\0') { k++; if (k <= 2) { nvoices++; checkLabel(w); strcpy(voice_label[nvoices-1], w); if (*instr_name[nstaves-1] == '\0') { strcpy(instr_name[nstaves-1], w); /* p2c: preamble.pas, line 266: * Note: Possible string truncation in assignment [145] */ } setStavePos(nvoices, nstaves, k); } } } while (*w != '\0'); if (k > 2) { sprintf(STR1, "More than two voices per stave: %s", s); error(STR1, print); } if (k == 2) { sprintf(instr_name[nstaves-1], "\\mtxTwoInstruments{%s}{%s}", voice_label[nvoices-2], voice_label[nvoices-1]); /* p2c: preamble.pas, line 273: * Note: Possible string truncation in assignment [145] */ } number_on_stave[nstaves-1] = k; } } while (*line != '\0'); FORLIM = nvoices; for (k = 0; k <= FORLIM - 1; k++) selected[k] = true; }
Char *startString(Char *Result, voice_index0 voice) { Char s[256], w[256]; voice_index j; strcpy(s, start_line); for (j = 1; j <= voice; j++) GetNextWord(w, s, dummy, ';'); curtail(w, ';'); if (*w != '\0') { sprintf(Result, "%s ", w); return Result; } else return strcpy(Result, w); }
Static void applyStyles(void) { short n1, n2, sn; Char s[256]; Char STR2[256]; *voices = '\0'; *clefs = '\0'; ninstr = 0; while (*cline[(long)style] != '\0') { n1 = voiceCount(voices) + 1; n2 = wordCount(voices) + 1; GetNextWord(s, cline[(long)style], blank_, comma_); curtail(s, comma_); sn = findStyle(s); if (sn == 0) { sprintf(STR2, "Style %s unknown", s); error(STR2, print); } line_no = orig_style_line[sn-1]; applyStyle(known_style[sn-1], s, n1, n2); style_used[sn-1] = true; } }
void doExecution() { pid_t pid; Process *proc; char *input = (char *) malloc(sizeof(char) * (INPUT_BUFFER_SIZE + 1)); char *currdir = (char *) malloc(sizeof(char) * (CURRDIR_BUFFER_SIZE + 1)); char *hostname = (char *) malloc(sizeof(char) * (CURRDIR_BUFFER_SIZE + 1)); char *fgetsResult; //int pipefd[2]; // Read the input memset(input, 0, (INPUT_BUFFER_SIZE + 1)); memset(currdir, 0, (CURRDIR_BUFFER_SIZE + 1)); memset(hostname, 0, (CURRDIR_BUFFER_SIZE + 1)); // Read the machine name gethostname(hostname, CURRDIR_BUFFER_SIZE); // The loop that goes for days while (1) { // Read current directory getcwd(currdir, CURRDIR_BUFFER_SIZE); printf("%s> [%s]# ", hostname, currdir); // Set the buffer to "empty" input[0] = 0; // Read from command line fgetsResult = fgets(input, INPUT_BUFFER_SIZE, stdin); // Make sure the input string is curtailed first curtail(input); // Continue with loop if (strlen(input) >= 1) { // Read proc proc = readCommand(input, strlen(input)); // Verify that the executable exists // Put the prog in argv if (proc->argv) proc->argv[0] = proc->prog; else { // We have to make up an argv proc->argv = (char **) malloc(sizeof(char *) * 2); proc->argv[0] = proc->prog; proc->argv[1] = NULL; } // EXEC BREH //pipe(pipefd); pid = fork(); if (pid > 0) { // This is the parent proc->pid = pid; if (!(proc->backgrounded)) { // Wait for the kid do { pid = wait(&(proc->status)); // if (pid != proc->pid) process_terminated(pid); } while (pid != proc->pid); // Child has now exited // printf("Child exited with status %d.\n", proc->status); } else { printf("Child started in background.\n"); } } else if (pid < 0) { printf("THE FORK FAILED....PANICCCCCCCCCCCCCCC!\n"); exit(1); } else { // This is the child if (proc->backgrounded) { // IF backgrounding - then we have to do something setpgid(0, 0); } // Input redirection if (proc->in != -1) { // Replace stdin with infile close(0); dup(proc->in); close(proc->in); } // Output redirection if (proc->out != -1) { // Replace stdout with outfile close(1); dup(proc->out); close(proc->out); } execvp(proc->prog, proc->argv); // If we got this far the call failed printf("Could not execute the command as entered - please try again."); exit(1); } } else if (fgetsResult == NULL) { printf("Received Ctrl + D (the EOF) - now exiting...\n"); exit(0); } else { // Empty input - so don't do anything } } }
Static void applyStyle(Char *s_, Char *stylename, stave_index first_inst, stave_index first_stave) { Char s[256]; Char clef[256], subline[256], subcommand[256]; stave_index0 i, last_inst, last_stave; boolean continuo = false, toosoon = false, vocal = false; Char STR2[256]; strcpy(s, s_); last_inst = first_inst - 1; GetNextWord(subline, s, blank_, colon_); while (*s != '\0') { GetNextWord(subline, s, semicolon, dummy); i = curtail(subline, semicolon); GetNextWord(subcommand, subline, blank_, dummy); if (equalsIgnoreCase(subcommand, "VOICES")) { sprintf(voices + strlen(voices), " %s", subline); last_stave = first_stave + wordCount(subline) - 1; last_inst = first_inst + voiceCount(subline) - 1; } else if (equalsIgnoreCase(subcommand, "CLEFS")) { strcpy(clef, subline); sprintf(clefs + strlen(clefs), " %s", clef); } else if (equalsIgnoreCase(subcommand, "VOCAL")) { if (last_inst < first_inst) toosoon = true; else { some_vocal = true; vocal = true; for (i = first_inst; i <= last_inst; i++) setVocal(i, true); } } else if (equalsIgnoreCase(subcommand, "CHORAL") || equalsIgnoreCase(subcommand, "GROUP")) { if (last_inst < first_inst) toosoon = true; else { if (equalsIgnoreCase(subcommand, "CHORAL")) { some_vocal = true; vocal = true; for (i = first_inst; i <= last_inst; i++) setVocal(i, true); } if (ngroups == maxgroups) error("Too many groups", print); else { ngroups++; group_start[ngroups-1] = first_stave; group_stop[ngroups-1] = last_stave; } } } else if (equalsIgnoreCase(subcommand, "CONTINUO")) continuo = true; else { sprintf(STR2, "Subcommand %s in STYLE unknown", subcommand); error(STR2, print); } if (toosoon) { sprintf(STR2, "You must first give VOICES before specifying %s", subcommand); error(STR2, print); } } if (vocal && continuo) error("A continuo instrument may not be vocal", print); if (wordCount(clef) != last_stave - first_stave + 1) error("Number of clefs does not match number of voices", print); if (first_stave == last_stave || continuo) { strcpy(instr_name[first_stave-1], stylename); /* p2c: preamble.pas, line 185: * Note: Possible string truncation in assignment [145] */ } else { for (i = first_stave - 1; i <= last_stave - 1; i++) *instr_name[i] = '\0'; } if (continuo) { ninstr++; stave[ninstr-1] = first_stave; for (i = first_stave - 1; i <= last_stave - 1; i++) instr[i] = ninstr; return; } for (i = first_stave; i <= last_stave; i++) { ninstr++; stave[ninstr-1] = i; instr[i-1] = ninstr; } }
static F1(jtcoeff){V*v; RZ(w); v=VAV(w); R VTAYFINITE&v->flag ? curtail(VAV(v->f)->g) : mtv; } /* coefficents c in {&c@(n&<.), or empty */