int main(int argc, char* argv[] ) { int from = 1; int to = CONFIG_NSIGS; int ncases; int i; int pos; int number; int totalResult; dcTest_initPlatform(); InitEnv(); appname = argv[0]; pos = 0; for(i = 1 ; i < argc ; ++i ) { if ( argv[i][0] == '-' ) { switch(argv[i][1]) { case 'v': OptionVerbose = 1; continue; case 'h': PrintUsage(appname); return 0; default: Error("invalid option: %s", argv[i]); } } number = atoi(argv[i]); switch(pos) { case 0: to = from = number; ++pos; break; case 1: to = number; break; default: Error("too many arguments%s", ""); } } assert(from > 0); assert(to <= CONFIG_NSIGS); assert(from <= to); ncases = (to - from) + 1; PrintHeader(); TestRange(from, to); totalResult = (totalErrorCodes[1] == ncases) ? 1 : 0; PrintTotalResult(totalResult); dcTest_deInitPlatform(); return 0; }
/** * Push the environment onto the stack. * InitEnv() will be called if the initial environment hasn't been set. */ void Env::PushEnv() { lua_State *L = GetState(); if (initialized) { envRef.Push(); // env } else { lua_newtable(L); // env InitEnv(); // env initialized = true; lua_pushvalue(L, -1); // env env envRef.SetFromStack(); // env } }
int main(int argc, char *argv[]) { InitEnv(); SDL_Window* win = NULL; SDL_Renderer* ren = NULL; SDL_Texture* tex = NULL; // CreateWindowRendererWrapper(std::ref(win), std::ref(ren)); win = SDL_CreateWindow("Flappy Bird", 100, 100, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI); ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED); if (win == NULL ) std::cout << "win == NULL" << std::endl; if (ren == NULL) std::cout << "ren == NULL" << std::endl; SDL_RenderClear(ren); tex = LoadImage("./res/bg.png", &ren); ApplySurface(0, 0, tex, ren); SDL_RenderPresent(ren); SDL_Delay(1000); BgScroll(100, tex, ren); SDL_Delay(2000000); SDL_DestroyTexture(tex); SDL_DestroyRenderer(ren); SDL_DestroyWindow(win); SDL_Quit(); return 0; }
void mg_bool_query(char *qstr, char *dir, char *file, void **rqd) { InitQueryTimes iqt ; query_data *qd ; BooleanQueryInfo bqi ; char *line ; InitEnv() ; qd = InitQuerySystem(dir, file, &iqt) ; bqi.MaxDocsToRetrieve=-1 ; if(qd != NULL) { bool_tree_node *tree ; DocList *Docs ; int res=0; tree = ParseBool(qstr, strlen(qstr), &(qd->TL), qd->sd->sdh.stem_method, &res) ; if (res != 0) { qd->DL = NULL ; } else { ReadInTermInfo(qd) ; FindNoneTerms(qd, tree) ; OptimiseBoolTree(tree, qd->TL, 1) ; qd->hops_taken=qd->num_of_ptrs=qd->num_of_terms=0 ; Docs = BooleanGet(qd, tree, &bqi) ; if (qd->id->ifh.InvfLevel==3) AdjustParaDocs(qd, Docs) ; FreeQueryDocs(qd) ; qd->DL = Docs ; } } *rqd = (void *)qd ; }
VOID ReadEnvFile(CHAR *EnvFileName) { INT i, j; /* Indices. */ INT stat; /* Input var status counter. */ INT dummy; CHAR opcode; /* Environment spec opcode. */ CHAR command[30]; /* Environment spec command. */ CHAR opparam[30]; /* Command parameter. */ CHAR dummy_char[60]; CHAR datafile[10]; BOOL lights_set; /* Lights set? */ FILE *pf; /* Input file pointer. */ LIGHT *lptr, *lastlight; /* Light node pointers. */ /* Open command file. */ pf = fopen(EnvFileName, "r"); if (!pf) { printf("Unable to open environment file %s.\n", EnvFileName); exit(-1); } InitEnv(); /* Set defaults. */ nlights = 0; lights_set = FALSE; /* Process command file according to opcodes. */ while (fscanf(pf, "%s", command) != EOF) { opcode = LookupCommand(command); switch (opcode) { /* Eye position. */ case OP_EYE: stat = fscanf(pf, "%lf %lf %lf", &(View.eye[0]), &(View.eye[1]), &(View.eye[2])); if (stat != 3) { printf("error: eye position.\n"); exit(-1); } break; /* Center of interest position. */ case OP_COI: stat = fscanf(pf, "%lf %lf %lf", &(View.coi[0]), &(View.coi[1]), &(View.coi[2])); if (stat != 3) { printf("error: coi position.\n"); exit(-1); } break; /* Background color. */ case OP_BKGCOL: stat = fscanf(pf, "%lf %lf %lf", &(View.bkg[0]), &(View.bkg[1]), &(View.bkg[2])); if (stat != 3) { printf("error: background color.\n"); exit(-1); } if (!VerifyColorRange(View.bkg)) exit(-1); break; /* Viewing angle in degrees. */ case OP_VANG: stat = fscanf(pf, "%lf", &(View.vang)); if (stat != 1) { printf("error: viewing angle.\n"); exit(-1); } if (View.vang < 0.0 || View.vang > 100.0) { printf("Invalid angle %f.\n", View.vang); exit(-1); } break; /* Ambient. */ case OP_AMBIENT: stat = fscanf(pf, "%lf %lf %lf", &(View.ambient[0]), &(View.ambient[1]), &(View.ambient[2])); if (stat != 3) { printf("error: ambient.\n"); exit(-1); } if (!VerifyColorRange(View.ambient)) exit(-1); break; /* Anti-aliasing level. */ case OP_ANTILEVEL: stat = fscanf(pf, "%ld", &(Display.maxAAsubdiv)); if (stat != 1) { printf("View error: antialias level.\n"); exit(-1); } if (Display.maxAAsubdiv < 0 || Display.maxAAsubdiv > 3) { printf("error: antialias level %ld.\n", Display.maxAAsubdiv); exit(-1); } break; /* Recursion level. */ case OP_MAXLEVEL: stat = fscanf(pf, "%ld", &(Display.maxlevel)); printf("maxlevel of ray recursion = %ld\n",Display.maxlevel); fflush(stdout); if (stat != 1) { printf("error: recursion level.\n"); exit(-1); } if (Display.maxlevel > 5 || Display.maxlevel < 0) { printf("error: recursion level %ld.\n", Display.maxlevel); exit(-1); } break; /* Mininum ray weight. */ case OP_MINWEIGHT: stat = fscanf(pf, "%lf", &(Display.minweight)); if (stat != 1) { printf("error: miniumum ray weight.\n"); exit(-1); } if (Display.minweight < 0.0 || Display.minweight > 1.0) { printf("error: invalid ray weight %f.\n", Display.minweight); exit(-1); } break; /* Anti tolerance weight. */ case OP_ANTITOL: stat = fscanf(pf, "%lf", &(Display.aatolerance)); if (stat != 1) { printf("error: anti tolerance weight.\n"); exit(-1); } if (Display.aatolerance < 0.0 || Display.aatolerance > 1.0) { printf("error: invalid anti tolerance weight %f.\n", Display.aatolerance); exit(-1); } break; /* Resolution. */ case OP_RES: stat = fscanf(pf, "%ld %ld", &(Display.xres), &(Display.yres)); if (stat != 2) { printf("error: resolution.\n"); exit(-1); } break; /* Light positions and colors. */ case OP_LIGHT: lights_set = TRUE; if (nlights > 0) lptr = GlobalMalloc(sizeof(LIGHT), "env.c"); else lptr = lights; stat = fscanf(pf, "%lf %lf %lf %lf %lf %lf", &(lptr->pos[0]), &(lptr->pos[1]), &(lptr->pos[2]), &(lptr->col[0]), &(lptr->col[1]), &(lptr->col[2])); if (stat != 6) { printf("error: Lights.\n"); exit(-1); } if (!VerifyColorRange(lptr->col)) exit(-1); lptr->pos[3] = 1.0; stat = fscanf(pf, "%ld", &(lptr->shadow)); if (stat != 1) { printf("error: Lights shadow indicator.\n"); exit(-1); } lptr->next = NULL; if (nlights > 0) lastlight->next = lptr; nlights++; lastlight = lptr; break; /* Model transformation matrix. */ case OP_MODELMAT: for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { stat = fscanf(pf, "%lf", &(View.model[i][j])); if (stat != 1) { printf("Error in matrix.\n"); exit(-1); } } ModelTransform = TRUE; break; /* Shadow info. */ case OP_SHAD: stat = fscanf(pf, "%s", opparam); if (stat != 1) { printf("error: shadow.\n"); exit(-1); } if (strcmp(opparam, "on") == 0) View.shad = TRUE; else View.shad = FALSE; break; /* Shading info. */ case OP_SHADING: stat = fscanf(pf, "%s", opparam); if (stat != 1) { printf("error: shading %s.\n", opparam); exit(-1); } if (strcmp(opparam, "on") == 0) View.shading = TRUE; else View.shading = FALSE; break; /* Projection type. */ case OP_PROJECT: stat = fscanf(pf, "%s", opparam); if (stat != 1) { printf("error: projection %s.\n", opparam); exit(-1); } if (strcmp(opparam, "perspective") == 0) View.projection = PT_PERSP; else if (strcmp(opparam, "orthographic") == 0) View.projection = PT_ORTHO; else { printf("Invalid projection %s.\n", opparam); exit(-1); } break; /* Database traversal info. */ case OP_TRAVERSAL: stat = fscanf(pf, "%s", opparam); if (stat != 1) { printf("error: traversal %s.\n", opparam); exit(-1); } if (strcmp(opparam, "list") == 0) TraversalType = TT_LIST; else if (strcmp(opparam, "huniform") == 0) TraversalType = TT_HUG; else { printf("Invalid traversal code %s.\n", opparam); exit(-1); } break; /* Geometry file. */ case OP_GEOM_FILE: stat = fscanf(pf, " %s", GeoFileName); if (stat != 1) { printf("error: geometry file.\n"); exit(-1); } GeoFile = TRUE; break; /* Runlength file. */ case OP_RL_FILE: stat = fscanf(pf, " %s", PicFileName); if (stat != 1) { printf("error: runlength file.\n"); exit(-1); } PicFile = TRUE; break; case OP_PREVIEW_BKCULL: stat = fscanf(pf, "%ld", &dummy); if (stat != 1) { printf("error: Preview bkcull.\n"); exit(-1); } break; case OP_PREVIEW_FILL: stat = fscanf(pf, "%ld", &dummy); if (stat != 1) { printf("error: Preview fill.\n"); exit(-1); } break; case OP_PREVIEW_SPHTESS: stat = fscanf(pf, "%s", dummy_char); if (stat != 1) { printf("error: sphere tess.\n"); exit(-1); } break; case OP_NORM_DB: stat = fscanf(pf, "%s", opparam); if (stat != 1) { printf("error: norm database.\n"); exit(-1); } if (strcmp(opparam, "no") == 0) ModelNorm = FALSE; break; case OP_DATA_TYPE: stat = fscanf(pf, "%s", datafile); if (stat != 1) { printf("error: datatype.\n"); exit(-1); } if (strcmp(datafile, "binary") == 0) DataType = DT_BINARY; break; case OP_HU_MAX_PRIMS_CELL: stat = fscanf(pf, "%ld", &hu_max_prims_cell); if (stat != 1) { printf("error: Huniform prims per cell.\n"); exit(-1); } break; case OP_HU_GRIDSIZE: stat = fscanf(pf, "%ld", &hu_gridsize); if (stat != 1) { printf("error: Huniform gridsize.\n"); exit(-1); } break; case OP_HU_NUMBUCKETS: stat = fscanf(pf, "%ld", &hu_numbuckets); if (stat != 1) { printf("error: Huniform numbuckets.\n"); exit(-1); } break; case OP_HU_MAX_SUBDIV: stat = fscanf(pf, "%ld", &hu_max_subdiv_level); if (stat != 1 || hu_max_subdiv_level > 3) { printf("error: Huniform max subdiv level.\n"); exit(-1); } break; case OP_HU_LAZY: stat = fscanf(pf, "%ld", &hu_lazy); if (stat != 1) { printf("error: Huniform lazy.\n"); exit(-1); } break; case OP_BUNDLE: stat = fscanf(pf, "%ld %ld", &bundlex, &bundley); if (stat != 2 ) { printf("error: bundle.\n"); exit(-1); } break; case OP_BLOCK: stat = fscanf(pf, "%ld %ld", &blockx, &blocky); if (stat != 2 ) { printf("error: block.\n"); exit(-1); } break; default: printf("Warning: unrecognized env command: %s.\n", command); break; } } fclose(pf); /* Display parameters reset. */ Display.numpixels = Display.xres*Display.yres; Display.vWscale = Display.scrWidth/Display.xres; Display.vHscale = Display.scrHeight/Display.yres; /* If no light information given, set default. */ if (!lights_set) InitLights(); /* Set up screen parameters. */ InitDisplay(); /* Parameter check; think about lifting this restriction. */ if ((TraversalType != TT_LIST) && ModelNorm == FALSE) { printf("Data must be normalized with this traversal method!.\n"); ModelNorm = TRUE; } }
bool IPTVFeederRTP::Open(const QString &url) { LOG(VB_RECORD, LOG_INFO, LOC + QString("Open(%1) -- begin").arg(url)); QMutexLocker locker(&_lock); if (_source) { LOG(VB_RECORD, LOG_INFO, LOC + "Open() -- end 1"); return true; } QUrl parse(url); if (!parse.isValid() || parse.host().isEmpty() || (-1 == parse.port())) { LOG(VB_RECORD, LOG_INFO, LOC + "Open() -- end 2"); return false; } struct in_addr addr; QByteArray host = parse.host().toLatin1(); addr.s_addr = our_inet_addr(host.constData()); // Begin by setting up our usage environment: if (!InitEnv()) return false; ReceivingSocketAddr = our_inet_addr(parse.host().toLatin1()); Groupsock *socket = new Groupsock(*_live_env, addr, parse.port(), 0); if (!socket) { LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create Live RTP Socket."); FreeEnv(); return false; } _source = SimpleRTPSource::createNew(*_live_env, socket, 33, 90000, "video/MP2T", 0, False); if (!_source) { LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create Live RTP Source."); if (socket) delete socket; FreeEnv(); return false; } _sink = IPTVMediaSink::CreateNew(*_live_env, TSPacket::kSize * 128*1024); if (!_sink) { LOG(VB_GENERAL, LOG_ERR, QString("IPTV # Failed to create sink: %1") .arg(_live_env->getResultMsg())); Medium::close(_source); _source = NULL; if (socket) delete socket; FreeEnv(); return false; } _sink->startPlaying(*_source, NULL, NULL); vector<TSDataListener*>::iterator it = _listeners.begin(); for (; it != _listeners.end(); ++it) _sink->AddListener(*it); LOG(VB_RECORD, LOG_INFO, LOC + "Open() -- end"); return true; }
bool ProcRedirect(vector<pair<string,string> > &vt_param,string &errInfo) { WriteParam(redirect,vt_param,""); string userName = GetValue(USERNAME,vt_param); string url = GetValue(URL,vt_param); if(!ValidateParamEmpty(userName.c_str())) { errInfo.append("ftpName not valid."); WriteLog(redirect,ERROR,"ftpName invalid"); return false; } CVirtualHost *virtualHost; bool success = InitEnv(&virtualHost,userName,redirect); if(success) { if(url.empty()) { string tmp = ""; DeleteRedirect(tmp,virtualHost); } else { vector<string> vt_url; vector<string> vt_from; vector<string> vt_tmp; string to = ""; SplitByComas(url,vt_url,';'); int url_size = vt_url.size(); for(int i = 0; i < url_size; i++) { to = ""; vt_tmp.clear(); SplitByComas(vt_url[i],vt_tmp,':'); vt_from.clear(); SplitByComas(vt_tmp[0],vt_from); if(vt_tmp.size() > 1) to = vt_tmp[1]; int size = vt_from.size(); for(int k = 0; k < size; k++) { if(!to.empty()) AddRedirect(vt_from[k],to,virtualHost); else DeleteRedirect(vt_from[k],virtualHost); } } } } if(success) success = virtualHost->SaveFile(); if(success) WriteParam(redirect,vt_param,"success"); else { errInfo.append("failed to process your resuest."); WriteParam(redirect,vt_param,"failed. write the config file failed."); } CVirtualHost::ReleaseVirtualHost(userName); return success; }
/* files. Then calls query () to perform the querying. */ int main (int argc, char **argv) { ProgTime StartTime; int decomp = 0; int ch; msg_prefix = argv[0]; GetTime (&StartTime); /* Initialise the environment with default values */ InitEnv (); read_mgrc_file (); OutFile = stdout; InFile = stdin; opterr = 0; while ((ch = getopt (argc, argv, "Df:d:h")) != -1) switch (ch) { case 'f': SetEnv ("mgname", optarg, NULL); break; case 'd': SetEnv ("mgdir", optarg, NULL); break; case 'D': decomp = 1; break; case 'h': case '?': fprintf (stderr, "usage: %s [-D] [-f base name of collection]" "[-d data directory] [collection]\n", argv[0]); exit (1); } PushEnv (); if (decomp == 0) { Init_ReadLine (); /* write a first prompt, let the user start thinking */ if (!BooleanEnv (GetEnv ("expert"), 0) && isatty (fileno (InFile))) { fprintf (stderr, "\n\n\t FULL TEXT RETRIEVAL QUERY PROGRAM\n"); fprintf (stderr, "%24s%s\n\n", "", *"30 Jul 1999" == '%' ? __DATE__ : "30 Jul 1999"); fprintf (stderr, "\n"); fprintf (stderr, " mgquery version " VERSION ", Copyright (C) 1994 Neil Sharman\n"); fprintf (stderr, " mgquery comes with ABSOLUTELY NO WARRANTY; for details type `.warranty'\n"); fprintf (stderr, " This is free software, and you are welcome to redistribute it\n"); fprintf (stderr, " under certain conditions; type `.conditions' for details.\n"); fprintf (stderr, "\n"); } } if (optind < argc) search_for_collection (argv[optind]); if (decomp == 0) { query (); } else { int i; InitQueryTimes iqt; query_data *qd; qd = InitQuerySystem (GetDefEnv ("mgdir", "./"), GetDefEnv ("mgname", ""), &iqt); if (!qd) FatalError (1, mg_errorstrs[mg_errno], mg_error_data); start_up_stats (qd, iqt); Display_Stats (stderr); for (i = 0; i < qd->td->cth.num_of_docs; i++) { RawDocOutput (qd, i + 1, stdout); putc ('\2', stdout); } Message ("%s", ElapsedTime (&StartTime, NULL)); FinishQuerySystem (qd); } UninitEnv (); exit (0); }