int AGOSEngine_PN::actCallD(int n) { int pf[8]; funcentry(pf, n); addstack(kJmpClassNum); funccpy(pf); setposition(n, 0); return doline(1); }
int LineParser::parse(char *line, int ignore_escaping/*=0*/) // returns -1 on error { freetokens(); bool bPrevCB=m_bCommentBlock; int n=doline(line, ignore_escaping); if (n) return n; if (m_nt) { m_bCommentBlock=bPrevCB; m_tokens=(char**)malloc(sizeof(char*)*m_nt); n=doline(line, ignore_escaping); if (n) { freetokens(); return -1; } } return 0; }
int main() { int length = 0; char str[MAXLENGTH]; while ((length = getline(str)) > 0) { if (doline(str) == SUCCESS) printf("\t%.8g\n", pop()); else printf("Calculate ERROR!\n"); } return 0; }
static void readlines(void) { char *line = NULL; size_t alloc_size = 0; ssize_t len; while ((len = getline(&line, &alloc_size, stdin)) >= 0) { if (len > 0 && line[len-1] == '\n') line[--len] = '\0'; if (len == 0) continue; if (doline(line, len)) break; } free(line); }
void rfc2045_parse(struct rfc2045 *h, const char *buf, size_t s) { size_t l; while (s) { for (l=0; l<s; l++) if (buf[l] == '\n') break; if (l < s && buf[l] == '\n') { ++l; rfc2045_add_workbuf(h, buf, l); doline(h); h->workbuflen=0; } else rfc2045_add_workbuf(h, buf, l); buf += l; s -= l; } if (h->workbuflen > 1024) rfc2045_parse_partial(h); }
int LineParser::doline(char *line, int ignore_escaping/*=0*/) { m_nt=0; if ( m_bCommentBlock ) { while ( *line ) { if ( *line == '*' && *(line+1) == '/' ) { m_bCommentBlock=false; // Found end of comment block line+=2; break; } line++; } } while (*line == ' ' || *line == '\t') line++; while (*line) { int lstate=0; // 1=", 2=`, 4=' if (*line == ';' || *line == '#') break; if (*line == '/' && *(line+1) == '*') { m_bCommentBlock = true; line+=2; return doline(line, ignore_escaping); } if (*line == '\"') lstate=1; else if (*line == '\'') lstate=2; else if (*line == '`') lstate=4; if (lstate) line++; int nc=0; char *p = line; while (*line) { if (line[0] == '$' && line[1] == '\\') { switch (line[2]) { case '"': case '\'': case '`': nc += ignore_escaping ? 3 : 1; line += 3; continue; } } if (lstate==1 && *line =='\"') break; if (lstate==2 && *line =='\'') break; if (lstate==4 && *line =='`') break; if (!lstate && (*line == ' ' || *line == '\t')) break; line++; nc++; } if (m_tokens) { int i; m_tokens[m_nt]=(char*)malloc(nc+1); for (i = 0; p < line; i++, p++) { if (!ignore_escaping && p[0] == '$' && p[1] == '\\') { switch (p[2]) { case '"': case '\'': case '`': p += 2; } } m_tokens[m_nt][i] = *p; } m_tokens[m_nt][nc]=0; } m_nt++; if (lstate) { if (*line) line++; else return -2; } while (*line == ' ' || *line == '\t') line++; } return 0; }
int main(void) { doline(0); return status; }
int prep (void) /* Check for preprocessor commands */ { int b, c; char *ln; ln = line; while (*(++ln) == '#' || *ln == ' ') /* locate first directive character */ ; if ( ! *ln) /* NULL directive */ return (killine ()); /* fprintf(stderr,"prep - line=%s\n",ln); */ if (strcmp2 (ln, "if ") || strcmp2 (ln, "ifdef ") || strcmp2 (ln, "ifndef ")) { /* fprintf(stderr,"prep - calling doif(%s)\n",ln); */ doif (ln); return (killine ()); } if (strcmp2 (ln, "else")) { doelse (); return (killine ()); } if (strcmp2 (ln, "endif")) { doendif (); return (killine ()); } if (strcmp2 (ln, "elif ")) { doelif (ln); return (killine ()); } if (procsw) { if (strcmp2 (ln, "define ")) { c = getident (ln, 7) + 2; /* get end of identifier */ splittok (ln, c); /* tokenize rest of line */ dodefine (strlen (line), &ln[7] - line); /* store #define info */ /* fprintf(stderr,"PREP (after dodef): line=|%s|\n",line); */ tstdupdef (); /* Check for def duplication and fix */ return (killine ()); /* Discard #define line */ } if (strcmp2 (ln, "include ")) { doinclude (&ln[8]); /* open include file */ return (killine ()); /* Discard #include line */ } if (strcmp2 (ln, "undef ")) { /* fprintf(stderr,"prep - undef found %s\n",ln); */ doundef (&ln[6]); /* remove undef identifier from def table */ /* fprintf(stderr,"prep - doundef done\n"); */ return (killine ()); /* Discard #undef line */ } if (strcmp2 (ln, "error ")) { fprintf (stderr, "User error - %s\n", &ln[6]); /* print error */ return (killine ()); /* Discard #error line */ } if (strcmp2 (ln, "asm")) { for (;;) /* send all following lines through for assembler */ { getln (0); if (eflag) break; if (findstr (1, line, "#endasm")) break; if (cflag) puts ("#2"); else printf ("#pragma asm "); printf ("%s\n", line); } if (eflag && cflag) /* error only in Microware mode (no #endasm) */ doerr (18, 1); return (killine ()); } if (strcmp2 (ln, "pragma ")) { dopragma (ln + 7); return (killine ()); } if (strcmp2 (ln, "line ")) { doline (ln + 5); return (killine ()); } doerr (17, 1); /* Illegal preprocessor directive */ return (killine ()); } }
int main(int argc, char ** argv) { char * fn; int ix; if (3 > argc) return fprintf(stderr, "Specify library file name and copy file name(s).\n"), 1; if (openout(argv[1])) return 16; if (getdir(cards * 80)) return 20; for (ix = 2; argv[ix]; ix++) { char * dot; char * slash; char * name; int namelen; int ismacro = 1; /* Assume file is macro */ char * s; fn = argv[ix]; f = fopen(fn, "r"); if (!f) return fprintf(stderr, "Cannot open %s: %s\n", fn, strerror(errno)), 16; slash = strrchr(fn, '/'); name = slash ? slash + 1 : fn; namelen = strlen(name); dot = strrchr(name, '.'); if (dot) { namelen = dot - name; if (!strcmp(dot + 1, "copy")) ismacro = 0; } s = gline(); if (!s) continue; if (!ismacro && memcmp(s, "*COPY ", 6)) ismacro = 1; /* Not stacked copy */ if (ismacro) { loadname(name, namelen); if (doline(line)) return 20; } else if (newmember(s)) return 20; for (;;) { s = gline(); if (!s) break; if (!ismacro && !memcmp(s, "*COPY ", 6)) { if (eom()) return 20; if (newmember(s)) return 20; continue; } if (doline(line)) return 20; } if (eom()) return 20; } if (wrapup(dirs, dir)) return 16; printf("%s %d files %d members.\n", fno, ix - 2, members); return 0; }
static void mainloop(struct PCP *pcp) { int c; struct pcpdtimer inactivity_timeout; int my_acl_flags=PCP_ACL_MODIFY|PCP_ACL_CONFLICT| PCP_ACL_LIST|PCP_ACL_RETR; deleted_eventid=NULL; memset(&new_commit, 0, sizeof(new_commit)); new_commit_times=NULL; new_commit_participants=NULL; new_commit_participants_buf=NULL; termsig=0; setsigs(); inp_ptr=0; inp_left=0; need_rset=0; time(&prev_time); pcpdtimer_init(&inactivity_timeout); inactivity_timeout.handler=inactive; if (proxy_userid) { struct get_acl ga; ga.who=proxy_userid; ga.flags=0; if (pcp_has_acl(pcp)) { if (pcp_list_acl(pcp, get_acl_callback, &ga) == 0) { if (ga.flags == 0) { ga.who="public"; if (pcp_list_acl(pcp, get_acl_callback, &ga)) ga.flags=0; } } else ga.flags=0; } my_acl_flags=ga.flags; } do { char *p; input_line_len=0; pcpdtimer_install(&inactivity_timeout, 30 * 60); for (;;) { c=inputchar(pcp); if (termsig || c == '\n') break; input_buffer[input_line_len++]=c; } if (termsig) break; input_buffer[input_line_len]=0; for (p=input_buffer; *p; p++) if (isspace((int)(unsigned char)*p)) *p=' '; pcpdtimer_triggered(&inactivity_timeout); /* Cancel inactivity_timeout for the duration of the command */ } while (doline(pcp, input_buffer, my_acl_flags) == 0 && !termsig); alarm(0); free(input_buffer); rset(pcp); }
int main(int argc, char **argv) { doline(0); return status; }