static bool parseLine (const char * line, struct tr_ipv4_range * range) { return parseLine1 (line, range) || parseLine2 (line, range); }
static int parseScript2(FILE *from, int *embedArgc, char ***embedArgv, int option) { static char fname[] = "parseScript"; char *buf, line[MAXLINELEN*10], *prompt; register int ttyin = 0; int length = 0, size = 10*MAXLINELEN; int i, j, lineLen; char firstLine[MAXLINELEN*10]; char *sp; int notBourne = FALSE; static char szTmpShellCommands[] = "%s\n) > $LSB_CHKFILENAME.shell\n" "chmod u+x $LSB_CHKFILENAME.shell\n" "$LSB_JOBFILENAME.shell\n" "saveExit=$?\n" "/bin/rm -f $LSB_JOBFILENAME.shell\n" "(exit $saveExit)\n"; if (logclass & (LC_TRACE | LC_SCHED | LC_EXEC)) ls_syslog(LOG_DEBUG, "%s: Entering this routine...", fname); if (option & EMBED_BSUB) prompt = "bsub> "; else if (option & EMBED_QSUB) prompt = "qsub> "; if (option & EMBED_INTERACT) { firstLine[0] = '\0'; if ((buf = malloc(size)) == NULL) { fprintf(stderr, _i18n_msg_get(ls_catd, NL_SETN, 802, "Unable to allocate memory for commands")); return -1; } ttyin = isatty(fileno(from)); if (ttyin){ printf(prompt); fflush(stdout); } } sp = line; lineLen = 0; while (fgets (sp, 10 *MAXLINELEN - lineLen -1, from) != NULL) { lineLen = strlen(line); if (line[lineLen-2] == '\\' && line[lineLen-1] == '\n') { lineLen -= 2; sp = line + lineLen; continue; } if (parseLine2(line, embedArgc, embedArgv, option) == -1) return -1; if (option & EMBED_INTERACT) { if (!firstLine[0]) { sprintf(firstLine, "( cat <<%s\n%s", SCRIPT_WORD, line); strcpy(line, firstLine); notBourne = TRUE; } lineLen = strlen(line); if (length + lineLen + 20 >= size) { size = size * 2; if ((sp = (char *) realloc(buf, size)) == NULL) { free(buf); fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,807 , "Unable to reallocate memory for commands"))); /* catgets 807 */ return -1; } buf = sp; } for (i=length, j=0; j<lineLen; i++, j++) buf[i] = line[j]; length += lineLen; if (ttyin) { printf(prompt); fflush(stdout); } } sp = line; lineLen = 0; } if (option & EMBED_INTERACT) { buf[length] = '\0'; if (firstLine[0] != '\n' && firstLine[0] != '\0') { if (notBourne == TRUE) { if (length + strlen(szTmpShellCommands) + 1 >= size) { size = size + strlen(szTmpShellCommands) + 1; if ((sp = (char *) realloc(buf, size)) == NULL ) { free(buf); fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,808 , "Unable to reallocate memory for temp shell file"))); /* catgets 808 */ return -1; } buf = sp; } sprintf(&buf[length], szTmpShellCommands, SCRIPT_WORD_END); } } commandline = buf; } return 0; }