int dodfined ( /* replaces defined commands with 0 or 1 */ char *ln) { int b, c, d, pflag; pflag = FALSE; while (b = findstr (1, ln, " defined ")) { c = b + 8; /* point to next token */ if (ln[c] == '(') { c += 2; /* point to identifier token */ pflag = TRUE; } d = dodef (ln, c - 1); /* returns TRUE if defined, FALSE if not defined */ while (ln[++c] != ' ') /* get space at end of identifier */ ; if (pflag) { if (ln[++c] == ')' && ln[++c] == ' ') ; else doerr (3, c); /* No end ) */ } ln[b] = d + '0'; /* replace defined with 0 or 1 */ strcpy (&ln[++b], &ln[c]); } }
void dowheel (gdImagePtr im, int color, char *fontfile, int fontsize, double angle, int x, int y, int offset, char *string) { int brect[8]; FILE *err; double curangrads, curang, x0, y0; char *cp; err = fopen ("err.out", "a"); doerr (err, "------------- New fontwheel --------------"); doerr (err, fontfile); doerr (err, string); doerr (err, "------------------------------------------"); for (curang = 0.0; curang < 360.0; curang += angle) { curangrads = DEGTORAD(curang); x0 = x + cos (curangrads) * offset; y0 = y - sin (curangrads) * offset; /* The case of newlines is taken care of in the gdImageStringTTF call */ #if defined(OLDER_GD) cp = gdImageStringTTF (im, brect, color, fontfile, fontsize, curangrads, x0, y0, string); #else cp = gdImageStringFT (im, brect, color, fontfile, fontsize, curangrads, x0, y0, string); #endif if (cp) doerr (err, cp); gdImagePolygon (im, (gdPointPtr)brect, 4, color); } fclose (err); }
int putiddtbl (int b, int d) { register int i; if (d - b > 30) /* If identifier length is >31 ... */ d = b + 30; /* set identifier length = 31 */ for (i = b; i <= d; ++i) /* Put def name in $trng table */ { if (dptr < &dstrtbl[STRNG_TBL_MAX - 2]) /* test $trng table */ *dptr++ = line[i]; else doerr (5, i); /* $trng table full -- FATAL ERROR */ } *dptr++ = ' '; /* add ending space */ *dptr++ = 0; /* NULL terminate $trng */ }
int doendif (void) { if (iflvl < 0) { doerr (16, 3); /* nesting error */ return; } if (ifstat[--iflvl] != DEAD) { procsw = ifstat[iflvl]; tattle ("doendif(alive)","endif"); } else tattle ("doendif(DEAD)", "endif"); }
int doelse (void) { if (iflvl < 0 || ifnest[iflvl] == 1) { doerr (16, 3); /* improper nesting */ return; } --ifnest[iflvl]; if (ifstat[iflvl] != DEAD) { procsw = ifstat[iflvl] = 1 - ifstat[iflvl]; /* flip T or F status */ } }
int putdtbl ( /* Given B: Start pos. of identifier/ C: end pos. */ int b, int c /* Puts identifier in define $trng tbl */ ) { register int i; for (i = b; i <= c; ++i) { if (dptr < &dstrtbl[STRNG_TBL_MAX - 1]) /* test $trng table */ *dptr++ = line[i]; else doerr (5, i); /* $trng table full -- FATAL ERROR */ } *dptr++ = 0; /* NULL terminate $trng */ /* fprintf(stderr,"dtbl bytes=%d\n",dptr-dstrtbl); */ }
void doif (char *ln) { if (iflvl == MAX_NEST_IF) { doerr (15, ln - line); /* Too many nested #ifs */ return; } if (procsw) { /* evaluate IF & return T or F */ ifstat[++iflvl] = procsw = gettorf (ln); } else { ifstat[++iflvl] = DEAD; /* unused #if */ } tattle ("doif",ln); ifnest[iflvl] = 2; }
int doelif (char *ln) { if (iflvl < 0 || ifnest[iflvl] == 1) { doerr (16, ln - line); /* improper nesting */ return; } if (ifstat[iflvl] == TRUE) { ifstat[iflvl] = DEAD; procsw = FALSE; } if (ifstat[iflvl] == FALSE) { /* evaluate IF & return T or F */ procsw = ifstat[iflvl] = gettorf (ln); } ifnest[iflvl] = 2; }
static int handle_ssl_error2(SSL * ssl, int ret, int * accepted_errors, int * retcode, int accepted_error_cnt){ int err = SSL_get_error(ssl, ret); for(int i = 0; i < accepted_error_cnt; i++) if(accepted_errors[i] == err) return retcode[i]; #define doerr(kind)case kind: ERROR(#kind); break; switch(err){ doerr(SSL_ERROR_SSL); case(SSL_ERROR_SYSCALL): ERROR("SSL_ERROR_SYSCALL error id: %i %i", ERR_get_error(), ret); //doerr(SSL_ERROR_WANT_ASYNC); doerr(SSL_ERROR_WANT_CONNECT); doerr(SSL_ERROR_WANT_ACCEPT); doerr(SSL_ERROR_WANT_READ); doerr(SSL_ERROR_WANT_WRITE); doerr(SSL_ERROR_ZERO_RETURN); case SSL_ERROR_NONE: break; } return 0; }
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 ()); } }
/* Returns NULL if no errors */ int dodefine (int a, int b) { int c, d; if ((d = c = getident (line, b)) == ERROR) /* Get identifier */ return (doerr (1, b)); /* Return if invalid identifier */ /* fprintf(stderr,"In dodef, defining '%s'\n",&line[b]); */ /* Lets convert a crashed program into an error exit here folks, by checking to see if we've run out of deftbl room regardless of the status of the string table checked on later. Gene Heskett WDTV5CE. */ if ((defcntr + 1) >= MAX_DEFS) doerr (21, b); /* doerr() will exit(0) on this one */ defnam[defcntr] = dptr; /* Put identifier addr in def name tbl */ putiddtbl (b, d); /* Put def name in $trng table */ /* fprintf(stderr,"DODEFINE: line[c+1]=|%c|\n",line[c+1]); fprintf(stderr,"DODEFINE: line=%s\n",line); */ if (line[c + 1] == '(') /* if def is macro... */ { d = b = skpbl (line, c + 2); /* Align to 1st non-space char in macro */ if (line[b] != ')') /* if more than 0 arguments in macro */ { --b; defarg[defcntr] = dptr; do /* Scan argument format */ { /* fprintf(stderr,"DODEF (): b=|%d|\n",b); */ ++b; b = skpbl (line, b); /* fprintf(stderr,"DODEF (2): b=|%d|\n",b); */ if ((c = getident (line, b)) == ERROR) /* Get identifier (args) */ return (doerr (2, b)); /* return if any args missing */ putdtbl (b, c); /* put args in $trng table */ /* fprintf(stderr,"DODEF (): dfarg=|%s|\n",defarg[defcntr]);*/ *(dptr - 1) = ' '; b = skpbl (line, c + 1); /* Should now point at , or ) */ /* fprintf(stderr,"DODEF (3): b=|%d|\n",b); */ if (line[b] != ',' && line[b] != ')') /* If not ) or , error */ return (doerr (3, b)); /* so return */ } while (line[b] != ')'); *dptr++ = 0; /* fprintf(stderr,"DODEF: dfarg=|%s|\n",defarg[defcntr]); */ } else { if (dptr + 5 >= &dstrtbl[STRNG_TBL_MAX - 1]) /* table overflow */ doerr (5, b); strcpy (--dptr, "( ) "); dptr += 5; defarg[defcntr] = NULL; /* 0 args in macro */ } } else /* define is not a macro */ { b = c; defarg[defcntr] = NULL; } if (line[b + 1] == '\n') /* If EOL then define = 1 */ { line[b + 1] = ' '; line[b + 2] = '1'; /* This does not test LINE to see if it is full */ line[b + 3] = '\n'; } b += 2; /* locate 1st char of token-sequence */ c = rskpbl (line, a - 1); /* locate last char of token-sequence */ deftok[defcntr++] = dptr; /* Put token addr in tok table */ putdtbl (b, c); /* Copy token into $trng table */ return NULL; /* No errors */ }