DWORD WINAPI startsrv(LPVOID data) { #else void * startsrv(void * data) { #endif struct child *d = (struct child *)data; mainfunc(d->argc, (char **)d->argv); return 0; } int included =0; int getrotate(char c){ switch(c){ case 'c': case 'C': return MINUTELY; case 'h': case 'H': return HOURLY; case 'd': case 'D': return DAILY; case 'w': case 'W': return WEEKLY; case 'y': case 'Y': return ANNUALLY; case 'm': case 'M': return MONTHLY; default: return NEVER; } } unsigned char * dologname (unsigned char *buf, unsigned char *name, const unsigned char *ext, ROTATION lt, time_t t) { struct tm *ts; ts = localtime(&t); if(strchr((char *)name, '%')){ struct clientparam fakecli; memset(&fakecli, 0, sizeof(fakecli)); dobuf2(&fakecli, buf, NULL, NULL, ts, (char *)name); } else switch(lt){ case NONE: sprintf((char *)buf, "%s", name); break; case ANNUALLY: sprintf((char *)buf, "%s.%04d", name, ts->tm_year+1900); break; case MONTHLY: sprintf((char *)buf, "%s.%04d.%02d", name, ts->tm_year+1900, ts->tm_mon+1); break; case WEEKLY: t = t - (ts->tm_wday * (60*60*24)); ts = localtime(&t); sprintf((char *)buf, "%s.%04d.%02d.%02d", name, ts->tm_year+1900, ts->tm_mon+1, ts->tm_mday); break; case DAILY: sprintf((char *)buf, "%s.%04d.%02d.%02d", name, ts->tm_year+1900, ts->tm_mon+1, ts->tm_mday); break; case HOURLY: sprintf((char *)buf, "%s.%04d.%02d.%02d-%02d", name, ts->tm_year+1900, ts->tm_mon+1, ts->tm_mday, ts->tm_hour); break; case MINUTELY: sprintf((char *)buf, "%s.%04d.%02d.%02d-%02d.%02d", name, ts->tm_year+1900, ts->tm_mon+1, ts->tm_mday, ts->tm_hour, ts->tm_min); break; default: break; } if(ext){ strcat((char *)buf, "."); strcat((char *)buf, (char *)ext); } return buf; } int start_proxy_thread(struct child * chp){ pthread_t thread; #ifdef _WIN32 HANDLE h; #endif conf.threadinit = 1; #ifdef _WIN32 #ifndef _WINCE h = (HANDLE)_beginthreadex((LPSECURITY_ATTRIBUTES )NULL, 16384+conf.stacksize, (void *)startsrv, (void *) chp, (DWORD)0, &thread); #else h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, 16384+conf.stacksize, (void *)startsrv, (void *) chp, (DWORD)0, &thread); #endif if(h)CloseHandle(h); #else pthread_attr_init(&pa); pthread_attr_setstacksize(&pa,PTHREAD_STACK_MIN + (16384+conf.stacksize)); pthread_attr_setdetachstate(&pa,PTHREAD_CREATE_DETACHED); pthread_create(&thread, &pa, startsrv, (void *)chp); #endif while(conf.threadinit)usleep(SLEEPTIME); if(haveerror) { fprintf(stderr, "Service not started on line: %d\n", linenum); return(40); } return 0; }
ATF_TC_BODY(swapcontext2, tc) { alter_tlsbase = 1; mainfunc(); }
/* _WinMain: * Entry point for Windows GUI programs, hooked by a macro in alwin.h, * which makes it look as if the application can still have a normal * main() function. */ int _WinMain(void *_main, void *hInst, void *hPrev, char *Cmd, int nShow) { int (*mainfunc) (int argc, char *argv[]) = (int (*)(int, char *[]))_main; char *argbuf; char *cmdline; char **argv; int argc; int argc_max; int i, q; (void)hInst; (void)hPrev; (void)Cmd; (void)nShow; /* can't use parameter because it doesn't include the executable name */ cmdline = GetCommandLine(); i = strlen(cmdline) + 1; argbuf = al_malloc(i); memcpy(argbuf, cmdline, i); argc = 0; argc_max = 64; argv = al_malloc(sizeof(char *) * argc_max); if (!argv) { al_free(argbuf); return 1; } i = 0; /* parse commandline into argc/argv format */ while (argbuf[i]) { while ((argbuf[i]) && (isspace(argbuf[i]))) i++; if (argbuf[i]) { if ((argbuf[i] == '\'') || (argbuf[i] == '"')) { q = argbuf[i++]; if (!argbuf[i]) break; } else q = 0; argv[argc++] = &argbuf[i]; if (argc >= argc_max) { argc_max += 64; argv = al_realloc(argv, sizeof(char *) * argc_max); if (!argv) { al_free(argbuf); return 1; } } while ((argbuf[i]) && ((q) ? (argbuf[i] != q) : (!isspace(argbuf[i])))) i++; if (argbuf[i]) { argbuf[i] = 0; i++; } } } argv[argc] = NULL; /* call the application entry point */ i = mainfunc(argc, argv); al_free(argv); al_free(argbuf); return i; }
void program(){ symbol_t t = 0, id = 0; nextSym(); if(sym->type == CONST){ nextSym(); constant(); } if(isType(sym)){ do{ t = copySym(sym); nextSym(); if(sym->type==MAIN){ nextSym(); mainfunc(t); mfree(t); break; } if(sym->type != ID){ msg(ERR, "missing a identifier after a type name", line); ERROR_STATUS = 1; do nextSym(); while(sym->type != ID && sym->type != SEMIC && sym->type != SEOF); if(sym->type == SEOF) break; if(sym->type == SEMIC){ nextSym(); continue; } } id = copySym(sym); nextSym(); if(sym->type == LPAREN)break; variable(t, id); mfree(t); }while(isType(sym) || sym->type == VOID); }else if(sym->type==VOID){ t = copySym(sym); nextSym(); if(sym->type==MAIN){ nextSym(); mainfunc(t); mfree(t); }else{ if(sym->type != ID){ msg(ERR, "missing a identifier after a type name", line); ERROR_STATUS = 1; do nextSym(); while(sym->type != ID && sym->type !=SEOF); }else{ id = copySym(sym); nextSym(); if(sym->type!=LPAREN){ msg(ERR, "missing \'(\'", line); ERROR_STATUS = 1; // something } } } } while(sym->type==LPAREN){ nextSym(); funcdef(t, id); mfree(t);mfree(id); if(!(isType(sym)||sym->type==VOID))break; t = copySym(sym); nextSym(); if(sym->type==MAIN){ nextSym(); mainfunc(t); mfree(t); break; } if(sym->type!=ID){ msg(ERR, "missing a identifier after a type name", line); ERROR_STATUS = 1; do nextSym(); while(sym->type != ID && sym->type !=SEOF); if(sym->type == SEOF) break; } id = copySym(sym); nextSym(); } if(sym->type!=SEOF){ ERROR_STATUS = 1; msg(MSG, "Error occured!", 0); } }