这篇教程C++ strcasestr函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中strcasestr函数的典型用法代码示例。如果您正苦于以下问题:C++ strcasestr函数的具体用法?C++ strcasestr怎么用?C++ strcasestr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了strcasestr函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: main//.........这里部分代码省略......... //printf("method !%s! %i/n", method, method_len); // extract request-target from request-line int request_target_len = strlen(strchr(line, ' ')) - strlen(strrchr(line, ' ')) - 1; char request_target[request_target_len + 1]; for (int i = method_len + 1; i < method_len + request_target_len + 1; i++) { if (line[i] == ' ') { break; } request_target[i - method_len - 1] = line[i]; } request_target[request_target_len ] = '/0'; // extract absolute-path from request-target char absolute_path[100]; strcpy(absolute_path, request_target); int size = strlen(request_target); for (int i = 0; i < size ; i++) { if (request_target[i] == '?' || request_target[i] == ' ') { absolute_path[i] = '/0'; break; } absolute_path[i] = request_target[i]; } //printf("absolute_path !%s! /n", absolute_path); // request-line is consistent with these rules, // and respond to the browser with: if (strcasestr("GET", method) == NULL) { error(405); continue; } if (request_target[0] != '/') { error(501); continue; } if (strchr(request_target, '"') != NULL) { error(400); continue; } if (strcmp("HTTP/1.1", http_ver) != 0) { error(505); continue; } if (strchrnul(absolute_path, '.') == NULL) { error(501); continue; } // TODO: extract query from request-target //char query[] = "TODO";
开发者ID:FedorovIgor,项目名称:CS50x3-Introduction-to-Computer-Science-Harvard-edX,代码行数:67,
示例2: Unix_FindV6InterfaceInfovoid Unix_FindV6InterfaceInfo(void){ FILE *pp = NULL; char buffer[CF_BUFSIZE];/* Whatever the manuals might say, you cannot get IPV6 interface configuration from the ioctls. This seems to be implemented in a non standard way across OSes BSDi has done getifaddrs(), solaris 8 has a new ioctl, Stevens book shows the suggestion which has not been implemented...*/ CfOut(cf_verbose, "", "Trying to locate my IPv6 address/n"); switch (VSYSTEMHARDCLASS) { case cfnt: /* NT cannot do this */ return; case irix: case irix4: case irix64: if ((pp = cf_popen("/usr/etc/ifconfig -a", "r")) == NULL) { CfOut(cf_verbose, "", "Could not find interface info/n"); return; } break; case hp: if ((pp = cf_popen("/usr/sbin/ifconfig -a", "r")) == NULL) { CfOut(cf_verbose, "", "Could not find interface info/n"); return; } break; case aix: if ((pp = cf_popen("/etc/ifconfig -a", "r")) == NULL) { CfOut(cf_verbose, "", "Could not find interface info/n"); return; } break; default: if ((pp = cf_popen("/sbin/ifconfig -a", "r")) == NULL) { CfOut(cf_verbose, "", "Could not find interface info/n"); return; } }/* Don't know the output format of ifconfig on all these .. hope for the best*/ while (!feof(pp)) { fgets(buffer, CF_BUFSIZE - 1, pp); if (ferror(pp)) /* abortable */ { break; } if (strcasestr(buffer, "inet6")) { Item *ip, *list = NULL; char *sp; list = SplitStringAsItemList(buffer, ' '); for (ip = list; ip != NULL; ip = ip->next) { for (sp = ip->name; *sp != '/0'; sp++) { if (*sp == '/') /* Remove CIDR mask */ { *sp = '/0'; } } if (IsIPV6Address(ip->name) && (strcmp(ip->name, "::1") != 0)) { CfOut(cf_verbose, "", "Found IPv6 address %s/n", ip->name); AppendItem(&IPADDRESSES, ip->name, ""); NewClass(ip->name); } } DeleteItemList(list); }//.........这里部分代码省略.........
开发者ID:rdparker,项目名称:core,代码行数:101,
示例3: scan_src_file_cbstatic intscan_src_file_cb(const char *fpath,const struct stat *sb, int tflag,struct FTW *ftwbuf){ //record file to list src_f_list *n_file = NULL,*n_file_old = NULL; int fd = -1; char *index_str = NULL; switch(tflag) { case FTW_D: break; case FTW_F: n_file = (src_f_list *)malloc(sizeof(src_f_list)); bzero(n_file,sizeof(src_f_list)); n_file->node = NULL; n_file->f_p_len = strlen(fpath) + 1; n_file->f_path = (char *)malloc(n_file->f_p_len); bzero(n_file->f_path,n_file->f_p_len); memcpy(n_file->f_path,fpath,n_file->f_p_len - 1); n_file->req_count = 0; n_file->f_size = (intmax_t)(sb->st_size); if(max_file_size < n_file->f_size) max_file_size = n_file->f_size; n_file->f_data = (uint8_t *)malloc(n_file->f_size); bzero(n_file->f_data,n_file->f_size); if((fd = open(fpath,O_RDONLY,0)) < 0) { perror("open"); return -1; } read(fd,n_file->f_data,n_file->f_size); if(NULL == s_list) { s_list = n_file; regist_delete_call_back(s_list,s_list_free); regist_match_call_back(s_list,s_list_match); } else sl_node_insert_tail_absolute(s_list,n_file); //check the file if a index.html we ignore the case index_str = strcasestr(n_file->f_path,"/index.html"); #define INDEX_NAME_LEN 11 if(NULL != index_str && index_str[INDEX_NAME_LEN] == '/0') { n_file_old = n_file; n_file = (src_f_list *)malloc(sizeof(src_f_list)); bzero(n_file,sizeof(src_f_list)); n_file->node = NULL; n_file->f_p_len = n_file_old->f_p_len - INDEX_NAME_LEN; n_file->f_path = (char *)malloc(n_file->f_p_len); bzero(n_file->f_path,n_file->f_p_len); memcpy(n_file->f_path,n_file_old->f_path,n_file->f_p_len - 1); n_file->req_count = n_file_old->req_count; n_file->f_size = n_file_old->f_size; n_file->f_data = (uint8_t *)malloc(n_file->f_size); bzero(n_file->f_data,n_file->f_size); memcpy(n_file->f_data,n_file_old->f_data,n_file->f_size); sl_node_insert_tail_absolute(s_list,n_file); } #undef INDEX_NAME_LEN close(fd); break; case FTW_DNR: break; case FTW_NS: break; case FTW_SL: break; case FTW_SLN: break; default: break; } return 0;}
开发者ID:raiseking,项目名称:goku_studio,代码行数:72,
示例4: common_exec//.........这里部分代码省略......... ast_copy_string(dup_group, group, sizeof(dup_group)); num_groups = ast_app_separate_args(dup_group, ':', groups, ARRAY_LEN(groups)); } for (y = 0; y < num_mygroups; y++) { for (x = 0; x < num_groups; x++) { if (!strcmp(mygroups[y], groups[x])) { igrp = 1; break; } } } } if (!igrp) { continue; } if (myenforced) { char ext[AST_CHANNEL_NAME + 3]; char buffer[512]; char *end; snprintf(buffer, sizeof(buffer) - 1, ":%s:", myenforced); ast_copy_string(ext + 1, ast_channel_name(autochan->chan), sizeof(ext) - 1); if ((end = strchr(ext, '-'))) { *end++ = ':'; *end = '/0'; } ext[0] = ':'; if (strcasestr(buffer, ext)) { ienf = 1; } } if (!ienf) { continue; } if (!ast_test_flag(flags, OPTION_QUIET)) { char peer_name[AST_NAME_STRLEN + 5]; char *ptr, *s; strcpy(peer_name, "spy-"); strncat(peer_name, ast_channel_name(autochan->chan), AST_NAME_STRLEN - 4 - 1); if ((ptr = strchr(peer_name, '/'))) { *ptr++ = '/0'; for (s = peer_name; s < ptr; s++) { *s = tolower(*s); } if ((s = strchr(ptr, '-'))) { *s = '/0'; } } if (ast_test_flag(flags, OPTION_NAME)) { const char *local_context = S_OR(name_context, "default"); const char *local_mailbox = S_OR(mailbox, ptr); if (local_mailbox) { res = ast_app_sayname(chan, local_mailbox, local_context); } else { res = -1; }
开发者ID:xhook,项目名称:asterisk-v11,代码行数:67,
示例5: frame_trace_helperstatic int frame_trace_helper(struct ast_channel *chan, const char *cmd, char *data, const char *value){ struct frame_trace_data *framedata; struct ast_datastore *datastore = NULL; struct ast_framehook_interface interface = { .version = AST_FRAMEHOOK_INTERFACE_VERSION, .event_cb = hook_event_cb, .destroy_cb = hook_destroy_cb, }; int i = 0; if (!chan) { ast_log(LOG_WARNING, "No channel was provided to %s function./n", cmd); return -1; } if (!(framedata = ast_calloc(1, sizeof(*framedata)))) { return 0; } interface.data = framedata; if (!strcasecmp(data, "black")) { framedata->list_type = 1; } for (i = 0; i < ARRAY_LEN(frametype2str); i++) { if (strcasestr(value, frametype2str[i].str)) { framedata->values[i] = 1; } } ast_channel_lock(chan); i = ast_framehook_attach(chan, &interface); if (i >= 0) { int *id; if ((datastore = ast_channel_datastore_find(chan, &frame_trace_datastore, NULL))) { id = datastore->data; ast_framehook_detach(chan, *id); ast_channel_datastore_remove(chan, datastore); ast_datastore_free(datastore); } if (!(datastore = ast_datastore_alloc(&frame_trace_datastore, NULL))) { ast_framehook_detach(chan, i); ast_channel_unlock(chan); return 0; } if (!(id = ast_calloc(1, sizeof(int)))) { ast_datastore_free(datastore); ast_framehook_detach(chan, i); ast_channel_unlock(chan); return 0; } *id = i; /* Store off the id. The channel is still locked so it is safe to access this ptr. */ datastore->data = id; ast_channel_datastore_add(chan, datastore); } ast_channel_unlock(chan); return 0;}
开发者ID:litnimax,项目名称:asterisk,代码行数:63,
示例6: XimCreate//.........这里部分代码省略......... if (!imname) { imname = getenv("XMODIFIERS"); if (imname) { if (strstr(imname, "@im=")) imname += 4; else { FcitxLog(WARNING, _("XMODIFIERS Error.")); imname = DEFAULT_IMNAME; } } else { FcitxLog(WARNING, _("Please set XMODIFIERS.")); imname = DEFAULT_IMNAME; } } XimQueueInit(xim); if (GetXimConfigDesc() == NULL) xim->bUseOnTheSpotStyle = false; else { FcitxConfigFileDesc* configDesc = GetXimConfigDesc(); FILE *fp; char *file; fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-xim.config", "r", &file); FcitxLog(DEBUG, "Load Config File %s", file); free(file); if (!fp) { if (errno == ENOENT) { char *file; FILE *fp2 = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-xim.config", "w", &file); FcitxLog(DEBUG, "Save Config to %s", file); FcitxConfigSaveConfigFileFp(fp2, &xim->gconfig, configDesc); free(file); if (fp2) fclose(fp2); } } FcitxConfigFile *cfile = FcitxConfigParseConfigFileFp(fp, configDesc); FcitxXimFrontendConfigBind(xim, cfile, configDesc); FcitxConfigBindSync((FcitxGenericConfig*)xim); if (fp) fclose(fp); } input_styles = (XIMStyles *) malloc(sizeof(XIMStyles)); if (xim->bUseOnTheSpotStyle) { input_styles->count_styles = sizeof(OnTheSpot_Styles) / sizeof(XIMStyle) - 1; input_styles->supported_styles = OnTheSpot_Styles; } else { input_styles->count_styles = sizeof(OverTheSpot_Styles) / sizeof(XIMStyle) - 1; input_styles->supported_styles = OverTheSpot_Styles; } encodings = (XIMEncodings *) malloc(sizeof(XIMEncodings)); encodings->count_encodings = sizeof(zhEncodings) / sizeof(XIMEncoding) - 1; encodings->supported_encodings = zhEncodings; p = getenv("LC_CTYPE"); if (!p) { p = getenv("LC_ALL"); if (!p) p = getenv("LANG"); } if (p) { if (!strcasestr(strLocale, p)) { strcat(strLocale, ","); strcat(strLocale, p); } } xim->ims = IMOpenIM(xim->display, IMModifiers, "Xi18n", IMServerWindow, xim->ximWindow, IMServerName, imname, IMLocale, strLocale, IMServerTransport, "X/", IMInputStyles, input_styles, IMEncodingList, encodings, IMProtocolHandler, XimProtocolHandler, IMFilterEventMask, KeyPressMask | KeyReleaseMask, NULL); free(input_styles); free(encodings); if (xim->ims == (XIMS) NULL) { FcitxLog(ERROR, _("Start XIM error. Another XIM daemon named %s is running?"), imname); free(xim); FcitxInstanceEnd(instance); return NULL; } FcitxModuleAddFunction(ximaddon, XimConsumeQueue); return xim;}
开发者ID:areslp,项目名称:fcitx,代码行数:101,
示例7: mainint main (int argc, char** argv) { struct option cmd_options[] = {{"help", 0, NULL, CMD_HELP}, {"version", 0, NULL, CMD_VERSION}, {"jp4", 0, NULL, CMD_JP4}, {"jpeg", 0, NULL, CMD_JPEG}, {"dng", 0, NULL, CMD_DNG}, {"pgm", 0, NULL, CMD_PGM}, {"stdout", 0, NULL, CMD_STDOUT}, {"gui", 0, NULL, CMD_GUI}, {"frames", 1, NULL, CMD_N_FRAMES}, {"shift", 1, NULL, CMD_BAYER_SHIFT}, {"jpeg-quality", 1, NULL, CMD_JPEG_QUALITY}, {"no-dng-rotation", 0, NULL, CMD_DISABLE_DNG_ROTATION}, {0, 0, 0, 0}}; int option = 0; int option_index; bool save_jp4 = false; bool save_dng = false; bool save_pgm = false; bool save_jpeg = false; bool disable_dng_rotations = false; bool save_to_stdout = false; bool gui = false; long int n_frames = 0; int bayer_shift = -1; unsigned int jpeg_quality = 100; opterr = 0; while ((option = getopt_long(argc, argv, "hv", cmd_options, &option_index)) != -1) { switch (option) { case CMD_HELP: help(argv[0]); exit(0); case CMD_VERSION: version(argv[0]); exit(0); case CMD_JP4: save_jp4 = true; break; case CMD_JPEG: save_jpeg = true; break; case CMD_JPEG_QUALITY: jpeg_quality = atoi(optarg); if (jpeg_quality < 1 || jpeg_quality > 100) { fprintf(stderr, "Wrong JPEG quality factor, should be between 1 and 100./n"); exit(1); } break; case CMD_DISABLE_DNG_ROTATION: disable_dng_rotations = true; break; case CMD_DNG: save_dng = true; break; case CMD_PGM: save_pgm = true; break; case CMD_STDOUT: save_to_stdout = true; break; case CMD_GUI: gui = true; break; case CMD_N_FRAMES: n_frames = atoi(optarg); break; case CMD_BAYER_SHIFT: bayer_shift = atoi(optarg); if (bayer_shift < 0 || bayer_shift > 3) { fprintf(stderr, "Ivalid shift mode, shift=[0-3]/n"); exit(1); } break; default: printf("Unknown option./n/n"); help(argv[0]); exit(1); } } if (argc-optind < 1) { help(argv[0]); exit(1); } if (!save_dng && !save_jp4 && !save_pgm && !save_jpeg) { help(argv[0]); exit(1); } // Check if sourceFilename is a movie or a single frame char* sourceFilename = argv[optind]; const char* is_jp4 = strcasestr(sourceFilename, ".jp4");//.........这里部分代码省略.........
开发者ID:F0x06,项目名称:Movie2DNG,代码行数:101,
示例8: lhttpd_packet_handlerint lhttpd_packet_handler(CONN *conn, CB_DATA *packet){ char *s = NULL, *end = NULL, *p = NULL, path[HTTP_PATH_MAX], line[HTTP_LINE_MAX]; int high = 0, low = 0, keepalive = 0; struct stat st; if(conn) { if(packet && (s = packet->data) && packet->ndata > 0) { return conn->push_file(conn, "/tmp/x.txt", 0, 2272); end = s + packet->ndata; while(*s == 0x20 || *s == '/t')s++; if(s < end && strncasecmp(s, "get", 3) == 0) { s += 3; while(*s == 0x20 || *s == '/t')s++; if(*s != '/') goto err; p = path; p += sprintf(path, "%s", httpd_home); while(s < end && *s != 0x20 && *s != '/t' && *s != '?' && *s != '#' && p < (path + HTTP_PATH_MAX)) { URLDECODE(s, end, high, low, p); } *p = '/0'; if(s < end && strcasestr(s, "Keep-Alive"))keepalive = 1; if(stat(path, &st) != 0) goto not_found; if(S_ISDIR(st.st_mode)) { if(*(p-1) == '/') p += sprintf(p, "index.html"); else p += sprintf(p, "/index.html"); if(stat(path, &st) != 0) goto not_found; } if(S_ISREG(st.st_mode) && st.st_size > 0) { p = line; p += sprintf(p, "HTTP/1.0 200 OK/r/nContent-Length: %lld/r/n" "Last-Modified:", LL(st.st_size)); p += GMTstrdate(st.st_mtime, p);p += sprintf(p, "%s", "/r/n"); p += sprintf(p, "Date: ");p += GMTstrdate(time(NULL), p); p += sprintf(p, "/r/n"); if(keepalive) p += sprintf(p, "Connection: Keep-Alive/r/n"); else p += sprintf(p, "Connection: close/r/n"); p += sprintf(p, "Server: lhttpd/%s/r/n/r/n", LHTTPD_VERSION); conn->push_chunk(conn, line, (p - line)); conn->push_file(conn, path, 0, st.st_size); if(keepalive) conn->set_timeout(conn, HTTP_TIMEOUT); else conn->over(conn); return 0; } else { conn->push_chunk(conn, HTTP_FORBIDDEN, strlen(HTTP_FORBIDDEN)); return conn->over(conn); } } }err: conn->push_chunk(conn, HTTP_BAD_REQUEST, strlen(HTTP_BAD_REQUEST)); return conn->over(conn);not_found: conn->push_chunk(conn, HTTP_NOT_FOUND, strlen(HTTP_NOT_FOUND)); return conn->over(conn); } return -1;}
开发者ID:5bruce,项目名称:sbase,代码行数:73,
示例9: linktitlevoid linktitle (ircclient_t *cl, char *nick, char *host, char *source, char *message){ char *buf, *link, *ttag; CURL *c; if (source [0] != '#') return; // Do not reply to links through private message buf = alloca (strlen (message) + 1); strncpy (buf, message, strlen (message) + 1); // We don't want to mess up the original while (strstr (buf, "http://") || strstr (buf, "https://")) { // Allocate head and body buffers head.data = malloc (1); body.data = malloc (1); head.len = body.len = 0; if (!(link = strstr (buf, "http://"))) // see if we need https link = strstr (buf, "https://"); if (strstr (link, " ")) strstr (link, " ") [0] = '/0'; // terminate the string at the end of the link // Get HEAD of the http request c = curl_easy_init (); curl_easy_setopt (c, CURLOPT_URL, link); curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, writedata); curl_easy_setopt (c, CURLOPT_WRITEHEADER, (void*) &head); curl_easy_setopt (c, CURLOPT_WRITEDATA, (void*) &body); curl_easy_setopt (c, CURLOPT_NOBODY, 1); curl_easy_setopt (c, CURLOPT_TIMEOUT, 5); curl_easy_setopt (c, CURLOPT_FOLLOWLOCATION, 1); curl_easy_perform (c); if (!strstr (head.data, "Content-Type: text/html")) { curl_easy_cleanup (c); free (head.data); free (body.data); return; // According to the web server, this is not an HTML file } // Get the body of the http request curl_easy_setopt (c, CURLOPT_HTTPGET, 1); curl_easy_setopt (c, CURLOPT_WRITEHEADER, NULL); curl_easy_perform (c); curl_easy_cleanup (c); // Finally extract the title from the body, if possible ttag = strcasestr (body.data, "<title>"); if (ttag) { get_title (&link, &ttag); irc_privmsg (cl, source, "link title: %s (at %s)", ttag, link); } free (head.data); free (body.data); buf = strstr (link + strlen (link) + 1, "/0") + 1; } return;}
开发者ID:tm512,项目名称:ispolin,代码行数:66,
示例10: WinMainint PASCAL WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int nCmdShow){ ModelLoader* modelLoader; bool screenSaver = isScreenSaver(); int retValue; STARTUPINFO startupInfo; bool fromConsole = false; //HMODULE hThumbs = LoadLibrary("LDViewThumbs.dll"); //if (hThumbs != NULL) //{ // PFNDLLREGISTERSERVER pDllRegisterServer = // (PFNDLLREGISTERSERVER)GetProcAddress(hThumbs, "DllRegisterServer"); // CoInitialize(NULL); // if (pDllRegisterServer != NULL) // { // pDllRegisterServer(); // } //} memset(&startupInfo, 0, sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); GetStartupInfo(&startupInfo); if (startupInfo.lpTitle != NULL && stringHasCaseInsensitivePrefix(startupInfo.lpTitle, "command line ") && strcasestr(startupInfo.lpTitle, "ldview") != NULL) { runningWithConsole(); fromConsole = true; }#ifdef _DEBUG int _debugFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); _debugFlag |= _CRTDBG_LEAK_CHECK_DF; _CrtSetDbgFlag(_debugFlag); _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); if (!fromConsole) { createConsole(); }// MessageBox(NULL, "Attach a debugger now...", "Debug", MB_OK);#endif // _DEBUG bool udok = setupUserDefaults(lpCmdLine, screenSaver, isRemovableDrive(hInstance)); setupLocalStrings(); if (TCUserDefaults::boolForKey(DEBUG_COMMAND_LINE_KEY, false, false)) { std::string message = "Command Line:/n"; message += lpCmdLine; MessageBox(NULL, message.c_str(), "LDView", MB_OK); } if (!udok && !TCUserDefaults::longForKey("IniFailureShown", 0, 0)) { UCCHAR message[2048]; UCSTR iniPath = mbstoucstring(TCUserDefaults::getIniPath()); sucprintf(message, COUNT_OF(message), TCLocalStrings::get(_UC("IniFailure")), iniPath); CUIWindow::messageBoxUC(NULL, message, _UC("LDView"), MB_OK); delete iniPath; TCUserDefaults::setLongForKey(1, "IniFailureShown", false); } if (screenSaver) { if (strncasecmp(lpCmdLine, "/p", 2) == 0 || strncasecmp(lpCmdLine, "-p", 2) == 0 || strncasecmp(lpCmdLine, "p", 1) == 0) { // preview mode return doPreview(hInstance, lpCmdLine); } if (strncasecmp(lpCmdLine, "/c", 2) == 0 || strncasecmp(lpCmdLine, "-c", 2) == 0 || strncasecmp(lpCmdLine, "c", 1) == 0 || strlen(lpCmdLine) == 0) { SSConfigure *configure; configure = new SSConfigure(hInstance);#ifdef _DEBUG _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG); createConsole();#endif // _DEBUG configure->run(); // configure mode return 1; } // This shouldn't be necessary, but I've received a report of a whole // bunch of copies of the LDView screensaver running at once. This // might not fix things entirely, but it will at least prevent it // from launching multiple times concurrently. CreateMutex(NULL, FALSE, "LDView Screensaver"); if (GetLastError() == ERROR_ALREADY_EXISTS) { return 0; } }#ifdef _LOG_PERFORMANCE LARGE_INTEGER frequency;//.........这里部分代码省略.........
开发者ID:HazenBabcock,项目名称:LDView,代码行数:101,
示例11: searchstatic Booleansearch(char *const query){ const config_t *conf = config(); Boolean resp = True; results_not_found = True; if (query_len < conf->section_main->min_query_len) { return False; } if (query[0] == ' ') return False; GQueue *cache = get_cache(); int current_query_len = 1; str_array_t *query_parts = NULL; if (conf->section_main->allow_spaces) { query_parts = str_array_new(strdup(query), " "); if ( (query_len > 0 && query[query_len - 1] == ' ') || query_parts == NULL ) { resp = False; goto free_query_parts; } current_query_len = query_parts->length; } g_list_free(results); results = NULL; for (int i = 0; i < g_queue_get_length(cache); i++) { char *path = g_queue_peek_nth(cache, i); Boolean found = True; if (current_query_len == 1) { char *name = g_path_get_basename(path); if (strcasestr(name, query) != NULL) { results = g_list_prepend(results, path); } free(name); } else if (current_query_len > 1) { for (int i = 0; i < current_query_len; i++) { if (strcmp(query_parts->data[i], " ") == 0) continue; char *name = g_path_get_basename( path ); if (strstr(name, query_parts->data[i]) == NULL) { found = False; goto finish; } finish: free(name); if (! found) break; } if (found) results = g_list_prepend(results, path); } } results_not_found = (g_list_length(results) > 0 ? False : True); recent_apps_on_top();free_query_parts: str_array_free(query_parts); return resp;}
开发者ID:lchsk,项目名称:xstarter,代码行数:84,
示例12: Android_ParseFamily//.........这里部分代码省略......... free( psz_lc ); return VLC_ENOMEM; } } } if( vlc_dictionary_value_for_key( p_dict, psz_lc ) == kVLCDictionaryNotFound ) vlc_dictionary_insert( p_dict, psz_lc, p_family ); free( psz_lc ); } /* * If p_family has not been set by the time we encounter the first file, * it means this family has no name, and should be used only as a fallback. * We create a new family for it in the master list with the name "fallback-xx" * and later add it to the "default" fallback list. */ else if( !strcasecmp( "file", p_node ) ) { i_type = xml_ReaderNextNode( p_xml, &p_node ); if( i_type != XML_READER_TEXT || !p_node || !*p_node ) { ++i_counter; continue; } if( !p_family ) p_family = NewFamily( p_filter, NULL, &p_sys->p_families, &p_sys->family_map, NULL ); if( unlikely( !p_family ) ) return VLC_ENOMEM; switch( i_counter ) { case 0: b_bold = false; b_italic = false; break; case 1: b_bold = true; b_italic = false; break; case 2: b_bold = false; b_italic = true; break; case 3: b_bold = true; b_italic = true; break; default: msg_Warn( p_filter, "Android_ParseFamily: too many files" ); return VLC_EGENERIC; } char *psz_fontfile = NULL; if( asprintf( &psz_fontfile, "%s/%s", ANDROID_FONT_PATH, p_node ) < 0 || !NewFont( psz_fontfile, 0, b_bold, b_italic, p_family ) ) return VLC_ENOMEM; ++i_counter; } break; case XML_READER_ENDELEM: if( !strcasecmp( "family", p_node ) ) { if( !p_family ) { msg_Warn( p_filter, "Android_ParseFamily: empty family" ); return VLC_EGENERIC; } /* * If the family name has "fallback" in it, add it to the * "default" fallback list. */ if( strcasestr( p_family->psz_name, FB_NAME ) ) { vlc_family_t *p_fallback = NewFamily( p_filter, p_family->psz_name, NULL, &p_sys->fallback_map, FB_LIST_DEFAULT ); if( unlikely( !p_fallback ) ) return VLC_ENOMEM; p_fallback->p_fonts = p_family->p_fonts; } return VLC_SUCCESS; } break; } } msg_Warn( p_filter, "Android_ParseFamily: Corrupt font configuration file" ); return VLC_EGENERIC;}
开发者ID:0xheart0,项目名称:vlc,代码行数:101,
示例13: ro_gui_wimp_desktop_font/** * Looks up the current desktop font and converts that to a family name, * font size and style flags suitable for passing directly to rufl * * /param family buffer to receive font family * /param family_size buffer size * /param psize receives the font size in 1/16 points * /param pstyle receives the style settings to be passed to rufl */static voidro_gui_wimp_desktop_font(char *family, size_t family_size, int *psize, rufl_style *pstyle){ rufl_style style = rufl_WEIGHT_400; os_error *error; int ptx, pty; font_f font_handle; int used; assert(family); assert(20 < family_size); assert(psize); assert(pstyle); error = xwimpreadsysinfo_font(&font_handle, NULL); if (error) { LOG("xwimpreadsysinfo_font: 0x%x: %s", error->errnum, error->errmess); ro_warn_user("WimpError", error->errmess); goto failsafe; } if (font_handle == font_SYSTEM) { /* Er, yeah; like that's ever gonna work with RUfl */ goto failsafe; } error = xfont_read_identifier(font_handle, NULL, &used); if (error) { LOG("xfont_read_identifier: 0x%x: %s", error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); goto failsafe; } if (family_size < (size_t) used + 1) { LOG("desktop font name too long"); goto failsafe; } error = xfont_read_defn(font_handle, (byte *) family, &ptx, &pty, NULL, NULL, NULL, NULL); if (error) { LOG("xfont_read_defn: 0x%x: %s", error->errnum, error->errmess); ro_warn_user("MiscError", error->errmess); goto failsafe; } for (size_t i = 0; i != (size_t) used; i++) { if (family[i] < ' ') { family[i] = 0; break; } } LOG("desktop font /"%s/"", family); if (strcasestr(family, ".Medium")) style = rufl_WEIGHT_500; else if (strcasestr(family, ".Bold")) style = rufl_WEIGHT_700; if (strcasestr(family, ".Italic") || strcasestr(family, ".Oblique")) style |= rufl_SLANTED; char *dot = strchr(family, '.'); if (dot) *dot = 0; *psize = max(ptx, pty); *pstyle = style; LOG("family /"%s/", size %i, style %i", family, *psize, style); return;failsafe: strcpy(family, "Homerton"); *psize = 12*16; *pstyle = rufl_WEIGHT_400;}
开发者ID:arczi84,项目名称:NetSurf-68k,代码行数:90,
示例14: recherche_nom_rueint recherche_nom_rue(char contexte[20]) { int choix_ok = 0, nb_result = 0 , saisie_ok=0 ; int choix = NON_TROUVE, test_saisie_char = 0 ; char nom_rue[TAILLE_NOM_JONCTION] ; char *test, tab_result[NB_JONCTIONS][TAILLE_NOM_JONCTION] ; purge(); /*On vide le buffer avant de demander la saisie à l'utilisateur*/ while(nb_result == 0){ while (saisie_ok == 0){ saisie_ok=1; printf("/nEntrez le nom de la voie, sans son type (rue, avenue, boulevard, ...)/nExemple : pour la rue de la Roquette, tapez roquette /nNom du point %s : ", contexte); recup_saisie_user(nom_rue); if (nom_rue[0] == '/0'){ saisie_ok=0; printf ("Attention! Vous avez validé en n'ayant fait aucune saisie!/n"); } else{ verif_saisie_numerique(nom_rue, &saisie_ok); if (saisie_ok==0) printf("Votre saisie ne doit pas contenir de caractères de type numérique/n"); } } saisie_ok=0; /*on remet saisie_ok à 0 sinon on part en boucle infinie dans le cas où la recherche ne donne rien*/ conv_char_speciaux(nom_rue); for(int i = 0 ; i < nbjonction ; i++) // boucle de recherche du nom saisie dans liste des rues { test = strcasestr(tab_jonctions[i].nom, nom_rue) ; if(test != NULL) { nb_result++; printf("%-s/n", tab_jonctions[i].nom) ; strcpy(tab_result[i], tab_jonctions[i].nom) ; } } if(nb_result == 0) { //purge(); printf("Le nom que vous avez saisi ne correspond à aucune données en mémoire./nMerci de ressaisir le nom ou de choisir une autre rue./n/n"); } } printf("/nEntrez le numéro de jonction correspondant à votre point %s : ", contexte) ; while(!choix_ok) // boucle de vérification de la saisie { test_saisie_char = scanf("%d",&choix) ; if(test_saisie_char) { for(int i = 0 ; i < NB_JONCTIONS ; i++) { if (choix == atoi(tab_result[i]) && choix != 0) { choix_ok = 1 ; printf("Vous avez sélectionné : %s/n", tab_result[i]); // affichage du choix } } } else { purge(); } if (!choix_ok) { printf("Choix erroné. Merci de renseigner un numéro valide : "); //printf("%d/n", choix); } } return choix-1;}
开发者ID:MikeSquall,项目名称:projet_c,代码行数:69,
示例15: mainint main(int argc, char **argv) { printf("AiO Screengrabber "PACKAGE_VERSION"/n/n"); int xres_v,yres_v,xres_o,yres_o,xres,yres,aspect; int c,osd_only,video_only,use_osd_res,width,use_png,use_jpg,jpg_quality,no_aspect,use_letterbox; // we use fast resize as standard now resize = &fast_resize; osd_only=video_only=use_osd_res=width=use_png=use_jpg=no_aspect=use_letterbox=0; jpg_quality=50; aspect=1; int dst_left = 0, dst_top = 0, dst_width = 0, dst_height = 0; unsigned char *video, *osd, *output; int output_bytes=3; char filename[256]; sprintf(filename,"/tmp/screenshot.bmp"); // detect STB char buf[256]; FILE *pipe = fopen("/proc/fb","r"); if (!pipe) { printf("No framebuffer, unknown STB .. quit./n"); return 1; } while (fgets(buf,sizeof(buf),pipe)) { if (strcasestr(buf,"VULCAN")) stb_type=VULCAN; if (strcasestr(buf,"PALLAS")) stb_type=PALLAS; if (strcasestr(buf,"XILLEON")) stb_type=XILLEON; if (strcasestr(buf,"BCM7401") || strcasestr(buf,"BCMFB")) stb_type=BRCM7401; } pclose(pipe); if (stb_type == BRCM7401) // All Broadcom Dreamboxes use the same framebuffer string, so fall back to /proc/stb/info/model for detecting DM8000/DM500HD { pipe = fopen("/proc/stb/info/model", "r"); if (pipe) { while (fgets(buf,sizeof(buf),pipe)) { if (strcasestr(buf,"DM500HD")) { stb_type = BRCM7405; break; } } fclose(pipe); } if (stb_type == BRCM7401) { pipe = fopen("/proc/cpuinfo","r"); if (pipe) { while (fgets(buf, sizeof(buf), pipe)) { if (strcasestr(buf,"Brcm4380 V4.2")) { stb_type = BRCM7400; break; } else if (strcasestr(buf,"Brcm4380 V4.4")) { stb_type = BRCM7335; break; } } fclose(pipe); } } } if (stb_type == UNKNOWN) { printf("Unknown STB .. quit./n"); return 1; } else { printf("Detected STB: %s/n", stb_name[stb_type]); } // process command line while ((c = getopt (argc, argv, "dhj:lbnopr:v")) != -1) { switch (c) { case 'h': case '?': printf("Usage: grab [commands] [filename]/n/n"); printf("command:/n"); printf("-o only grab osd (framebuffer) when using this with png or bmp/n fileformat you will get a 32bit pic with alphachannel/n"); printf("-v only grab video/n"); printf("-d always use osd resolution (good for skinshots)/n"); printf("-n dont correct 16:9 aspect ratio/n");//.........这里部分代码省略.........
开发者ID:kakunbsc,项目名称:aio-grab,代码行数:101,
示例16: get_cpuinfoextern intget_cpuinfo(uint16_t *p_cpus, uint16_t *p_boards, uint16_t *p_sockets, uint16_t *p_cores, uint16_t *p_threads, uint16_t *p_block_map_size, uint16_t **p_block_map, uint16_t **p_block_map_inv){ enum { SOCKET=0, CORE=1, PU=2, LAST_OBJ=3 }; hwloc_topology_t topology; hwloc_obj_t obj; hwloc_obj_type_t objtype[LAST_OBJ]; unsigned idx[LAST_OBJ]; int nobj[LAST_OBJ]; int actual_cpus; int macid; int absid; int actual_boards = 1, depth; int i; debug2("hwloc_topology_init"); if (hwloc_topology_init(&topology)) { /* error in initialize hwloc library */ debug("hwloc_topology_init() failed."); return 1; } /* parse all system */ hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM); /* ignores cache, misc */ hwloc_topology_ignore_type (topology, HWLOC_OBJ_CACHE); hwloc_topology_ignore_type (topology, HWLOC_OBJ_MISC); /* load topology */ debug2("hwloc_topology_load"); if (hwloc_topology_load(topology)) { /* error in load hardware topology */ debug("hwloc_topology_load() failed."); hwloc_topology_destroy(topology); return 2; } /* Some processors (e.g. AMD Opteron 6000 series) contain multiple * NUMA nodes per socket. This is a configuration which does not map * into the hardware entities that Slurm optimizes resource allocation * for (PU/thread, core, socket, baseboard, node and network switch). * In order to optimize resource allocations on such hardware, Slurm * will consider each NUMA node within the socket as a separate socket. * You can disable this configuring "SchedulerParameters=Ignore_NUMA", * in which case Slurm will report the correct socket count on the node, * but not be able to optimize resource allocations on the NUMA nodes. */ objtype[SOCKET] = HWLOC_OBJ_SOCKET; objtype[CORE] = HWLOC_OBJ_CORE; objtype[PU] = HWLOC_OBJ_PU; if (hwloc_get_type_depth(topology, HWLOC_OBJ_NODE) > hwloc_get_type_depth(topology, HWLOC_OBJ_SOCKET)) { char *sched_params = slurm_get_sched_params(); if (sched_params && strcasestr(sched_params, "Ignore_NUMA")) { info("Ignoring NUMA nodes within a socket"); } else { info("Considering each NUMA node as a socket"); objtype[SOCKET] = HWLOC_OBJ_NODE; } xfree(sched_params); } /* number of objects */ depth = hwloc_get_type_depth(topology, HWLOC_OBJ_GROUP); if (depth != HWLOC_TYPE_DEPTH_UNKNOWN) { actual_boards = MAX(hwloc_get_nbobjs_by_depth(topology, depth), 1); } nobj[SOCKET] = hwloc_get_nbobjs_by_type(topology, objtype[SOCKET]); nobj[CORE] = hwloc_get_nbobjs_by_type(topology, objtype[CORE]); /* * Workaround for hwloc * hwloc_get_nbobjs_by_type() returns 0 on some architectures. */ if ( nobj[SOCKET] == 0 ) { debug("get_cpuinfo() fudging nobj[SOCKET] from 0 to 1"); nobj[SOCKET] = 1; } if ( nobj[CORE] == 0 ) { debug("get_cpuinfo() fudging nobj[CORE] from 0 to 1"); nobj[CORE] = 1; } if ( nobj[SOCKET] == -1 ) fatal("get_cpuinfo() can not handle nobj[SOCKET] = -1"); if ( nobj[CORE] == -1 ) fatal("get_cpuinfo() can not handle nobj[CORE] = -1"); actual_cpus = hwloc_get_nbobjs_by_type(topology, objtype[PU]);#if 0 /* Used to find workaround above */ info("CORE = %d SOCKET = %d actual_cpus = %d nobj[CORE] = %d", CORE, SOCKET, actual_cpus, nobj[CORE]);#endif nobj[PU] = actual_cpus/nobj[CORE]; /* threads per core */ nobj[CORE] /= nobj[SOCKET]; /* cores per socket *///.........这里部分代码省略.........
开发者ID:FredHutch,项目名称:slurm,代码行数:101,
示例17: curl_easy_initchar *get_url_title(const char *url) { CURL *curl; CURLcode code; struct mem_buffer mem = {NULL, 0}; char *temp, *url_title = NULL; bool iso = false; curl = curl_easy_init(); if (!curl) goto cleanup; curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 3L); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_memory); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &mem); code = curl_easy_perform(curl); if (code != CURLE_OK) { fprintf(stderr, "Error: %s/n", curl_easy_strerror(code)); goto cleanup; } if (!mem.buffer) { fprintf(stderr, "Error: Body was empty"); goto cleanup; } // Search http response in order to determine text encoding temp = strcasestr(mem.buffer, "iso-8859-7"); if (temp) // strlen("charset") = 7 if (starts_case_with(temp - 8, "charset") || starts_case_with(temp - 7, "charset")) iso = true; temp = strcasestr(mem.buffer, "<title"); if (!temp) goto cleanup; url_title = temp + 7; // Point url_title to the first title character temp = strcasestr(url_title, "</title"); if (!temp) { url_title = NULL; goto cleanup; } *temp = '/0'; // Terminate title string // Replace newline characters with spaces for (temp = url_title; *temp != '/0'; temp++) if (*temp == '/n') *temp = ' '; // If title string uses ISO 8859-7 encoding then convert it to UTF-8 // Return value must be freed to avoid memory leak if (iso) url_title = iso8859_7_to_utf8(url_title); else url_title = strndup(url_title, TITLELEN);cleanup: free(mem.buffer); curl_easy_cleanup(curl); return url_title;}
开发者ID:foss-teiwest,项目名称:irc-bot,代码行数:64,
示例18: connection_complete_source/* Called when activating a source. Verifies that the source count is not * exceeded and applies any initial parameters. */int connection_complete_source (source_t *source, int response){ ice_config_t *config; global_lock (); DEBUG1 ("sources count is %d", global.sources); config = config_get_config(); if (global.sources < config->source_limit) { const char *contenttype; const char *expectcontinue; mount_proxy *mountinfo; format_type_t format_type; /* setup format handler */ contenttype = httpp_getvar (source->parser, "content-type"); if (contenttype != NULL) { format_type = format_get_type (contenttype); if (format_type == FORMAT_ERROR) { config_release_config(); global_unlock(); if (response) { client_send_403 (source->client, "Content-type not supported"); source->client = NULL; } WARN1("Content-type /"%s/" not supported, dropping source", contenttype); return -1; } } else { WARN0("No content-type header, falling back to backwards compatibility mode " "for icecast 1.x relays. Assuming content is mp3."); format_type = FORMAT_TYPE_GENERIC; } if (format_get_plugin (format_type, source) < 0) { global_unlock(); config_release_config(); if (response) { client_send_403 (source->client, "internal format allocation problem"); source->client = NULL; } WARN1 ("plugin format failed for /"%s/"", source->mount); return -1; } /* For PUT support we check for 100-continue and send back a 100 to stay in spec */ expectcontinue = httpp_getvar (source->parser, "expect"); if (expectcontinue != NULL) {#ifdef HAVE_STRCASESTR if (strcasestr (expectcontinue, "100-continue") != NULL)#else WARN0("OS doesn't support case insenestive substring checks..."); if (strstr (expectcontinue, "100-continue") != NULL)#endif { client_send_100 (source->client); } } global.sources++; stats_event_args (NULL, "sources", "%d", global.sources); global_unlock(); source->running = 1; mountinfo = config_find_mount (config, source->mount, MOUNT_TYPE_NORMAL); source_update_settings (config, source, mountinfo); config_release_config(); slave_rebuild_mounts(); source->shutdown_rwlock = &_source_shutdown_rwlock; DEBUG0 ("source is ready to start"); return 0; } WARN1("Request to add source when maximum source limit " "reached %d", global.sources); global_unlock(); config_release_config(); if (response) { client_send_403 (source->client, "too many sources connected"); source->client = NULL; } return -1;//.........这里部分代码省略.........
开发者ID:miksago,项目名称:icecast,代码行数:101,
示例19: SUMA_WindowsOnRootDisplay/*! A toy function to identify windows on the root window. This function can potentially be used to identify where AFNI windows, for example, are taking screen space and have SUMA avoid overlapping with them. The function needs much work. It is not terribly selective about what it chases down. See command line xwininfo -tree -root for full listing from command line, or xwininfo for interactive queries. For now, we let this rest.*/int SUMA_WindowsOnRootDisplay(Display *dd, Window ww, int all){ static char FuncName[]={"SUMA_WindowsOnRootDisplay"}; Window rr, pr, *cr, jj; XWindowAttributes wa; unsigned int ncr, wr, hr, bwr, bhr; int ii, xr, yr, showgeom=0; char *wname=NULL, *sout=NULL; /* tell me what windows are displayed and where */ if (XQueryTree(dd, ww, &rr, &pr, &cr, &ncr)) { if (all) fprintf(stderr,"Have %d childern in query/n", ncr); for (ii=0; ii<ncr; ++ii) { showgeom = 0; XGetWindowAttributes(dd, cr[ii], &wa); XTranslateCoordinates (dd, cr[ii], wa.root, -wa.border_width, -wa.border_width, &xr, &yr, &jj); if (XFetchName(dd, cr[ii], &wname)) { /* XGetWMName usage From source of xwininfo.c, Not getting advantage over XFetchName for lots more hassle ....*/ if (wname) { sout = SUMA_copy_string(wname); XFree(wname); } else sout = SUMA_copy_string("no name but fetch OK!"); if (strcasestr(sout,"afni") || strcasestr(sout,"suma") ) { fprintf(stderr," brethren %d: %s/n", ii, sout); showgeom=1; } else { if (all) { fprintf(stderr," furner %d: %s/n", ii, sout); showgeom=1; } } } else { if (all) { fprintf(stderr," %d: (No name!)/n", ii); showgeom = 1; } } if (showgeom) { fprintf(stderr, " abs Upper Left X Y %d %d, (rel UL %d %d) W H%d %d, /n", xr, yr, wa.x, wa.y, wa.width, wa.height); /* Under alternative below, xr and yr are relative UL vals */ #if 0 if (XGetGeometry(dd, cr[ii], &rr, &xr, &yr, &wr, &hr, &bwr, &bhr)) { fprintf(stderr," %d %d, %dx%d, %d %d/n", xr, yr, wr, hr, bwr, bhr); } #endif } if (sout) SUMA_free(sout); sout = NULL; SUMA_WindowsOnRootDisplay(dd, cr[ii],all); } }}
开发者ID:pmolfese,项目名称:afni,代码行数:78,
示例20: xstrdup//.........这里部分代码省略......... } else path = end; if (!path || !*path) die("No path specified. See 'man git-pull' for valid url syntax"); /* * null-terminate hostname and point path to ~ for URL's like this: * ssh://host.xz/~user/repo */ if (protocol != PROTO_LOCAL && host != url) { char *ptr = path; if (path[1] == '~') path++; else { path = xstrdup(ptr); free_path = 1; } *ptr = '/0'; } /* * Add support for ssh port: ssh://host.xy:<port>/... */ if (protocol == PROTO_SSH && host != url) port = get_port(host); if (protocol == PROTO_GIT) { /* These underlying connection commands die() if they * cannot connect. */ char *target_host = xstrdup(host); if (git_use_proxy(host)) git_proxy_connect(fd, host); else git_tcp_connect(fd, host, flags); /* * Separate original protocol components prog and path * from extended host header with a NUL byte. * * Note: Do not add any other headers here! Doing so * will cause older git-daemon servers to crash. */ packet_write(fd[1], "%s %s%chost=%s%c", prog, path, 0, target_host, 0); free(target_host); free(url); if (free_path) free(path); return &no_fork; } conn = xcalloc(1, sizeof(*conn)); strbuf_init(&cmd, MAX_CMD_LEN); strbuf_addstr(&cmd, prog); strbuf_addch(&cmd, ' '); sq_quote_buf(&cmd, path); if (cmd.len >= MAX_CMD_LEN) die("command line too long"); conn->in = conn->out = -1; conn->argv = arg = xcalloc(7, sizeof(*arg)); if (protocol == PROTO_SSH) { const char *ssh = getenv("GIT_SSH"); int putty = ssh && strcasestr(ssh, "plink"); if (!ssh) ssh = "ssh"; *arg++ = ssh; if (putty && !strcasestr(ssh, "tortoiseplink")) *arg++ = "-batch"; if (port) { /* P is for PuTTY, p is for OpenSSH */ *arg++ = putty ? "-P" : "-p"; *arg++ = port; } *arg++ = host; } else { /* remove repo-local variables from the environment */ conn->env = local_repo_env; conn->use_shell = 1; } *arg++ = cmd.buf; *arg = NULL; if (start_command(conn)) die("unable to fork"); fd[0] = conn->out; /* read from child's stdout */ fd[1] = conn->in; /* write to child's stdin */ strbuf_release(&cmd); free(url); if (free_path) free(path); return conn;}
开发者ID:rosdabos55,项目名称:sample_app,代码行数:101,
示例21: _find_stringstatic char const * _find_string(char const * big, char const * little, gboolean sensitive){ return sensitive ? strstr(big, little) : strcasestr(big, little);}
开发者ID:DeforaOS,项目名称:Surfer,代码行数:5,
示例22: GetNextURL/* * GetNextURL - get the next url from html[pos] into result * * Assumptions: * 1. html and base_url are allocated and valid * 2. pos = 0 on initial call * 3. result is NULL and will be allocated internally * * Pseudocode: * 1. check arguments * 2. if pos = 0: remove whitespace from html * 3. find hyperlink starting tags "<a" or "<A" * 4. find next href attribute "href=" * 5. find next end tag ">" * 6. check that href comes before end tag * 7. deal with quoted and unquoted urls * 8. determine if url is absolute * 9. fixup relative links * 10. create new character buffer for result and return it */int GetNextURL(char *html, int pos, char *base_url, char **result){ int bad_link; // is this link ill formatted? int relative; // is this link relative? char delim; // url delimiter: ' ', ''', '"' char *lnk; // hyperlink tags char *href; // href in a tag char *end; // end of hyperlink tag or url char *ptr; // absolute vs. relative char *hash; // hash mark character // make sure we have text and base url if (!html || !base_url) return -1; // condense html, makes parsing easier if (pos == 0) RemoveWhitespace(html); // parse for hyperlinks do { relative = 0; // assume absolute link bad_link = 0; // assume valid link // find tag "<a" or "<A"" lnk = strcasestr(&html[pos], "<a"); // no more links on this page if (!lnk) { result = NULL; return -1; } // find next href after hyperlink tag href = strcasestr(lnk, "href="); // no more links on this page if (!href) { result = NULL; return -1; } // find end of hyperlink tag end = strchr(lnk, '>'); // if the href we have is outside the current tag, continue if (end && (end < href)) { bad_link = 1; pos+=2; continue; } // move href to beginning of url href+=5; // something went wrong, just continue if (!href) { bad_link=1; pos+=2; continue; } // is the url quoted? if (*href == '/'' || *href == '"') { // yes, href="url" or href='url' delim = *(href++); // remember delimiter end = strchr(href, delim); // find next of same delimiter } else { // no, href=url end = strchr(href, '>'); // hope: <a ... href=url> // since we've stripped whitespace // this could mangle things like: // <a ... href=url name=val> } // if there is a # before the end of the url, exclude the #fragment hash = strchr(href, '#'); if (hash && hash < end) { end = hash; } // if we don't know where to end the url, continue if (!end) { bad_link = 1; pos += 2; continue; } // have a link now if (*href == '#') { // internal reference bad_link = 1; pos += 2; continue; } // is the url absolute, i.e, ':' must precede any '/', '?', or '#' ptr = strpbrk(href, ":/?#");//.........这里部分代码省略.........
开发者ID:WolfCoder22,项目名称:C-and-BASH,代码行数:101,
示例23: malloccl_int GLCLDraw::InitContext(int platformnum, int processornum, int GLinterop){ cl_int ret; size_t len; char extension_data[1024]; size_t llen; size_t extension_len; int i; properties = malloc(16 * sizeof(intptr_t)); ret = clGetPlatformIDs(8, platform_id, &ret_num_platforms); if(ret != CL_SUCCESS) return ret; if(ret_num_platforms <= 0) return CL_INVALID_PLATFORM; platform_num = platformnum; if(platform_num >= ret_num_platforms) platform_num = ret_num_platforms - 1; if(platform_num <= 0) platform_num = 0; ret = clGetDeviceIDs(platform_id[platform_num], CL_DEVICE_TYPE_ALL, 8, device_id, &ret_num_devices); if(ret != CL_SUCCESS) return ret; if(ret_num_devices <= 0) { XM7_DebugLog(XM7_LOG_DEBUG, "CL : Has no useful device(s)."); return ret; } if(ret_num_devices > 8) ret_num_devices = 8; if(ret_num_devices <= 0) return CL_INVALID_DEVICE_TYPE; XM7_DebugLog(XM7_LOG_DEBUG, "CL : Found %d processors.", ret_num_devices); using_device = processornum; if(using_device >= ret_num_devices) using_device = ret_num_devices - 1; if(using_device <= 0) using_device = 0; bCLEnableKhrGLShare = 0; for(i = 0; i < ret_num_devices; i++ ){ extension_data[0] = '/0'; GetDeviceName(extension_data, sizeof(extension_data), i); XM7_DebugLog(XM7_LOG_DEBUG, "CL : Processor #%d : Name = %s ", i, extension_data); extension_data[0] = '/0'; clGetDeviceInfo(device_id[i], CL_DEVICE_TYPE, sizeof(cl_ulong), &(device_type[i]), &llen); clGetDeviceInfo(device_id[i], CL_DEVICE_LOCAL_MEM_SIZE, sizeof(cl_ulong), &(local_memsize[i]), &llen); GetDeviceType(extension_data, sizeof(extension_data), i); XM7_DebugLog(XM7_LOG_DEBUG, "CL : Processor #%d : TYPE = %s / Local memory size = %d bytes", i, extension_data, local_memsize[i]); extension_data[0] = '/0'; clGetDeviceInfo(device_id[i], CL_DEVICE_EXTENSIONS, 1024, extension_data, &extension_len); XM7_DebugLog(XM7_LOG_DEBUG, "CL : Extension features(#%d):%s", i, extension_data); if(i == using_device) { if(strcasestr(extension_data, "cl_khr_gl_sharing") != NULL) { if(GLinterop != 0) bCLEnableKhrGLShare = -1; } else { bCLEnableKhrGLShare = 0; } } } XM7_DebugLog(XM7_LOG_DEBUG, "CL : Using device #%d", using_device); if(bCLEnableKhrGLShare != 0) { // This is only under X11. Must fix. XM7_DebugLog(XM7_LOG_DEBUG, "CL : GL Interoperability enabled."); properties[0] = CL_GL_CONTEXT_KHR; properties[1] = (cl_context_properties)glXGetCurrentContext(); XM7_DebugLog(XM7_LOG_DEBUG, "CL : GL Context = %08x", glXGetCurrentContext()); properties[2] = CL_GLX_DISPLAY_KHR; properties[3] = (cl_context_properties)glXGetCurrentDisplay(); XM7_DebugLog(XM7_LOG_DEBUG, "CL : GL Display = %08x", glXGetCurrentDisplay()); properties[4] = CL_CONTEXT_PLATFORM; properties[5] = (cl_context_properties)platform_id[platform_num]; properties[6] = 0; } else { XM7_DebugLog(XM7_LOG_DEBUG, "CL : GL Interoperability disabled."); properties[0] = CL_CONTEXT_PLATFORM; properties[1] = (cl_context_properties)platform_id[platform_num]; properties[2] = 0; }// if(device_id == NULL) return -1; context = clCreateContext(properties, 1, &device_id[using_device], cl_notify_log, NULL, &ret); XM7_DebugLog(XM7_LOG_DEBUG, "CL : Created context : STS = %d", ret); if(ret != CL_SUCCESS) return ret; command_queue = clCreateCommandQueue(context, device_id[using_device], CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &ret); XM7_DebugLog(XM7_LOG_DEBUG, "CL: Created command queue."); return ret;}
开发者ID:Artanejp,项目名称:XM7-for-SDL,代码行数:91,
示例24: guess_from_received_headerstatic const char *guess_from_received_header (notmuch_config_t *config, notmuch_message_t *message){ const char *received,*primary,*by; const char **other; char *tohdr; char *mta,*ptr,*token; char *domain=NULL; char *tld=NULL; const char *delim=". /t"; size_t i,j,other_len; const char *to_headers[] = {"Envelope-to", "X-Original-To"}; primary = notmuch_config_get_user_primary_email (config); other = notmuch_config_get_user_other_email (config, &other_len); /* sadly, there is no standard way to find out to which email * address a mail was delivered - what is in the headers depends * on the MTAs used along the way. So we are trying a number of * heuristics which hopefully will answer this question. * We only got here if none of the users email addresses are in * the To: or Cc: header. From here we try the following in order: * 1) check for an Envelope-to: header * 2) check for an X-Original-To: header * 3) check for a (for <[email C++ strcatW函数代码示例 C++ strcaseeq函数代码示例
|