这篇教程C++ xsnprintf函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xsnprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ xsnprintf函数的具体用法?C++ xsnprintf怎么用?C++ xsnprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xsnprintf函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: spu_store_registers/* Override the to_store_registers routine. */static voidspu_store_registers (struct target_ops *ops, struct regcache *regcache, int regno){ struct gdbarch *gdbarch = get_regcache_arch (regcache); struct target_ops *ops_beneath = find_target_beneath (ops); int spufs_fd; CORE_ADDR spufs_addr; /* This version applies only if we're currently in spu_run. */ if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu) { while (ops_beneath && !ops_beneath->to_fetch_registers) ops_beneath = find_target_beneath (ops_beneath); gdb_assert (ops_beneath); ops_beneath->to_store_registers (ops_beneath, regcache, regno); return; } /* We must be stopped on a spu_run system call. */ if (!parse_spufs_run (inferior_ptid, &spufs_fd, &spufs_addr)) return; /* The NPC register is found in PPC memory at SPUFS_ADDR. */ if (regno == -1 || regno == SPU_PC_REGNUM) { gdb_byte buf[4]; regcache_raw_collect (regcache, SPU_PC_REGNUM, buf); target_write (ops_beneath, TARGET_OBJECT_MEMORY, NULL, buf, spufs_addr, sizeof buf); } /* The GPRs are found in the "regs" spufs file. */ if (regno == -1 || (regno >= 0 && regno < SPU_NUM_GPRS)) { gdb_byte buf[16 * SPU_NUM_GPRS]; char annex[32]; int i; for (i = 0; i < SPU_NUM_GPRS; i++) regcache_raw_collect (regcache, i, buf + i*16); xsnprintf (annex, sizeof annex, "%d/regs", spufs_fd); target_write (ops_beneath, TARGET_OBJECT_SPU, annex, buf, 0, sizeof buf); }}
开发者ID:cooljeanius,项目名称:apple-gdb-1824,代码行数:50,
示例2: style_tostring/* Convert style to a string. */const char *style_tostring(struct grid_cell *gc){ int c, off = 0, comma = 0; static char s[256]; *s = '/0'; if (gc->fg != 8 || gc->flags & GRID_FLAG_FG256) { if (gc->flags & GRID_FLAG_FG256) c = gc->fg | 0x100; else c = gc->fg; off += xsnprintf(s, sizeof s, "fg=%s", colour_tostring(c)); comma = 1; } if (gc->bg != 8 || gc->flags & GRID_FLAG_BG256) { if (gc->flags & GRID_FLAG_BG256) c = gc->bg | 0x100; else c = gc->bg; off += xsnprintf(s + off, sizeof s - off, "%sbg=%s", comma ? "," : "", colour_tostring(c)); comma = 1; } if (gc->attr != 0 && gc->attr != GRID_ATTR_CHARSET) { xsnprintf(s + off, sizeof s - off, "%s%s", comma ? "," : "", attributes_tostring(gc->attr)); } if (*s == '/0') return ("default"); return (s);}
开发者ID:Darkoe,项目名称:tmux,代码行数:37,
示例3: safe_strerrorchar *safe_strerror (int errnum){ char *msg; msg = strerror (errnum); if (msg == NULL) { static char buf[32]; xsnprintf (buf, sizeof buf, "(undocumented errno %d)", errnum); msg = buf; } return (msg);}
开发者ID:RasmusKoldsoe,项目名称:performand.k70.2,代码行数:15,
示例4: server_fill_environvoidserver_fill_environ(struct session *s, struct environ *env){ char tmuxvar[MAXPATHLEN], *term; u_int idx; if (session_index(s, &idx) != 0) fatalx("session not found"); xsnprintf(tmuxvar, sizeof tmuxvar, "%s,%ld,%u", socket_path, (long) getpid(), idx); environ_set(env, "TMUX", tmuxvar); term = options_get_string(&s->options, "default-terminal"); environ_set(env, "TERM", term);}
开发者ID:ThomasAdam,项目名称:tmux-ARCHIVED,代码行数:15,
示例5: send_sideband/* * fd is connected to the remote side; send the sideband data * over multiplexed packet stream. */void send_sideband(int fd, int band, const char *data, ssize_t sz, int packet_max){ const char *p = data; while (sz) { unsigned n; char hdr[5]; n = sz; if (packet_max - 5 < n) n = packet_max - 5; if (0 <= band) { xsnprintf(hdr, sizeof(hdr), "%04x", n + 5); hdr[4] = band; write_or_die(fd, hdr, 5); } else { xsnprintf(hdr, sizeof(hdr), "%04x", n + 4); write_or_die(fd, hdr, 4); } write_or_die(fd, p, n); p += n; sz -= n; }}
开发者ID:koraktor,项目名称:git,代码行数:28,
示例6: makesocketpathchar *makesocketpath(const char *label){ char base[PATH_MAX], realbase[PATH_MAX], *path, *s; struct stat sb; u_int uid; uid = getuid(); if ((s = getenv("TMUX_TMPDIR")) != NULL && *s != '/0') xsnprintf(base, sizeof base, "%s/", s); else if ((s = getenv("TMPDIR")) != NULL && *s != '/0') xsnprintf(base, sizeof base, "%s/tmux-%u", s, uid); else xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid); if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST) return (NULL); if (lstat(base, &sb) != 0) return (NULL); if (!S_ISDIR(sb.st_mode)) { errno = ENOTDIR; return (NULL); } if (sb.st_uid != uid || (!S_ISDIR(sb.st_mode) && sb.st_mode & (S_IRWXG|S_IRWXO)) != 0) { errno = EACCES; return (NULL); } if (realpath(base, realbase) == NULL) strlcpy(realbase, base, sizeof realbase); xasprintf(&path, "%s/%s", realbase, label); return (path);}
开发者ID:JonAWhite,项目名称:tmux,代码行数:36,
示例7: set_variant_num_fprs/* Indicate that the variant VAR has NUM_FPRS floating-point registers, and fill in the names array appropriately. */static voidset_variant_num_fprs (struct gdbarch_tdep *var, int num_fprs){ int r; var->num_fprs = num_fprs; for (r = 0; r < num_fprs; ++r) { char buf[20]; xsnprintf (buf, sizeof (buf), "fr%d", r); var->register_names[first_fpr_regnum + r] = xstrdup (buf); }}
开发者ID:RadeonOpenCompute,项目名称:ROCm-GDB,代码行数:17,
示例8: queue_directorystatic void queue_directory(const unsigned char *sha1, struct strbuf *base, const char *filename, unsigned mode, int stage, struct archiver_context *c){ struct directory *d; size_t len = st_add4(base->len, 1, strlen(filename), 1); d = xmalloc(st_add(sizeof(*d), len)); d->up = c->bottom; d->baselen = base->len; d->mode = mode; d->stage = stage; c->bottom = d; d->len = xsnprintf(d->path, len, "%.*s%s/", (int)base->len, base->buf, filename); hashcpy(d->oid.hash, sha1);}
开发者ID:fcharlie,项目名称:git,代码行数:15,
示例9: cvs_server_static_directoryvoidcvs_server_static_directory(char *data){ FILE *fp; char fpath[MAXPATHLEN]; (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, CVS_PATH_STATICENTRIES); if ((fp = fopen(fpath, "w+")) == NULL) { cvs_log(LP_ERRNO, "%s", fpath); return; } (void)fclose(fp);}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:15,
示例10: colour_tostring/* Convert colour to a string. */const char *colour_tostring(int c){ static char s[32]; if (c & 0x100) { xsnprintf(s, sizeof s, "colour%u", c & ~0x100); return (s); } switch (c) { case 0: return ("black"); case 1: return ("red"); case 2: return ("green"); case 3: return ("yellow"); case 4: return ("blue"); case 5: return ("magenta"); case 6: return ("cyan"); case 7: return ("white"); case 8: return ("default"); case 90: return ("brightblack"); case 91: return ("brightred"); case 92: return ("brightgreen"); case 93: return ("brightyellow"); case 94: return ("brightblue"); case 95: return ("brightmagenta"); case 96: return ("brightcyan"); case 97: return ("brightwhite"); } return (NULL);}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:49,
示例11: winansi_initvoid winansi_init(void){ int con1, con2; char name[32]; /* check if either stdout or stderr is a console output screen buffer */ con1 = is_console(1); con2 = is_console(2); /* Also compute console bit for fd 0 even though we don't need the result here. */ is_console(0); if (!con1 && !con2) {#ifdef DETECT_MSYS_TTY /* check if stdin / stdout / stderr are MSYS2 pty pipes */ detect_msys_tty(0); detect_msys_tty(1); detect_msys_tty(2);#endif return; } /* create a named pipe to communicate with the console thread */ xsnprintf(name, sizeof(name), "////.//pipe//winansi%lu", GetCurrentProcessId()); hwrite = CreateNamedPipe(name, PIPE_ACCESS_OUTBOUND, PIPE_TYPE_BYTE | PIPE_WAIT, 1, BUFFER_SIZE, 0, 0, NULL); if (hwrite == INVALID_HANDLE_VALUE) die_lasterr("CreateNamedPipe failed"); hread = CreateFile(name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); if (hread == INVALID_HANDLE_VALUE) die_lasterr("CreateFile for named pipe failed"); /* start console spool thread on the pipe's read end */ hthread = CreateThread(NULL, 0, console_thread, NULL, 0, NULL); if (hthread == INVALID_HANDLE_VALUE) die_lasterr("CreateThread(console_thread) failed"); /* schedule cleanup routine */ if (atexit(winansi_exit)) die_errno("atexit(winansi_exit) failed"); /* redirect stdout / stderr to the pipe */ if (con1) hconsole1 = swap_osfhnd(1, duplicate_handle(hwrite)); if (con2) hconsole2 = swap_osfhnd(2, duplicate_handle(hwrite));}
开发者ID:PEPE-coin,项目名称:git,代码行数:48,
示例12: cmd_printsize_tcmd_print(struct cmd *cmd, char *buf, size_t len){ size_t off, used; off = xsnprintf(buf, len, "%s ", cmd->entry->name); if (off + 1 < len) { used = args_print(cmd->args, buf + off, len - off - 1); if (used == 0) off--; else off += used; buf[off] = '/0'; } return (off);}
开发者ID:Darkoe,项目名称:tmux,代码行数:16,
示例13: cli_field_intstatic voidcli_field_int (struct ui_out *uiout, int fldno, int width, enum ui_align alignment, const char *fldname, int value){ char buffer[20]; /* FIXME: how many chars long a %d can become? */ cli_out_data *data = ui_out_data (uiout); if (data->suppress_output) return; xsnprintf (buffer, sizeof (buffer), "%d", value); /* Always go through the function pointer (virtual function call). We may have been extended. */ uo_field_string (uiout, fldno, width, alignment, fldname, buffer);}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:16,
示例14: report_messagestatic void report_message(const char *prefix, const char *err, va_list params){ int sz; char msg[4096]; sz = xsnprintf(msg, sizeof(msg), "%s", prefix); sz += vsnprintf(msg + sz, sizeof(msg) - sz, err, params); if (sz > (sizeof(msg) - 1)) sz = sizeof(msg) - 1; msg[sz++] = '/n'; if (use_sideband) send_sideband(1, 2, msg, sz, use_sideband); else xwrite(2, msg, sz);}
开发者ID:1tgr,项目名称:git,代码行数:16,
示例15: union_searchintunion_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp){ char *mapd = xstrdup(map + UNION_PREFLEN); char **v = strsplit(mapd, ':', '/"'); char **p; size_t l; for (p = v; p[1]; p++) ; l = strlen(*p) + 5; *pval = xmalloc(l); xsnprintf(*pval, l, "fs:=%s", *p); XFREE(mapd); XFREE(v); return 0;}
开发者ID:0mp,项目名称:freebsd,代码行数:16,
示例16: fbsd_pid_to_strstatic char *fbsd_pid_to_str (struct target_ops *ops, ptid_t ptid){ lwpid_t lwp; lwp = ptid_get_lwp (ptid); if (lwp != 0) { static char buf[64]; int pid = ptid_get_pid (ptid); xsnprintf (buf, sizeof buf, "LWP %d of process %d", lwp, pid); return buf; } return normal_pid_to_str (ptid);}
开发者ID:Distrotech,项目名称:binutils,代码行数:17,
示例17: nbsd_pid_to_exec_filechar *nbsd_pid_to_exec_file (struct target_ops *self, int pid){ ssize_t len; static char buf[PATH_MAX]; char name[PATH_MAX]; xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid); len = readlink (name, buf, PATH_MAX - 1); if (len != -1) { buf[len] = '/0'; return buf; } return NULL;}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:17,
示例18: match_age_descvoidmatch_age_desc(struct expritem *ei, char *buf, size_t len){ struct match_age_data *data = ei->data; const char *cmp = ""; if (data->time < 0) { strlcpy(buf, "age invalid", len); return; } if (data->cmp == CMP_LT) cmp = "<"; else if (data->cmp == CMP_GT) cmp = ">"; xsnprintf(buf, len, "age %s %lld seconds", cmp, data->time);}
开发者ID:avkrotov,项目名称:fdm,代码行数:17,
示例19: xsnprintfconst char *fbsd_nat_target::pid_to_str (ptid_t ptid){ lwpid_t lwp; lwp = ptid.lwp (); if (lwp != 0) { static char buf[64]; int pid = ptid.pid (); xsnprintf (buf, sizeof buf, "LWP %d of process %d", lwp, pid); return buf; } return normal_pid_to_str (ptid);}
开发者ID:jon-turney,项目名称:binutils-gdb,代码行数:17,
示例20: mw_get_base_dir/* * mw_get_base_dir() * * Returns a string with absolute path to BASEDIR, which for now is $HOME/mw. * If BASEDIR does not exist, we create it. */char *mw_get_base_dir(struct mw_conf_head *root){ char *home, *mwbuildroot; if ((mwbuildroot = mw_get_config_var(root, "MWBUILD_ROOT")) == NULL) { mwbuildroot = xmalloc(MAXPATHLEN); memset(mwbuildroot, '/0', MAXPATHLEN); /* $HOME/mw is the default */ if ((home = getenv("HOME")) == NULL) { fprintf(stderr, "could not find value of $HOME/n"); exit(1); } xsnprintf(mwbuildroot, MAXPATHLEN, "%s/mw", home); } mw_mkpath(mwbuildroot); return (mwbuildroot);}
开发者ID:niallo,项目名称:mwbuild,代码行数:24,
示例21: cvs_server_update_entryvoidcvs_server_update_entry(const char *resp, struct cvs_file *cf){ char *p; char repo[MAXPATHLEN], fpath[MAXPATHLEN]; if ((p = strrchr(cf->file_rpath, ',')) != NULL) *p = '/0'; cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", repo, cf->file_name); cvs_server_send_response("%s %s/", resp, cf->file_wd); cvs_remote_output(fpath); if (p != NULL) *p = ',';}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:18,
示例22: cmd_target_printsize_tcmd_target_print(struct cmd *self, char *buf, size_t len){ struct cmd_target_data *data = self->data; size_t off = 0; off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) return (off); off += cmd_print_flags(buf, len, off, data->chflags); if (off < len && data->target != NULL) off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->arg != NULL) off += cmd_prarg(buf + off, len - off, " ", data->arg); if (off < len && data->arg2 != NULL) off += cmd_prarg(buf + off, len - off, " ", data->arg2); return (off);}
开发者ID:ThomasAdam,项目名称:tmux-ARCHIVED,代码行数:18,
示例23: cmd_list_printsize_tcmd_list_print(struct cmd_list *cmdlist, char *buf, size_t len){ struct cmd *cmd; size_t off; off = 0; TAILQ_FOREACH(cmd, cmdlist, qentry) { if (off >= len) break; off += cmd_print(cmd, buf + off, len - off); if (off >= len) break; if (TAILQ_NEXT(cmd, qentry) != NULL) off += xsnprintf(buf + off, len - off, " ; "); } return (off);}
开发者ID:ThomasAdam,项目名称:tmux-ARCHIVED,代码行数:18,
示例24: Apoptosisstatic void Apoptosis(void){ char promiser_buf[CF_SMALLBUF]; snprintf(promiser_buf, sizeof(promiser_buf), "%s/bin/cf-execd", CFWORKDIR); if (LoadProcessTable(&PROCESSTABLE)) { char myuid[PRINTSIZE(unsigned)]; xsnprintf(myuid, sizeof(myuid), "%u", (unsigned) getuid()); Rlist *owners = NULL; RlistPrepend(&owners, myuid, RVAL_TYPE_SCALAR); ProcessSelect process_select = { .owner = owners, .process_result = "process_owner", }; Item *killlist = SelectProcesses(PROCESSTABLE, promiser_buf, process_select, true); RlistDestroy(owners); for (Item *ip = killlist; ip != NULL; ip = ip->next) { pid_t pid = ip->counter; if (pid != getpid() && kill(pid, SIGTERM) < 0) { if (errno == ESRCH) { /* That's ok, process exited voluntarily */ } else { Log(LOG_LEVEL_ERR, "Unable to kill stale cf-execd process pid=%d. (kill: %s)", (int)pid, GetErrorStr()); } } } } DeleteItemList(PROCESSTABLE); Log(LOG_LEVEL_VERBOSE, "Pruning complete");}
开发者ID:Webhuis,项目名称:Cfengine-debian,代码行数:44,
示例25: prepare_headerstatic void prepare_header(struct archiver_args *args, struct ustar_header *header, unsigned int mode, unsigned long size){ xsnprintf(header->mode, sizeof(header->mode), "%07o", mode & 07777); xsnprintf(header->size, sizeof(header->size), "%011"PRIoMAX , S_ISREG(mode) ? (uintmax_t)size : (uintmax_t)0); xsnprintf(header->mtime, sizeof(header->mtime), "%011lo", (unsigned long) args->time); xsnprintf(header->uid, sizeof(header->uid), "%07o", 0); xsnprintf(header->gid, sizeof(header->gid), "%07o", 0); strlcpy(header->uname, "root", sizeof(header->uname)); strlcpy(header->gname, "root", sizeof(header->gname)); xsnprintf(header->devmajor, sizeof(header->devmajor), "%07o", 0); xsnprintf(header->devminor, sizeof(header->devminor), "%07o", 0); memcpy(header->magic, "ustar", 6); memcpy(header->version, "00", 2); xsnprintf(header->chksum, sizeof(header->chksum), "%07o", ustar_header_chksum(header));}
开发者ID:XGodLike,项目名称:Git,代码行数:20,
示例26: get_hex_string/* get string version (in hex) of identifier */static char *get_hex_string(u_int len, const char *fhdata){ u_int i; static char buf[128]; /* better not go over it! */ char str[16]; short int arr[64]; if (!fhdata) return NULL; buf[0] = '/0'; memset(&arr[0], 0, (64 * sizeof(short int))); memcpy(&arr[0], &fhdata[0], len); for (i=0; i<len/sizeof(unsigned short int); i++) { xsnprintf(str, sizeof(str), "%04x", ntohs(arr[i])); xstrlcat(buf, str, sizeof(buf)); } return buf;}
开发者ID:enukane,项目名称:netbsd-src,代码行数:20,
示例27: op_name_standardchar *op_name_standard (enum exp_opcode opcode){ switch (opcode) { default: { static char buf[30]; xsnprintf (buf, sizeof (buf), "<unknown %d>", opcode); return buf; }#define OP(name) / case name: / return #name ;#include "std-operator.def"#undef OP }}
开发者ID:5kg,项目名称:gdb,代码行数:19,
注:本文中的xsnprintf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ xsocket函数代码示例 C++ xsltTransformError函数代码示例 |