这篇教程C++ util_err函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中util_err函数的典型用法代码示例。如果您正苦于以下问题:C++ util_err函数的具体用法?C++ util_err怎么用?C++ util_err使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了util_err函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: util_str2recno/* * util_str2recno -- * Convert a string to a record number. */intutil_str2recno(WT_SESSION *session, const char *p, uint64_t *recnop){ uint64_t recno; char *endptr; /* * strtouq takes lots of things like hex values, signs and so on and so * forth -- none of them are OK with us. Check the string starts with * digit, that turns off the special processing. */ if (!isdigit(p[0])) goto format; errno = 0; recno = __wt_strtouq(p, &endptr, 0); if (recno == ULLONG_MAX && errno == ERANGE) return ( util_err(session, ERANGE, "%s: invalid record number", p)); if (endptr[0] != '/0')format: return ( util_err(session, EINVAL, "%s: invalid record number", p)); *recnop = recno; return (0);}
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:31,
示例2: dump_record/* * dump_record -- * Dump a single record, advance cursor to next/prev, along * with JSON formatting if needed. */static intdump_record(WT_CURSOR *cursor, const char *name, int reverse, int json){ WT_DECL_RET; const char *infix, *key, *prefix, *suffix, *value; int once; once = 0; if (json) { prefix = "/n{/n"; infix = ",/n"; suffix = "/n}"; } else { prefix = ""; infix = "/n"; suffix = "/n"; } while ((ret = (reverse ? cursor->prev(cursor) : cursor->next(cursor))) == 0) { if ((ret = cursor->get_key(cursor, &key)) != 0) return (util_cerr(name, "get_key", ret)); if ((ret = cursor->get_value(cursor, &value)) != 0) return (util_cerr(name, "get_value", ret)); if (printf("%s%s%s%s%s%s", (json && once) ? "," : "", prefix, key, infix, value, suffix) < 0) return (util_err(EIO, NULL)); once = 1; } if (json && once && printf("/n") < 0) return (util_err(EIO, NULL)); return (ret == WT_NOTFOUND ? 0 : util_cerr(name, (reverse ? "prev" : "next"), ret));}
开发者ID:deepinit-arek,项目名称:wiredtiger,代码行数:38,
示例3: util_loadintutil_load(WT_SESSION *session, int argc, char *argv[]){ int ch; const char *filename; uint32_t flags; flags = 0; filename = "<stdin>"; while ((ch = __wt_getopt(progname, argc, argv, "af:jnr:")) != EOF) switch (ch) { case 'a': /* append (ignore record number keys) */ append = 1; break; case 'f': /* input file */ if (freopen(__wt_optarg, "r", stdin) == NULL) return ( util_err(errno, "%s: reopen", __wt_optarg)); else filename = __wt_optarg; break; case 'j': /* input is JSON */ json = 1; break; case 'n': /* don't overwrite existing data */ no_overwrite = 1; break; case 'r': /* rename */ cmdname = __wt_optarg; break; case '?': default: return (usage()); } argc -= __wt_optind; argv += __wt_optind; /* -a and -o are mutually exclusive. */ if (append == 1 && no_overwrite == 1) return (util_err(EINVAL, "the -a (append) and -n (no-overwrite) flags are mutually " "exclusive")); /* The remaining arguments are configuration uri/string pairs. */ if (argc != 0) { if (argc % 2 != 0) return (usage()); cmdconfig = argv; } if (json) { if (append) flags |= LOAD_JSON_APPEND; if (no_overwrite) flags |= LOAD_JSON_NO_OVERWRITE; return (util_load_json(session, filename, flags)); } else return (load_dump(session));}
开发者ID:deepinit-arek,项目名称:wiredtiger,代码行数:60,
示例4: list_get_allocsize/* * list_get_allocsize -- * Get the allocation size for this file from the metadata. */static intlist_get_allocsize(WT_SESSION *session, const char *key, size_t *allocsize){ WT_CONFIG_ITEM szvalue; WT_CONFIG_PARSER *parser; WT_DECL_RET; WT_EXTENSION_API *wt_api; int tret; char *config; wt_api = session->connection->get_extension_api(session->connection); if ((ret = wt_api->metadata_search(wt_api, session, key, &config)) != 0) return (util_err( session, ret, "%s: WT_EXTENSION_API.metadata_search", key)); if ((ret = wt_api->config_parser_open(wt_api, session, config, strlen(config), &parser)) != 0) return (util_err( session, ret, "WT_EXTENSION_API.config_parser_open")); if ((ret = parser->get(parser, "allocation_size", &szvalue)) != 0) { if (ret == WT_NOTFOUND) { *allocsize = 0; ret = 0; } else ret = util_err(session, ret, "WT_CONFIG_PARSER.get"); if ((tret = parser->close(parser)) != 0) (void)util_err(session, tret, "WT_CONFIG_PARSER.close"); return (ret); } if ((ret = parser->close(parser)) != 0) return (util_err(session, ret, "WT_CONFIG_PARSER.close")); *allocsize = (size_t)szvalue.val; return (0);}
开发者ID:Machyne,项目名称:mongo,代码行数:37,
示例5: print_config/* * print_config -- * Output a key/value URI pair by combining v1 and v2. */static intprint_config(WT_SESSION *session, const char *key, const char *v1, const char *v2){ WT_DECL_RET; char *value_ret; const char *cfg[] = { v1, v2, NULL }; /* * The underlying call will stop if the first string is NULL -- check * here and swap in that case. */ if (cfg[0] == NULL) { cfg[0] = cfg[1]; cfg[1] = NULL; } if ((ret = __wt_config_collapse( (WT_SESSION_IMPL *)session, cfg, &value_ret)) != 0) return (util_err(session, ret, NULL)); ret = printf("%s/n%s/n", key, value_ret); free((char *)value_ret); if (ret < 0) return (util_err(session, EIO, NULL)); return (0);}
开发者ID:alabid,项目名称:mongo,代码行数:30,
示例6: util_read_line/* * util_read_line -- * Read a line from stdin into a ULINE. */intutil_read_line(WT_SESSION *session, ULINE *l, bool eof_expected, bool *eofp){ static uint64_t line = 0; size_t len; int ch; ++line; *eofp = false; if (l->memsize == 0) { if ((l->mem = realloc(l->mem, l->memsize + 1024)) == NULL) return (util_err(session, errno, NULL)); l->memsize = 1024; } for (len = 0;; ++len) { if ((ch = getchar()) == EOF) { if (len == 0) { if (eof_expected) { *eofp = true; return (0); } return (util_err(session, 0, "line %" PRIu64 ": unexpected end-of-file", line)); } return (util_err(session, 0, "line %" PRIu64 ": no newline terminator", line)); } if (ch == '/n') break; /* * We nul-terminate the string so it's easier to convert the * line into a record number, that means we always need one * extra byte at the end. */ if (len >= l->memsize - 1) { if ((l->mem = realloc(l->mem, l->memsize + 1024)) == NULL) return (util_err(session, errno, NULL)); l->memsize += 1024; } ((uint8_t *)l->mem)[len] = (uint8_t)ch; } ((uint8_t *)l->mem)[len] = '/0'; /* nul-terminate */ return (0);}
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:53,
示例7: dump_suffix/* * dump_suffix -- * Output the dump file header suffix. */static intdump_suffix(WT_SESSION *session, bool json){ if (json) { if (printf( " },/n" " {/n" " /"data/" : [") < 0) return (util_err(session, EIO, NULL)); } else { if (printf("Data/n") < 0) return (util_err(session, EIO, NULL)); } return (0);}
开发者ID:Tsmith5151,项目名称:mongo,代码行数:19,
示例8: dump_suffix/* * dump_suffix -- * Output the dump file header suffix. */static intdump_suffix(void){ if (printf("Data/n") < 0) return (util_err(EIO, NULL)); return (0);}
开发者ID:ezhangle,项目名称:node-wiredtiger,代码行数:11,
示例9: dump_json_table_end/* * dump_json_table_end -- * Output the JSON syntax that ends a table. */static intdump_json_table_end(void){ if (printf(" ]/n }/n ]") < 0) return (util_err(EIO, NULL)); return (0);}
开发者ID:deepinit-arek,项目名称:wiredtiger,代码行数:11,
示例10: dump_json_begin/* * dump_json_begin -- * Output the dump file header prefix. */static intdump_json_begin(void){ if (printf("{/n") < 0) return (util_err(EIO, NULL)); return (0);}
开发者ID:deepinit-arek,项目名称:wiredtiger,代码行数:11,
示例11: config_rename/* * config_rename -- * Update the URI name. */static intconfig_rename(char **urip, const char *name){ size_t len; char *buf, *p; /* Allocate room. */ len = strlen(*urip) + strlen(name) + 10; if ((buf = malloc(len)) == NULL) return (util_err(errno, NULL)); /* * Find the separating colon characters, but not the trailing one may * not be there. */ if ((p = strchr(*urip, ':')) == NULL) { free(buf); return (format()); } *p = '/0'; p = strchr(p + 1, ':'); snprintf(buf, len, "%s:%s%s", *urip, name, p == NULL ? "" : p); *urip = buf; return (0);}
开发者ID:deepinit-arek,项目名称:wiredtiger,代码行数:30,
示例12: append_target/* * append_target -- * Build a list of comma-separated targets. */static intappend_target(WT_SESSION *session, const char *target, char **bufp){ static bool first = true; static size_t len = 0, remain = 0; static char *buf = NULL; /* 20 bytes of slop */ if (buf == NULL || remain < strlen(target) + 20) { len += strlen(target) + 512; remain += strlen(target) + 512; if ((buf = realloc(buf, len)) == NULL) return (util_err(session, errno, NULL)); *bufp = buf; } if (first) { first = false; strcpy(buf, "target=("); } else buf[strlen(buf) - 1] = ','; /* overwrite previous ")" */ strcat(buf, "/""); strcat(buf, target); strcat(buf, "/")"); remain -= strlen(target) + 1; return (0);}
开发者ID:DINKIN,项目名称:mongo,代码行数:31,
示例13: dump_json_table_end/* * dump_json_table_end -- * Output the JSON syntax that ends a table. */static intdump_json_table_end(WT_SESSION *session){ if (printf(" ]/n }/n ]") < 0) return (util_err(session, EIO, NULL)); return (0);}
开发者ID:Tsmith5151,项目名称:mongo,代码行数:11,
示例14: dump_json_separator/* * dump_json_begin -- * Output the dump file header prefix. */static intdump_json_separator(WT_SESSION *session){ if (printf(",/n") < 0) return (util_err(session, EIO, NULL)); return (0);}
开发者ID:Tsmith5151,项目名称:mongo,代码行数:11,
示例15: handle_client_responsevoid handle_client_response(int sockfd){ char *headers = "HTTP/1.1 200 OK/nContent-Type: text/html/n"; struct FileBuffer *f = file_read("index.html"); if( f->data == NULL){ util_err("(handle_client_response) reading file"); } char *length = malloc(32); bzero(length,32); snprintf(length,32,"%d",f->size); char *ContentLength = "Content-Length: "; char *end = "/n/n"; // Writes the first two headers write(sockfd,headers,strlen(headers)); // Writes 'Content Length: ' write(sockfd,ContentLength,strlen(ContentLength)); // Writes the 'value' of Content Length write(sockfd,length,strlen(length)); // Two endline (aka CRLF, newline, EOL) chars to seperate the HEADERS from the BODY of the response. write(sockfd,end,strlen(end)); // The actual content. (html file) write(sockfd,f->data,f->size);}
开发者ID:af-inet,项目名称:Http-Server-C,代码行数:28,
示例16: dump_json_separator/* * dump_json_begin -- * Output the dump file header prefix. */static intdump_json_separator(void){ if (printf(",/n") < 0) return (util_err(EIO, NULL)); return (0);}
开发者ID:deepinit-arek,项目名称:wiredtiger,代码行数:11,
示例17: dump_suffix/* * dump_suffix -- * Output the dump file header suffix. */static intdump_suffix(WT_SESSION *session){ if (printf("Data/n") < 0) return (util_err(session, EIO, NULL)); return (0);}
开发者ID:alabid,项目名称:mongo,代码行数:11,
示例18: dump_json_begin/* * dump_json_begin -- * Output the dump file header prefix. */static intdump_json_begin(WT_SESSION *session){ if (printf("{/n") < 0) return (util_err(session, EIO, NULL)); return (0);}
开发者ID:Tsmith5151,项目名称:mongo,代码行数:11,
示例19: util_createintutil_create(WT_SESSION *session, int argc, char *argv[]){ WT_DECL_RET; int ch; const char *config, *uri; config = NULL; while ((ch = __wt_getopt(progname, argc, argv, "c:")) != EOF) switch (ch) { case 'c': /* command-line configuration */ config = __wt_optarg; break; case '?': default: return (usage()); } argc -= __wt_optind; argv += __wt_optind; /* The remaining argument is the uri. */ if (argc != 1) return (usage()); if ((uri = util_name(*argv, "table")) == NULL) return (1); if ((ret = session->create(session, uri, config)) != 0) return (util_err(ret, "%s: session.create", uri)); return (0);}
开发者ID:deepinit-arek,项目名称:wiredtiger,代码行数:32,
示例20: dump_json_table_begin/* * dump_json_table_begin -- * Output the JSON syntax that starts a table, along with its config. */static intdump_json_table_begin( WT_SESSION *session, WT_CURSOR *cursor, const char *uri, const char *config){ WT_DECL_RET; const char *name; char *jsonconfig, *stripped; jsonconfig = NULL; /* Get the table name. */ if ((name = strchr(uri, ':')) == NULL) { fprintf(stderr, "%s: %s: corrupted uri/n", progname, uri); return (1); } ++name; if ((ret = __wt_session_create_strip(session, config, NULL, &stripped)) != 0) return (util_err(ret, NULL)); ret = dup_json_string(stripped, &jsonconfig); free(stripped); if (ret != 0) return (util_cerr(uri, "config dup", ret)); if (printf(" /"%s/" : [/n {/n", uri) < 0) goto eio; if (printf(" /"config/" : /"%s/",/n", jsonconfig) < 0) goto eio; if ((ret = dump_json_table_cg( session, cursor, uri, name, "colgroup:", "colgroups")) == 0) { if (printf(",/n") < 0) goto eio; ret = dump_json_table_cg( session, cursor, uri, name, "index:", "indices"); } if (printf("/n },/n {/n /"data/" : [") < 0) goto eio; if (0) {eio: ret = util_err(EIO, NULL); } free(jsonconfig); return (ret);}
开发者ID:deepinit-arek,项目名称:wiredtiger,代码行数:51,
示例21: dump_json_table_config/* * dump_json_table_config -- * Dump the config for the uri. */static intdump_json_table_config(WT_SESSION *session, const char *uri){ WT_CURSOR *cursor; WT_DECL_RET; int tret; char *value; /* Dump the config. */ /* Open a metadata cursor. */ if ((ret = session->open_cursor( session, "metadata:create", NULL, NULL, &cursor)) != 0) { fprintf(stderr, "%s: %s: session.open_cursor: %s/n", progname, "metadata:create", session->strerror(session, ret)); return (1); } /* * Search for the object itself, to make sure it * exists, and get its config string. This where we * find out a table object doesn't exist, use a simple * error message. */ cursor->set_key(cursor, uri); if ((ret = cursor->search(cursor)) == 0) { if ((ret = cursor->get_value(cursor, &value)) != 0) ret = util_cerr(cursor, "get_value", ret); else if (dump_json_table_begin( session, cursor, uri, value) != 0) ret = 1; } else if (ret == WT_NOTFOUND) ret = util_err( session, 0, "%s: No such object exists", uri); else ret = util_err(session, ret, "%s", uri); if ((tret = cursor->close(cursor)) != 0) { tret = util_cerr(cursor, "close", tret); if (ret == 0) ret = tret; } return (ret);}
开发者ID:alabid,项目名称:mongo,代码行数:49,
示例22: config_exec/* * config_exec -- * Create the tables/indices/colgroups implied by the list. */intconfig_exec(WT_SESSION *session, char **list){ WT_DECL_RET; for (; *list != NULL; list += 2) if ((ret = session->create(session, list[0], list[1])) != 0) return (util_err(ret, "%s: session.create", list[0])); return (0);}
开发者ID:deepinit-arek,项目名称:wiredtiger,代码行数:14,
示例23: run_servervoid run_server(int port){ // Socket Identifier int server_sock, client_sock; // Socket Address struct sockaddr *server_addr, *client_addr; // * Avoid Undefined Behavior server_addr = NULL; client_addr = NULL; // Attempt To Bind Server server_sock = sl_tcp_server(sl_sockaddr_server(port)); // Allocate a sockaddr for the client client_addr = sl_sockaddr(); signed char running = 1; if(server_sock < 0){ util_err("(sl_tcp_server) binding socket"); running = 0; } if(OPTION_VERBOSE==1) util_startup(port); while(running){ client_sock = sl_accept(server_sock,client_addr); if(client_sock < 0){ util_err("(sl_accept) accepting connection."); running = 0; }else{ util_say("Accepted Connection."); } handle_client(client_sock); close(client_sock); util_say("Closed Connection."); } // We check != NULL here incase our addr's failed to be allocated - // which happens for server_addr if sl_tcp_server fails to bind. if(server_addr!=NULL) free(server_addr); if(client_addr!=NULL) free(client_addr);}
开发者ID:af-inet,项目名称:Http-Server-C,代码行数:43,
示例24: util_loadintutil_load(WT_SESSION *session, int argc, char *argv[]){ int ch; while ((ch = util_getopt(argc, argv, "af:nr:")) != EOF) switch (ch) { case 'a': /* append (ignore record number keys) */ append = 1; break; case 'f': /* input file */ if (freopen(util_optarg, "r", stdin) == NULL) return ( util_err(errno, "%s: reopen", util_optarg)); break; case 'n': /* don't overwrite existing data */ no_overwrite = 1; break; case 'r': /* rename */ cmdname = util_optarg; break; case '?': default: return (usage()); } argc -= util_optind; argv += util_optind; /* -a and -o are mutually exclusive. */ if (append == 1 && no_overwrite == 1) return (util_err(EINVAL, "the -a (append) and -n (no-overwrite) flags are mutually " "exclusive")); /* The remaining arguments are configuration uri/string pairs. */ if (argc != 0) { if (argc % 2 != 0) return (usage()); cmdconfig = argv; } return (load_dump(session));}
开发者ID:GeertBosch,项目名称:wiredtiger,代码行数:43,
示例25: util_flush/* * util_flush -- * Flush the file successfully, or drop it. */intutil_flush(WT_SESSION *session, const char *uri){ WT_DECL_RET; size_t len; char *buf; len = strlen(uri) + 100; if ((buf = malloc(len)) == NULL) return (util_err(session, errno, NULL)); (void)snprintf(buf, len, "target=(/"%s/")", uri); if ((ret = session->checkpoint(session, buf)) != 0) { ret = util_err(session, ret, "%s: session.checkpoint", uri); (void)session->drop(session, uri, NULL); } free(buf); return (ret);}
开发者ID:AlexOreshkevich,项目名称:mongo,代码行数:24,
示例26: dump_prefix/* * dump_prefix -- * Output the dump file header prefix. */static intdump_prefix(WT_SESSION *session, bool hex, bool json){ int vmajor, vminor, vpatch; (void)wiredtiger_version(&vmajor, &vminor, &vpatch); if (!json && (printf( "WiredTiger Dump (WiredTiger Version %d.%d.%d)/n", vmajor, vminor, vpatch) < 0 || printf("Format=%s/n", hex ? "hex" : "print") < 0 || printf("Header/n") < 0)) return (util_err(session, EIO, NULL)); else if (json && printf( " /"%s/" : /"%d (%d.%d.%d)/",/n", DUMP_JSON_VERSION_MARKER, DUMP_JSON_CURRENT_VERSION, vmajor, vminor, vpatch) < 0) return (util_err(session, EIO, NULL)); return (0);}
开发者ID:Tsmith5151,项目名称:mongo,代码行数:25,
示例27: dump_config/* * dump_config -- * Dump the config for the uri. */static intdump_config(WT_SESSION *session, const char *uri, WT_CURSOR *cursor, bool hex, bool json){ WT_CURSOR *mcursor; WT_DECL_RET; int tret; /* Open a metadata cursor. */ if ((ret = session->open_cursor( session, "metadata:create", NULL, NULL, &mcursor)) != 0) { fprintf(stderr, "%s: %s: session.open_cursor: %s/n", progname, "metadata:create", session->strerror(session, ret)); return (1); } /* * Search for the object itself, just to make sure it exists, we don't * want to output a header if the user entered the wrong name. This is * where we find out a table doesn't exist, use a simple error message. */ mcursor->set_key(mcursor, uri); if ((ret = mcursor->search(mcursor)) == 0) { if ((!json && dump_prefix(session, hex, json) != 0) || dump_table_config(session, mcursor, cursor, uri, json) != 0 || dump_suffix(session, json) != 0) ret = 1; } else if (ret == WT_NOTFOUND) ret = util_err(session, 0, "%s: No such object exists", uri); else ret = util_err(session, ret, "%s", uri); if ((tret = mcursor->close(mcursor)) != 0) { tret = util_cerr(mcursor, "close", tret); if (ret == 0) ret = tret; } return (ret);}
开发者ID:bsamek,项目名称:wiredtiger,代码行数:44,
示例28: util_name/* * util_name -- * Build a name. */char *util_name(const char *s, const char *type, u_int flags){ size_t len; int copy; char *name; copy = 0; if (WT_PREFIX_MATCH(s, "backup:")) { goto type_err; } else if (WT_PREFIX_MATCH(s, "colgroup:")) { if (!(flags & UTIL_COLGROUP_OK)) goto type_err; copy = 1; } else if (WT_PREFIX_MATCH(s, "config:")) { goto type_err; } else if (WT_PREFIX_MATCH(s, "file:")) { if (!(flags & UTIL_FILE_OK)) goto type_err; copy = 1; } else if (WT_PREFIX_MATCH(s, "index:")) { if (!(flags & UTIL_INDEX_OK)) goto type_err; copy = 1; } else if (WT_PREFIX_MATCH(s, "lsm:")) { if (!(flags & UTIL_LSM_OK)) goto type_err; copy = 1; } else if (WT_PREFIX_MATCH(s, "statistics:")) { goto type_err; } else if (WT_PREFIX_MATCH(s, "table:")) { if (!(flags & UTIL_TABLE_OK)) {type_err: fprintf(stderr, "%s: %s: unsupported object type: %s/n", progname, command, s); return (NULL); } copy = 1; } len = strlen(type) + strlen(s) + 2; if ((name = calloc(len, 1)) == NULL) { (void)util_err(errno, NULL); return (NULL); } if (copy) strcpy(name, s); else snprintf(name, len, "%s:%s", type, s); return (name);}
开发者ID:ezhangle,项目名称:node-wiredtiger,代码行数:56,
注:本文中的util_err函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ util_file_exists函数代码示例 C++ util_concat函数代码示例 |