您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xsprintf函数代码示例

51自学网 2021-06-03 11:52:35
  C++
这篇教程C++ xsprintf函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xsprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ xsprintf函数的具体用法?C++ xsprintf怎么用?C++ xsprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xsprintf函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: write_to_syslog

static int write_to_syslog(                int level,                int error,                const char *file,                int line,                const char *func,                const char *buffer) {        char header_priority[2 + DECIMAL_STR_MAX(int) + 1],             header_time[64],             header_pid[4 + DECIMAL_STR_MAX(pid_t) + 1];        struct iovec iovec[5] = {};        struct msghdr msghdr = {                .msg_iov = iovec,                .msg_iovlen = ELEMENTSOF(iovec),        };        time_t t;        struct tm *tm;        if (syslog_fd < 0)                return 0;        xsprintf(header_priority, "<%i>", level);        t = (time_t) (now(CLOCK_REALTIME) / USEC_PER_SEC);        tm = localtime(&t);        if (!tm)                return -EINVAL;        if (strftime(header_time, sizeof(header_time), "%h %e %T ", tm) <= 0)                return -EINVAL;        xsprintf(header_pid, "["PID_FMT"]: ", getpid());        IOVEC_SET_STRING(iovec[0], header_priority);        IOVEC_SET_STRING(iovec[1], header_time);        IOVEC_SET_STRING(iovec[2], program_invocation_short_name);        IOVEC_SET_STRING(iovec[3], header_pid);        IOVEC_SET_STRING(iovec[4], buffer);        /* When using syslog via SOCK_STREAM separate the messages by NUL chars */        if (syslog_is_stream)                iovec[4].iov_len++;        for (;;) {                ssize_t n;                n = sendmsg(syslog_fd, &msghdr, MSG_NOSIGNAL);                if (n < 0)                        return -errno;                if (!syslog_is_stream ||                    (size_t) n >= IOVEC_TOTAL_SIZE(iovec, ELEMENTSOF(iovec)))                        break;                IOVEC_INCREMENT(iovec, ELEMENTSOF(iovec), n);        }        return 1;}
开发者ID:devkral,项目名称:systemd,代码行数:60,


示例2: write_to_kmsg

static int write_to_kmsg(                int level,                int error,                const char *file,                int line,                const char *func,                const char *object_field,                const char *object,                const char *buffer) {        char header_priority[2 + DECIMAL_STR_MAX(int) + 1],             header_pid[4 + DECIMAL_STR_MAX(pid_t) + 1];        struct iovec iovec[5] = {};        if (kmsg_fd < 0)                return 0;        xsprintf(header_priority, "<%i>", level);        xsprintf(header_pid, "["PID_FMT"]: ", getpid());        IOVEC_SET_STRING(iovec[0], header_priority);        IOVEC_SET_STRING(iovec[1], program_invocation_short_name);        IOVEC_SET_STRING(iovec[2], header_pid);        IOVEC_SET_STRING(iovec[3], buffer);        IOVEC_SET_STRING(iovec[4], "/n");        if (writev(kmsg_fd, iovec, ELEMENTSOF(iovec)) < 0)                return -errno;        return 1;}
开发者ID:ChALkeR,项目名称:systemd,代码行数:31,


示例3: audit_callback

/*   Any time an access gets denied this callback will be called   with the audit data.  We then need to just copy the audit data into the msgbuf.*/static int audit_callback(                void *auditdata,                security_class_t cls,                char *msgbuf,                size_t msgbufsize) {        const struct audit_info *audit = auditdata;        uid_t uid = 0, login_uid = 0;        gid_t gid = 0;        char login_uid_buf[DECIMAL_STR_MAX(uid_t) + 1] = "n/a";        char uid_buf[DECIMAL_STR_MAX(uid_t) + 1] = "n/a";        char gid_buf[DECIMAL_STR_MAX(gid_t) + 1] = "n/a";        if (sd_bus_creds_get_audit_login_uid(audit->creds, &login_uid) >= 0)                xsprintf(login_uid_buf, UID_FMT, login_uid);        if (sd_bus_creds_get_euid(audit->creds, &uid) >= 0)                xsprintf(uid_buf, UID_FMT, uid);        if (sd_bus_creds_get_egid(audit->creds, &gid) >= 0)                xsprintf(gid_buf, GID_FMT, gid);        snprintf(msgbuf, msgbufsize,                 "auid=%s uid=%s gid=%s%s%s%s%s%s%s",                 login_uid_buf, uid_buf, gid_buf,                 audit->path ? " path=/"" : "", strempty(audit->path), audit->path ? "/"" : "",                 audit->cmdline ? " cmdline=/"" : "", strempty(audit->cmdline), audit->cmdline ? "/"" : "");        return 0;}
开发者ID:Werkov,项目名称:systemd,代码行数:32,


示例4: CE_SetNumArg

void CE_SetNumArg (CodeEntry* E, long Num)/* Set a new numeric argument for the given code entry that must already** have a numeric argument.*/{    char Buf[16];    /* Check that the entry has a numerical argument */    CHECK (E->Flags & CEF_NUMARG);    /* Make the new argument string */    if (E->Size == 2) {        Num &= 0xFF;        xsprintf (Buf, sizeof (Buf), "$%02X", (unsigned) Num);    } else if (E->Size == 3) {        Num &= 0xFFFF;        xsprintf (Buf, sizeof (Buf), "$%04X", (unsigned) Num);    } else {        Internal ("Invalid instruction size in CE_SetNumArg");    }    /* Replace the argument by the new one */    CE_SetArg (E, Buf);    /* Use the new numerical value */    E->Num = Num;}
开发者ID:Aliandrana,项目名称:cc65,代码行数:27,


示例5: server_forward_kmsg

void server_forward_kmsg(        Server *s,        int priority,        const char *identifier,        const char *message,        const struct ucred *ucred) {        struct iovec iovec[5];        char header_priority[DECIMAL_STR_MAX(priority) + 3],             header_pid[sizeof("[]: ")-1 + DECIMAL_STR_MAX(pid_t) + 1];        int n = 0;        char *ident_buf = NULL;        assert(s);        assert(priority >= 0);        assert(priority <= 999);        assert(message);        if (_unlikely_(LOG_PRI(priority) > s->max_level_kmsg))                return;        if (_unlikely_(s->dev_kmsg_fd < 0))                return;        /* Never allow messages with kernel facility to be written to         * kmsg, regardless where the data comes from. */        priority = syslog_fixup_facility(priority);        /* First: priority field */        xsprintf(header_priority, "<%i>", priority);        IOVEC_SET_STRING(iovec[n++], header_priority);        /* Second: identifier and PID */        if (ucred) {                if (!identifier) {                        get_process_comm(ucred->pid, &ident_buf);                        identifier = ident_buf;                }                xsprintf(header_pid, "["PID_FMT"]: ", ucred->pid);                if (identifier)                        IOVEC_SET_STRING(iovec[n++], identifier);                IOVEC_SET_STRING(iovec[n++], header_pid);        } else if (identifier) {                IOVEC_SET_STRING(iovec[n++], identifier);                IOVEC_SET_STRING(iovec[n++], ": ");        }        /* Fourth: message */        IOVEC_SET_STRING(iovec[n++], message);        IOVEC_SET_STRING(iovec[n++], "/n");        if (writev(s->dev_kmsg_fd, iovec, n) < 0)                log_debug_errno(errno, "Failed to write to /dev/kmsg for logging: %m");        free(ident_buf);}
开发者ID:josephgbr,项目名称:systemd,代码行数:59,


示例6: initTestNotes

static void initTestNotes() {  const int notesSize = 4;  for (int i = 0; i < notesSize; i++) {    xsprintf(noteTitles[i],"Titolo %d",i);    xsprintf(notesSubtitles[i],"Sottotitolo %d",i);    xsprintf(notes[i],"Nota %d",i);  }} 
开发者ID:cerebro84,项目名称:PebbleNotes,代码行数:8,


示例7: get_cap_mask

/* * Read a capability attribute and return bitmask. * @param dev udev_device * @param attr sysfs attribute name (e. g. "capabilities/key") * @param bitmask: Output array which has a sizeof of bitmask_size */static void get_cap_mask(struct udev_device *dev,                         struct udev_device *pdev, const char* attr,                         unsigned long *bitmask, size_t bitmask_size,                         bool test) {        const char *v;        char text[4096];        unsigned i;        char* word;        unsigned long val;        v = udev_device_get_sysattr_value(pdev, attr);        if (!v)                v = "";        xsprintf(text, "%s", v);        log_debug("%s raw kernel attribute: %s", attr, text);        memzero(bitmask, bitmask_size);        i = 0;        while ((word = strrchr(text, ' ')) != NULL) {                val = strtoul (word+1, NULL, 16);                if (i < bitmask_size/sizeof(unsigned long))                        bitmask[i] = val;                else                        log_debug("ignoring %s block %lX which is larger than maximum size", attr, val);                *word = '/0';                ++i;        }        val = strtoul (text, NULL, 16);        if (i < bitmask_size / sizeof(unsigned long))                bitmask[i] = val;        else                log_debug("ignoring %s block %lX which is larger than maximum size", attr, val);        if (test) {                /* printf pattern with the right unsigned long number of hex chars */                xsprintf(text, "  bit %%4u: %%0%zulX/n",                         2 * sizeof(unsigned long));                log_debug("%s decoded bit map:", attr);                val = bitmask_size / sizeof (unsigned long);                /* skip over leading zeros */                while (bitmask[val-1] == 0 && val > 0)                        --val;                for (i = 0; i < val; ++i) {                        DISABLE_WARNING_FORMAT_NONLITERAL;                        log_debug(text, i * BITS_PER_LONG, bitmask[i]);                        REENABLE_WARNING;                }        }}
开发者ID:BenjaminLefoul,项目名称:systemd,代码行数:56,


示例8: DECIMAL_STR_MAX

const char *signal_to_string(int signo) {        static thread_local char buf[sizeof("RTMIN+")-1 + DECIMAL_STR_MAX(int) + 1];        const char *name;        name = __signal_to_string(signo);        if (name)                return name;        if (signo >= SIGRTMIN && signo <= SIGRTMAX)                xsprintf(buf, "RTMIN+%d", signo - SIGRTMIN);        else                xsprintf(buf, "%d", signo);        return buf;}
开发者ID:AOSC-Dev,项目名称:systemd,代码行数:15,


示例9: pcconsole_probe

static void pcconsole_probe(cfe_driver_t *drv,			      unsigned long probe_a, unsigned long probe_b, 			      void *probe_ptr){    pcconsole_t *softc;    char descr[80];    /*      * probe_a is     * probe_b is          * probe_ptr is      */    softc = (pcconsole_t *) KMALLOC(sizeof(pcconsole_t),0);    if (softc) {	memset(softc,0,sizeof(pcconsole_t));	vga_init(&(softc->vga),__ISAaddr(VGA_TEXTBUF_COLOR),outb);	xsprintf(descr,"%s",drv->drv_description,probe_a,probe_b);	cfe_attach(drv,softc,NULL,descr);	}}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:25,


示例10: update_tan_entry

void    update_tan_entry(void){    u8 current_level;    current_level = get_current_tan_level();    xsprintf(tan_level_buffer, "Current tan level: %d", current_level);}
开发者ID:Nanquitas,项目名称:ACNL-NTR-Cheats,代码行数:7,


示例11: set_trackpoint_sensitivity

static void set_trackpoint_sensitivity(struct udev_device *dev, const char *value){        struct udev_device *pdev;        char val_s[DECIMAL_STR_MAX(int)];        int r, val_i;        assert(dev);        assert(value);        /* The sensitivity sysfs attr belongs to the serio parent device */        pdev = udev_device_get_parent_with_subsystem_devtype(dev, "serio", NULL);        if (!pdev) {                log_warning("Failed to get serio parent for '%s'", udev_device_get_devnode(dev));                return;        }        r = safe_atoi(value, &val_i);        if (r < 0) {                log_error("Unable to parse POINTINGSTICK_SENSITIVITY '%s' for '%s'", value, udev_device_get_devnode(dev));                return;        }        xsprintf(val_s, "%d", val_i);        r = udev_device_set_sysattr_value(pdev, "sensitivity", val_s);        if (r < 0)                log_error_errno(r, "Failed to write 'sensitivity' attribute for '%s': %m", udev_device_get_devnode(pdev));}
开发者ID:nazgul77,项目名称:systemd,代码行数:28,


示例12: sd_journal_printv

_public_ int sd_journal_printv(int priority, const char *format, va_list ap) {        /* FIXME: Instead of limiting things to LINE_MAX we could do a           C99 variable-length array on the stack here in a loop. */        char buffer[8 + LINE_MAX], p[sizeof("PRIORITY=")-1 + DECIMAL_STR_MAX(int) + 1];        struct iovec iov[2];        assert_return(priority >= 0, -EINVAL);        assert_return(priority <= 7, -EINVAL);        assert_return(format, -EINVAL);        xsprintf(p, "PRIORITY=%i", priority & LOG_PRIMASK);        memcpy(buffer, "MESSAGE=", 8);        vsnprintf(buffer+8, sizeof(buffer) - 8, format, ap);        /* Strip trailing whitespace, keep prefix whitespace. */        (void) strstrip(buffer);        /* Suppress empty lines */        if (isempty(buffer+8))                return 0;        zero(iov);        IOVEC_SET_STRING(iov[0], buffer);        IOVEC_SET_STRING(iov[1], p);        return sd_journal_sendv(iov, 2);}
开发者ID:ChALkeR,项目名称:systemd,代码行数:30,


示例13: network_link_get_strv

static int network_link_get_strv(int ifindex, const char *key, char ***ret) {        char path[STRLEN("/run/systemd/netif/links/") + DECIMAL_STR_MAX(ifindex) + 1];        _cleanup_strv_free_ char **a = NULL;        _cleanup_free_ char *s = NULL;        int r;        assert_return(ifindex > 0, -EINVAL);        assert_return(ret, -EINVAL);        xsprintf(path, "/run/systemd/netif/links/%i", ifindex);        r = parse_env_file(path, NEWLINE, key, &s, NULL);        if (r == -ENOENT)                return -ENODATA;        if (r < 0)                return r;        if (isempty(s)) {                *ret = NULL;                return 0;        }        a = strv_split(s, " ");        if (!a)                return -ENOMEM;        strv_uniq(a);        r = strv_length(a);        *ret = TAKE_PTR(a);        return r;}
开发者ID:davide125,项目名称:systemd,代码行数:31,


示例14: remote_start

//*****************************************************************************// 
C++ xstr函数代码示例
C++ xsocket函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。