void wcs_free(wcs_t wcs) { struct wcamsrv *ws = wcs; wcs_srv_free(ws); #if defined(VID_FUNC) vid_free(ws->vid); #endif pool_free(ws->pool); app_free(ws->app); cfg_free(ws->cfg); free(ws); }
wcs_t wcs_create(char *cfg_path) { struct wcamsrv *ws = calloc(1, sizeof(struct wcamsrv)); if (!ws) { perror("wcs_create"); return NULL; } ws->cfg = cfg_create(cfg_path); if (ws->cfg == NULL) goto err_mem; ws->app = app_create(cfg_get_max_app_event(ws->cfg)); if (ws->app == NULL) goto err_cfg; ws->pool = pool_create(cfg_get_thread_in_pool(ws->cfg)); if (ws->pool == NULL) goto err_app; #if defined(VID_FUNC) ws->vid = vid_create(ws); if (ws->vid == NULL) goto err_pool; #endif if (wcs_srv_init(ws) == -1) goto err_cam; return ws; err_cam: #if defined(VID_FUNC) vid_free(ws->vid); #endif err_pool: pool_free(ws->pool); err_app: app_free(ws->app); err_cfg: cfg_free(ws->cfg); err_mem: free(ws); return NULL; }
int main(int argc, char * const*argv) { List *files = list_create(LIST_SINGLE); char *fn; unsigned char *key; FILE*keysf; const char *keysname, *fldsname; int i,top; f_log = stderr; options(argc,argv,"2c:p:s"); if (!curr_project) usage(); setlocale(LC_ALL,LOCALE); if (l2) vidp = vid_load_data(se_file(curr_project,"cat","vid.dat")); estp = est_init(curr_project, "cat"); dp = dbi_create("cat", se_dir(curr_project,"cat"), 500000, sizeof(struct location8),DBI_ACCRETE); dbi_set_cache(dp,cache_size); dbi_set_user(dp,d_cat); progress("secatx: creating index %s\n",dp->dir); pqidsf = xfopen(se_file(curr_project,"cat","pqids.lst"),"w"); fldsname = strdup(se_file(curr_project,"cat","fieldnames.tab")); fldsf = xfopen(fldsname,"w"); for (i = 0,top=(sizeof(static_names)/sizeof(const char *))-3; i < top; ++i) { struct sn_tab *s = statnames(static_names[i],strlen(static_names[i])); fprintf(fldsf,"%s\t%d\n",static_names[i],s->uid); } if (one_big_stdin) { runexpat(i_stdin, NULL, startElement, endElement); } else { while (NULL != (fn = fgets(fnbuf,_MAX_PATH,stdin))) { fn[strlen(fn)-1] = '\0'; list_add(files,strdup(fn)); } fnlist = malloc(1+files->count * sizeof(const char *)); findex = 0; list_exec(files,fn_expand); runexpat(i_list, fnlist, startElement, endElement); } dbi_flush(dp); dbi_free(dp); est_dump(estp); est_term(estp); if (l2) { vid_free(vidp); vidp = NULL; } progress("secatx: completed db creation\n"); dp = dbi_open("cat",se_dir(curr_project,"cat")); if (dp && dp->h.entry_count > 0) { keysname = strdup(se_file(curr_project,"cat","key.lst")); keysf = xfopen(keysname,"w"); while (NULL != (key = dbi_each (dp))) #if 1 fprintf(keysf,"%s\n",key); #else fprintf(keysf,"%lu\t%s\n",(unsigned long)dp->nfound,key); #endif xfclose(keysname,keysf); } else { fprintf(stderr,"secatx: no keys in input\n"); } dbi_close(dp); xfclose(fldsname,fldsf); ce_cfg(curr_project, "cat", "catalog", "xmd", ce_xmd, NULL); return 0; }