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

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

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

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

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

示例1: 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,


示例2: match_rules

int match_rules (struct ruleset *rule, struct ruleset *packet){    int param = REG_EXTENDED|REG_NOSUB;    if (rule->rule != packet->rule || rule->direction != packet->direction)        return 0;    if (!strempty(rule->from)) {        if (Strcmp(rule->from, packet->from))            return 0;    }    if (!strempty(rule->to)) {        if (Strcmp(rule->to, packet->to))            return 0;    }    if (!strempty(rule->action)) {        if (Strcmp(rule->action, packet->action))            return 0;    }    if (!strempty(rule->data)) {        if (rule->icase)            param |= REG_ICASE;        if (!__match_regex(rule->data, packet->data, param))            return 0;    }    return 1;}
开发者ID:Ethylix,项目名称:child,代码行数:31,


示例3: bus_match_dump

void bus_match_dump(struct bus_match_node *node, unsigned level) {        struct bus_match_node *c;        _cleanup_free_ char *pfx = NULL;        char buf[32];        if (!node)                return;        pfx = strrep("  ", level);        printf("%s[%s]", strempty(pfx), bus_match_node_type_to_string(node->type, buf, sizeof(buf)));        if (node->type == BUS_MATCH_VALUE) {                if (node->parent->type == BUS_MATCH_MESSAGE_TYPE)                        printf(" <%u>/n", node->value.u8);                else                        printf(" <%s>/n", node->value.str);        } else if (node->type == BUS_MATCH_ROOT)                puts(" root");        else if (node->type == BUS_MATCH_LEAF)                printf(" %p/%p/n", node->leaf.callback, node->leaf.userdata);        else                putchar('/n');        if (BUS_MATCH_CAN_HASH(node->type)) {                Iterator i;                HASHMAP_FOREACH(c, node->compare.children, i)                        bus_match_dump(c, level + 1);        }        for (c = node->child; c; c = c->next)                bus_match_dump(c, level + 1);}
开发者ID:chuanchang,项目名称:systemd,代码行数:33,


示例4: PartitionedPageIO

DB::DB(const char* filename, ptnk_opts_t opts, int mode){	if(opts & OHELPERTHREAD)	{		m_helper.reset(new Helper);		}	if(! strempty(filename) && (opts & OPARTITIONED))	{		PartitionedPageIO* ppio;		m_pio.reset((ppio = new PartitionedPageIO(filename, opts, mode)));		if(m_helper)		{			ppio->attachHelper(m_helper.get());			ppio->setHookAddNewPartition([this] () {				m_helper->enq([this] () {					this->handleHookAddNewPartition();				});			});		}	}	else	{		m_pio.reset(new PageIOMem(filename, opts, mode));	}	m_tpio.reset(new TPIO(m_pio, opts));	initCommon();}
开发者ID:nyaxt,项目名称:ptnk,代码行数:29,


示例5: load_env_file_push

static int load_env_file_push(                const char *filename, unsigned line,                const char *key, char *value,                void *userdata) {        char ***m = userdata;        char *p;        int r;        if (!utf8_is_valid(key)) {                _cleanup_free_ char *t = utf8_escape_invalid(key);                log_error("%s:%u: invalid UTF-8 for key '%s', ignoring.", strna(filename), line, t);                return -EINVAL;        }        if (value && !utf8_is_valid(value)) {                _cleanup_free_ char *t = utf8_escape_invalid(value);                log_error("%s:%u: invalid UTF-8 value for key %s: '%s', ignoring.", strna(filename), line, key, t);                return -EINVAL;        }        p = strjoin(key, "=", strempty(value), NULL);        if (!p)                return -ENOMEM;        r = strv_consume(m, p);        if (r < 0)                return r;        free(value);        return 0;}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:33,


示例6: warn_wall

static int warn_wall(Manager *m, usec_t n) {        char date[FORMAT_TIMESTAMP_MAX] = {};        _cleanup_free_ char *l = NULL;        usec_t left;        int r;        assert(m);        if (!m->enable_wall_messages)                return 0;        left = m->scheduled_shutdown_timeout > n;        r = asprintf(&l, "%s%sThe system is going down for %s %s%s!",                     strempty(m->wall_message),                     isempty(m->wall_message) ? "" : "/n",                     m->scheduled_shutdown_type,                     left ? "at " : "NOW",                     left ? format_timestamp(date, sizeof(date), m->scheduled_shutdown_timeout) : "");        if (r < 0) {                log_oom();                return 0;        }        utmp_wall(l, uid_to_name(m->scheduled_shutdown_uid),                  m->scheduled_shutdown_tty, logind_wall_tty_filter, m);        return 1;}
开发者ID:halfline,项目名称:systemd,代码行数:29,


示例7: introspect_write_interface

int introspect_write_interface(struct introspect *i, const char *interface, const sd_bus_vtable *v) {        assert(i);        assert(interface);        assert(v);        fprintf(i->f, " <interface name=/"%s/">/n", interface);        for (; v->type != _SD_BUS_VTABLE_END; v++) {                switch (v->type) {                case _SD_BUS_VTABLE_START:                        if (v->flags & SD_BUS_VTABLE_DEPRECATED)                                fputs("  <annotation name=/"org.freedesktop.DBus.Deprecated/" value=/"true/"/>/n", i->f);                        break;                case _SD_BUS_VTABLE_METHOD:                        fprintf(i->f, "  <method name=/"%s/">/n", v->x.method.member);                        introspect_write_arguments(i, strempty(v->x.method.signature), "in");                        introspect_write_arguments(i, strempty(v->x.method.result), "out");                        introspect_write_flags(i, v->type, v->flags);                        fputs("  </method>/n", i->f);                        break;                case _SD_BUS_VTABLE_PROPERTY:                case _SD_BUS_VTABLE_WRITABLE_PROPERTY:                        fprintf(i->f, "  <property name=/"%s/" type=/"%s/" access=/"%s/">/n",                                v->x.property.member,                                v->x.property.signature,                                v->type == _SD_BUS_VTABLE_WRITABLE_PROPERTY ? "readwrite" : "read");                        introspect_write_flags(i, v->type, v->flags);                        fputs("  </property>/n", i->f);                        break;                case _SD_BUS_VTABLE_SIGNAL:                        fprintf(i->f, "  <signal name=/"%s/">/n", v->x.signal.member);                        introspect_write_arguments(i, strempty(v->x.signal.signature), NULL);                        introspect_write_flags(i, v->type, v->flags);                        fputs("  </signal>/n", i->f);                        break;                }        }        fputs(" </interface>/n", i->f);        return 0;}
开发者ID:shazj99,项目名称:systemd,代码行数:47,


示例8: copy_cb

/*********************************************************************** *                                                                     * *   Copy selected items from the left list to the right list.         * *                                                                     * ***********************************************************************/static void copy_cb(Widget w, XtPointer cd, XmAnyCallbackStruct *cbs){   int         icnt, pos, pcnt, *posl;   XmString   *items;   if (XmListGetSelectedPos(var2NtSList, &posl, &pcnt)) {      pos = posl[pcnt-1] + 1;      XtFree((char *)posl);   } else      pos = 0;   XmListDeselectAllItems(var2NtSList);   if (w == exprNtSText) {      char     *expr = XmTextGetString(w);      if (!strempty(expr)) {         XmString xms = XmStringCreateSimple(expr);         XmListAddItem(var2NtSList, xms, pos);         XmStringFree(xms);      }      XtFree(expr);      /*       * ugly... I don't want to show the scanner after hitting the       * KActivate in the text widget       */      no_scan = True;   } else if (w == copyNtSButton) {      XtVaGetValues(var1NtSList, XmNselectedItemCount, &icnt,                                 XmNselectedItems,     &items,                                 NULL);      XmListAddItems(var2NtSList, items, icnt, pos);   } else if (w == copyAllNtSButton) {      XtVaGetValues(var1NtSList, XmNitemCount, &icnt,                                 XmNitems,     &items,                                 NULL);      clear_selector_columns(2);      XmListAddItems(var2NtSList, items, icnt, pos);   } else if (w == var1NtSList) {      XmListCallbackStruct *cbsl = (XmListCallbackStruct *) cbs;      if (cbsl->event->type == ButtonRelease)         XmListAddItem(var2NtSList, cbsl->item, pos);   }   XmListSelectPos(var2NtSList, pos, False);}
开发者ID:apc-llc,项目名称:cernlib,代码行数:62,


示例9: util_resolve_subsys_kernel

/* handle "[<SUBSYSTEM>/<KERNEL>]<attribute>" format */int util_resolve_subsys_kernel(const char *string, char *result, size_t maxsize, bool read_value) {        char temp[UTIL_PATH_SIZE], *subsys, *sysname, *attr;        _cleanup_(sd_device_unrefp) sd_device *dev = NULL;        const char *val;        int r;        if (string[0] != '[')                return -EINVAL;        strscpy(temp, sizeof(temp), string);        subsys = &temp[1];        sysname = strchr(subsys, '/');        if (!sysname)                return -EINVAL;        sysname[0] = '/0';        sysname = &sysname[1];        attr = strchr(sysname, ']');        if (!attr)                return -EINVAL;        attr[0] = '/0';        attr = &attr[1];        if (attr[0] == '/')                attr = &attr[1];        if (attr[0] == '/0')                attr = NULL;        if (read_value && !attr)                return -EINVAL;        r = sd_device_new_from_subsystem_sysname(&dev, subsys, sysname);        if (r < 0)                return r;        if (read_value) {                r = sd_device_get_sysattr_value(dev, attr, &val);                if (r < 0 && r != -ENOENT)                        return r;                if (r == -ENOENT)                        result[0] = '/0';                else                        strscpy(result, maxsize, val);                log_debug("value '[%s/%s]%s' is '%s'", subsys, sysname, attr, result);        } else {                r = sd_device_get_syspath(dev, &val);                if (r < 0)                        return r;                strscpyl(result, maxsize, val, attr ? "/" : NULL, attr ?: NULL, NULL);                log_debug("path '[%s/%s]%s' is '%s'", subsys, sysname, strempty(attr), result);        }        return 0;}
开发者ID:clemensg,项目名称:systemd,代码行数:56,


示例10: test_conf_files_insert

static void test_conf_files_insert(const char *root) {        _cleanup_strv_free_ char **s = NULL;        log_info("/* %s root=%s */", __func__, strempty(root));        char **dirs = STRV_MAKE("/dir1", "/dir2", "/dir3");        _cleanup_free_ const char                *foo1 = prefix_root(root, "/dir1/foo.conf"),                *foo2 = prefix_root(root, "/dir2/foo.conf"),                *bar2 = prefix_root(root, "/dir2/bar.conf"),                *zzz3 = prefix_root(root, "/dir3/zzz.conf"),                *whatever = prefix_root(root, "/whatever.conf");        assert_se(conf_files_insert(&s, root, dirs, "/dir2/foo.conf") == 0);        assert_se(strv_equal(s, STRV_MAKE(foo2)));        /* The same file again, https://github.com/systemd/systemd/issues/11124 */        assert_se(conf_files_insert(&s, root, dirs, "/dir2/foo.conf") == 0);        assert_se(strv_equal(s, STRV_MAKE(foo2)));        /* Lower priority → new entry is ignored */        assert_se(conf_files_insert(&s, root, dirs, "/dir3/foo.conf") == 0);        assert_se(strv_equal(s, STRV_MAKE(foo2)));        /* Higher priority → new entry replaces */        assert_se(conf_files_insert(&s, root, dirs, "/dir1/foo.conf") == 0);        assert_se(strv_equal(s, STRV_MAKE(foo1)));        /* Earlier basename */        assert_se(conf_files_insert(&s, root, dirs, "/dir2/bar.conf") == 0);        assert_se(strv_equal(s, STRV_MAKE(bar2, foo1)));        /* Later basename */        assert_se(conf_files_insert(&s, root, dirs, "/dir3/zzz.conf") == 0);        assert_se(strv_equal(s, STRV_MAKE(bar2, foo1, zzz3)));        /* All lower priority → all ignored */        assert_se(conf_files_insert(&s, root, dirs, "/dir3/zzz.conf") == 0);        assert_se(conf_files_insert(&s, root, dirs, "/dir2/bar.conf") == 0);        assert_se(conf_files_insert(&s, root, dirs, "/dir3/bar.conf") == 0);        assert_se(conf_files_insert(&s, root, dirs, "/dir2/foo.conf") == 0);        assert_se(strv_equal(s, STRV_MAKE(bar2, foo1, zzz3)));        /* Two entries that don't match any of the directories, but match basename */        assert_se(conf_files_insert(&s, root, dirs, "/dir4/zzz.conf") == 0);        assert_se(conf_files_insert(&s, root, dirs, "/zzz.conf") == 0);        assert_se(strv_equal(s, STRV_MAKE(bar2, foo1, zzz3)));        /* An entry that doesn't match any of the directories, no match at all */        assert_se(conf_files_insert(&s, root, dirs, "/whatever.conf") == 0);        assert_se(strv_equal(s, STRV_MAKE(bar2, foo1, whatever, zzz3)));}
开发者ID:Keruspe,项目名称:systemd,代码行数:53,


示例11: sd_bus_set_property

_public_ int sd_bus_set_property(                sd_bus *bus,                const char *destination,                const char *path,                const char *interface,                const char *member,                sd_bus_error *error,                const char *type, ...) {        _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;        va_list ap;        int r;        bus_assert_return(bus, -EINVAL, error);        bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error);        bus_assert_return(member_name_is_valid(member), -EINVAL, error);        bus_assert_return(signature_is_single(type, false), -EINVAL, error);        bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);        if (!BUS_IS_OPEN(bus->state)) {                r = -ENOTCONN;                goto fail;        }        r = sd_bus_message_new_method_call(bus, &m, destination, path, "org.freedesktop.DBus.Properties", "Set");        if (r < 0)                goto fail;        r = sd_bus_message_append(m, "ss", strempty(interface), member);        if (r < 0)                goto fail;        r = sd_bus_message_open_container(m, 'v', type);        if (r < 0)                goto fail;        va_start(ap, type);        r = sd_bus_message_appendv(m, type, ap);        va_end(ap);        if (r < 0)                goto fail;        r = sd_bus_message_close_container(m);        if (r < 0)                goto fail;        return sd_bus_call(bus, m, 0, error, NULL);fail:        return sd_bus_error_set_errno(error, r);}
开发者ID:dankor,项目名称:systemd,代码行数:51,


示例12: SetStatus

void HttpHelper::SetStatus(int status, const char* reason){	m_status = status;	if(strempty(reason))	{		THttpStatus::const_iterator it = sm_status.find(status);		if(it != sm_status.end())		{			m_reason = it->second;			return;		}	}	m_reason = reason;}
开发者ID:azalpy,项目名称:sdk,代码行数:14,


示例13: pppoe_send_initiation

static int pppoe_send_initiation(sd_pppoe *ppp) {        int r;        r = pppoe_send(ppp, PADI_CODE);        if (r < 0)                return r;        log_debug("PPPoE: sent DISCOVER (Service-Name: %s)",                  strempty(ppp->service_name));        pppoe_arm_timeout(ppp);        return r;}
开发者ID:franciozzy,项目名称:systemd,代码行数:14,


示例14: filter_check

int filter_check (char *line, int direction){    if (rule_list.enabled == 0)        return -1;    struct ruleset *rule, *last = NULL, packet;    memset(&packet, 0, sizeof(packet));    char *from, *action, *to, *data;    char temp[1024];    strncpy(temp, line, 1023);    from = temp;    action = SeperateWord(from);    to = SeperateWord(action);    data = SeperateWord(to);    if (strempty(from))        return -1;    if (*from == ':')        from++;    packet.direction = direction;    strncpy(packet.from, from, NICKLEN);    if (action)        strncpy(packet.action, action, 128);    if (to)        strncpy(packet.to, to, NICKLEN);    if (data) {        if (*data == ':')            data++;        strncpy(packet.data, data, 1023);    }    for (rule = rule_list.ltail; rule; rule = rule->lprev) {        packet.rule = rule->rule;        if ((match_rules(rule, &packet)) == 1) {            last = rule;            if (rule->quick == 1)                return rule->rule;        }    }    if (last)        return last->rule;    return -1;}
开发者ID:Ethylix,项目名称:child,代码行数:49,


示例15: kill_context_dump

void kill_context_dump(KillContext *c, FILE *f, const char *prefix) {        assert(c);        prefix = strempty(prefix);        fprintf(f,                "%sKillMode: %s/n"                "%sKillSignal: SIG%s/n"                "%sSendSIGKILL: %s/n"                "%sSendSIGHUP:  %s/n",                prefix, kill_mode_to_string(c->kill_mode),                prefix, signal_to_string(c->kill_signal),                prefix, yes_no(c->send_sigkill),                prefix, yes_no(c->send_sighup));}
开发者ID:dankor,项目名称:systemd,代码行数:15,


示例16: audit_callback

/*   Any time an access gets denied this callback will be called   with the aduit 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;        sd_bus_creds_get_audit_login_uid(audit->creds, &login_uid);        sd_bus_creds_get_uid(audit->creds, &uid);        sd_bus_creds_get_gid(audit->creds, &gid);        snprintf(msgbuf, msgbufsize,                 "auid=%d uid=%d gid=%d%s%s%s%s%s%s",                 login_uid, uid, gid,                 audit->path ? " path=/"" : "", strempty(audit->path), audit->path ? "/"" : "",                 audit->cmdline ? " cmdline=/"" : "", strempty(audit->cmdline), audit->cmdline ? "/"" : "");        msgbuf[msgbufsize-1] = 0;        return 0;}
开发者ID:MOBO-OSS,项目名称:systemd-relative,代码行数:28,


示例17: sysctl_write_ip_property

int sysctl_write_ip_property(int af, const char *ifname, const char *property, const char *value) {        const char *p;        assert(IN_SET(af, AF_INET, AF_INET6));        assert(property);        assert(value);        p = strjoina("/proc/sys/net/ipv", af == AF_INET ? "4" : "6",                     ifname ? "/conf/" : "", strempty(ifname),                     property[0] == '/' ? "" : "/", property);        log_debug("Setting '%s' to '%s'", p, value);        return write_string_file(p, value, WRITE_STRING_FILE_VERIFY_ON_FAILURE | WRITE_STRING_FILE_DISABLE_BUFFER);}
开发者ID:clemensg,项目名称:systemd,代码行数:15,


示例18: audit_callback

/*   Any time an access gets denied this callback will be called   with the aduit 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) {        struct auditstruct *audit = (struct auditstruct *) auditdata;        snprintf(msgbuf, msgbufsize,                 "auid=%d uid=%d gid=%d%s%s%s%s%s%s",                 audit->loginuid,                 audit->uid,                 audit->gid,                 (audit->path ? " path=/"" : ""),                 strempty(audit->path),                 (audit->path ? "/"" : ""),                 (audit->cmdline ? " cmdline=/"" : ""),                 strempty(audit->cmdline),                 (audit->cmdline ? "/"" : ""));        msgbuf[msgbufsize-1] = 0;        return 0;}
开发者ID:felipec,项目名称:udev-fc,代码行数:28,


示例19: test_mount_points_list

static void test_mount_points_list(const char *fname) {        _cleanup_(mount_points_list_free) LIST_HEAD(MountPoint, mp_list_head);        MountPoint *m;        log_info("/* %s(/"%s/") */", __func__, fname ?: "/proc/self/mountinfo");        LIST_HEAD_INIT(mp_list_head);        assert_se(mount_points_list_get(fname, &mp_list_head) >= 0);        LIST_FOREACH(mount_point, m, mp_list_head)                log_debug("path=%s o=%s f=0x%lx try-ro=%s dev=%u:%u",                          m->path,                          strempty(m->remount_options),                          m->remount_flags,                          yes_no(m->try_remount_ro),                          major(m->devnum), minor(m->devnum));}
开发者ID:Hariprasathganesh,项目名称:testsysd,代码行数:17,


示例20: mount_legacy_cgroup_hierarchy

static int mount_legacy_cgroup_hierarchy(                const char *dest,                const char *controller,                const char *hierarchy,                bool read_only) {        const char *to, *fstype, *opts;        int r;        to = strjoina(strempty(dest), "/sys/fs/cgroup/", hierarchy);        r = path_is_mount_point(to, dest, 0);        if (r < 0 && r != -ENOENT)                return log_error_errno(r, "Failed to determine if %s is mounted already: %m", to);        if (r > 0)                return 0;        mkdir_p(to, 0755);        /* The superblock mount options of the mount point need to be         * identical to the hosts', and hence writable... */        if (streq(controller, SYSTEMD_CGROUP_CONTROLLER_HYBRID)) {                fstype = "cgroup2";                opts = NULL;        } else if (streq(controller, SYSTEMD_CGROUP_CONTROLLER_LEGACY)) {                fstype = "cgroup";                opts = "none,name=systemd,xattr";        } else {                fstype = "cgroup";                opts = controller;        }        r = mount_verbose(LOG_ERR, "cgroup", to, fstype, MS_NOSUID|MS_NOEXEC|MS_NODEV, opts);        if (r < 0)                return r;        /* ... hence let's only make the bind mount read-only, not the superblock. */        if (read_only) {                r = mount_verbose(LOG_ERR, NULL, to, NULL,                                  MS_BIND|MS_REMOUNT|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY, NULL);                if (r < 0)                        return r;        }        return 1;}
开发者ID:halfline,项目名称:systemd,代码行数:46,


示例21: test_unhexmem_one

static void test_unhexmem_one(const char *s, size_t l, int retval) {        _cleanup_free_ char *hex = NULL;        _cleanup_free_ void *mem = NULL;        size_t len;        assert_se(unhexmem(s, l, &mem, &len) == retval);        if (retval == 0) {                char *answer;                if (l == (size_t) -1)                        l = strlen(s);                assert_se(hex = hexmem(mem, len));                answer = strndupa(strempty(s), l);                assert_se(streq(delete_chars(answer, WHITESPACE), hex));        }}
开发者ID:Keruspe,项目名称:systemd,代码行数:17,


示例22: load_env_file_push

static int load_env_file_push(const char *key, char *value, void *userdata) {        char ***m = userdata;        char *p;        int r;        p = strjoin(key, "=", strempty(value), NULL);        if (!p)                return -ENOMEM;        r = strv_push(m, p);        if (r < 0) {                free(p);                return r;        }        free(value);        return 0;}
开发者ID:Miss6yka,项目名称:systemd,代码行数:18,


示例23: server_forward_wall

void server_forward_wall(                Server *s,                int priority,                const char *identifier,                const char *message,                const struct ucred *ucred) {        _cleanup_free_ char *ident_buf = NULL, *l_buf = NULL;        const char *l;        int r;        assert(s);        assert(message);        if (LOG_PRI(priority) > s->max_level_wall)                return;        if (ucred) {                if (!identifier) {                        get_process_comm(ucred->pid, &ident_buf);                        identifier = ident_buf;                }                if (asprintf(&l_buf, "%s["PID_FMT"]: %s", strempty(identifier), ucred->pid, message) < 0) {                        log_oom();                        return;                }                l = l_buf;        } else if (identifier) {                l = l_buf = strjoin(identifier, ": ", message, NULL);                if (!l_buf) {                        log_oom();                        return;                }        } else                l = message;        r = utmp_wall(l, "systemd-journald", NULL, NULL, NULL);        if (r < 0)                log_debug_errno(r, "Failed to send wall message: %m");}
开发者ID:AOSC-Dev,项目名称:systemd,代码行数:44,


示例24: specifier_instance

static int specifier_instance(char specifier, void *data, void *userdata, char **ret) {        const UnitFileInstallInfo *i = userdata;        char *instance;        int r;        assert(i);        r = unit_name_to_instance(i->name, &instance);        if (r < 0)                return r;        if (isempty(instance)) {                r = free_and_strdup(&instance, strempty(i->default_instance));                if (r < 0)                        return r;        }        *ret = instance;        return 0;}
开发者ID:Werkov,项目名称:systemd,代码行数:20,


示例25: sysctl_read_ip_property

int sysctl_read_ip_property(int af, const char *ifname, const char *property, char **ret) {        _cleanup_free_ char *value = NULL;        const char *p;        int r;        assert(IN_SET(af, AF_INET, AF_INET6));        assert(property);        p = strjoina("/proc/sys/net/ipv", af == AF_INET ? "4" : "6",                     ifname ? "/conf/" : "", strempty(ifname),                     property[0] == '/' ? "" : "/", property);        r = read_one_line_file(p, &value);        if (r < 0)                return r;        if (ret)                *ret = TAKE_PTR(value);        return r;}
开发者ID:clemensg,项目名称:systemd,代码行数:21,


示例26: setup_monitor

static int setup_monitor(MonitorNetlinkGroup sender, sd_event *event, sd_device_monitor **ret) {        _cleanup_(sd_device_monitor_unrefp) sd_device_monitor *monitor = NULL;        const char *subsystem, *devtype, *tag;        Iterator i;        int r;        r = device_monitor_new_full(&monitor, sender, -1);        if (r < 0)                return log_error_errno(r, "Failed to create netlink socket: %m");        (void) sd_device_monitor_set_receive_buffer_size(monitor, 128*1024*1024);        r = sd_device_monitor_attach_event(monitor, event);        if (r < 0)                return log_error_errno(r, "Failed to attach event: %m");        HASHMAP_FOREACH_KEY(devtype, subsystem, arg_subsystem_filter, i) {                r = sd_device_monitor_filter_add_match_subsystem_devtype(monitor, subsystem, devtype);                if (r < 0)                        return log_error_errno(r, "Failed to apply subsystem filter '%s%s%s': %m",                                               subsystem, devtype ? "/" : "", strempty(devtype));        }
开发者ID:tblume,项目名称:systemd-testsuite-suse,代码行数:22,


示例27: Get

/*	Get()*/LPCSTR CUrlService::Get(	UINT		nID,					LPSTR	lpszUrl,					int		nUrlSize,					LPSTR	lpszParentUrl,					int		nParentUrlSize,					CUrlStatus::URL_STATUS& nStat					){	char* p = NULL;	nStat = CUrlStatus::URL_STATUS_UNKNOWN;	memset(lpszUrl,'/0',nUrlSize);	memset(lpszParentUrl,'/0',nParentUrlSize);	if(m_bIsValid)	{		// sincronizza l'accesso alla tabella		if(m_mutexTable.Lock())		{			// cerca il valore richesto			if(m_pUrlTable->Seek((int)nID,URL_IDX_ID))			{				m_pUrlTable->ScatterMemvars();								strcpyn(lpszUrl,(char*)m_pUrlTable->GetField_Url(),nUrlSize);				if(!strempty(lpszUrl))				{					strcpyn(lpszParentUrl,(char*)m_pUrlTable->GetField_ParentUrl(),nParentUrlSize);					p = lpszUrl;					nStat = (CUrlStatus::URL_STATUS)m_pUrlTable->GetField_Stat();				}			}			m_mutexTable.Unlock();		}	}	return(p);}
开发者ID:code4bones,项目名称:crawlpaper,代码行数:41,


示例28: fopen

/** * Open and read an initialization file, putting the information * therein into a newly-allocated object of type Ini. * * @param[in] ifname Name of input file * * @returns Newly-allocate Ini object containing info from input file. */Ini        *Ini_new(const char *ifname) {    FILE       *ifp = fopen(ifname, "r");    int         inPopHist = 0;    if(ifp == NULL)        return NULL;    Ini        *ini = malloc(sizeof(Ini));    checkmem(ini, __FILE__, __LINE__);    memset(ini, 0, sizeof(Ini));    ini->a = NULL;    ini->epochList = NULL;    Tokenizer  *tkz = Tokenizer_new(100);    char        buff[1000];    int         lineno = 0, ntokens;    while(fgets(buff, sizeof(buff), ifp) != NULL) {        ++lineno;        if(!strchr(buff, '/n') && !feof(ifp))            eprintf("[email
C++ strend函数代码示例
C++ strecpy函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。