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

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

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

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

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

示例1: moduleDelData

/** * Delete the key/value pair indicated by "key" for the current module. * This allows module coders to remove a previously stored key/value pair. * @param md The module data for the struct to be used * @param key The key to delete the key/value pair for **/void moduleDelData(ModuleData ** md, char *key){    char *mod_name = sstrdup(mod_current_module_name);    ModuleData *modcurrent = *md;    ModuleData *prev = NULL;    ModuleData *next = NULL;    SET_SEGV_LOCATION();    if (mod_current_module_name == NULL) {        alog(LOG_DEBUG,             "debug: moduleDelData() called with mod_current_module_name being NULL");        if (denora->debug) {            do_backtrace(0);        }    }    if (key) {        while (modcurrent) {            next = modcurrent->next;            if ((stricmp(modcurrent->moduleName, mod_name) == 0)                && (stricmp(modcurrent->key, key) == 0)) {                if (prev) {                    prev->next = modcurrent->next;                } else {                    *md = modcurrent->next;                }                free(modcurrent->moduleName);                free(modcurrent->key);                free(modcurrent->value);                modcurrent->next = NULL;                free(modcurrent);            } else {                prev = modcurrent;            }            prev = modcurrent;            modcurrent = next;        }    }    free(mod_name);}
开发者ID:wodim,项目名称:irc-hispano,代码行数:47,


示例2: snprintf

static database_handle_t *opensex_db_open_write(const char *filename){	database_handle_t *db;	opensex_t *rs;	int fd;	FILE *f;	int errno1;	char bpath[BUFSIZE], path[BUFSIZE];	snprintf(bpath, BUFSIZE, "%s/%s", datadir, filename != NULL ? filename : "services.db");	mowgli_strlcpy(path, bpath, sizeof path);	mowgli_strlcat(path, ".new", sizeof path);	fd = open(path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);	if (fd < 0 || ! (f = fdopen(fd, "w")))	{		errno1 = errno;		slog(LG_ERROR, "db-open-write: cannot open '%s' for writing: %s", path, strerror(errno1));		wallops(_("/2DATABASE ERROR/2: db-open-write: cannot open '%s' for writing: %s"), path, strerror(errno1));		return NULL;	}	rs = scalloc(sizeof(opensex_t), 1);	rs->f = f;	rs->grver = 1;	db = scalloc(sizeof(database_handle_t), 1);	db->priv = rs;	db->vt = &opensex_vt;	db->txn = DB_WRITE;	db->file = sstrdup(bpath);	db->line = 0;	db->token = 0;	db_start_row(db, "GRVER");	db_write_int(db, rs->grver);	db_commit_row(db);	return db;}
开发者ID:Gryllida,项目名称:atheme,代码行数:41,


示例3: loadConfParam

int loadConfParam(char *name, char *defaultVal, char **ptr){	char *tmp = NULL;	Directive directivas[] = {		{name, {{PARAM_STRING, PARAM_RELOAD, &tmp}}},	};	Directive *d = &directivas[0];	moduleGetConfigDirective(d);	if (tmp) {		*ptr = tmp;	} else {		*ptr = sstrdup(defaultVal);	}	alog("ns_qdbban: Directive %s loaded (%s)...", name, *ptr);	return 0;}
开发者ID:GeekShed,项目名称:anope-modules,代码行数:21,


示例4: denora_event_server

/* (AB S trystan.nomadirc.net 2 0 1106520454 P10 ACAP] +h :Test Server) */int denora_event_server(char *source, int ac, char **av){    Server *s;    char uplinknum[3];    if (denora->protocoldebug) {        protocol_debug(source, ac, av);    }    *uplinknum = '/0';    strlcpy(uplinknum, av[5], sizeof(uplinknum));    if (!stricmp(av[1], "1")) {        denora->uplink = sstrdup(av[0]);        do_server(source, av[0], av[1], av[7], uplinknum);    } else {        s = server_find(source);        do_server((s ? s->name : source), av[0], av[1], av[7], uplinknum);    }    return MOD_CONT;}
开发者ID:danopia,项目名称:denora,代码行数:22,


示例5: _modinit

void _modinit(module_t *m){	MODULE_TRY_REQUEST_SYMBOL(m, httpd_path_handlers, "misc/httpd", "httpd_path_handlers");	hook_add_event("config_ready");	hook_add_config_ready(xmlrpc_config_ready);	xmlrpc_config.path = sstrdup("/xmlrpc");	add_subblock_top_conf("XMLRPC", &conf_xmlrpc_table);	add_dupstr_conf_item("PATH", &conf_xmlrpc_table, 0, &xmlrpc_config.path, NULL);	xmlrpc_set_buffer(dump_buffer);	xmlrpc_set_options(XMLRPC_HTTP_HEADER, XMLRPC_OFF);	xmlrpc_register_method("atheme.login", xmlrpcmethod_login);	xmlrpc_register_method("atheme.logout", xmlrpcmethod_logout);	xmlrpc_register_method("atheme.command", xmlrpcmethod_command);	xmlrpc_register_method("atheme.privset", xmlrpcmethod_privset);	xmlrpc_register_method("atheme.ison", xmlrpcmethod_ison);	xmlrpc_register_method("atheme.metadata", xmlrpcmethod_metadata);}
开发者ID:Canternet,项目名称:atheme,代码行数:21,


示例6: do_export

static int do_export(User * u, int ac, char **av){    char *filename = NULL;    if (ac < 1) {        syntax_error(s_StatServ, u, "EXPORT", STATS_EXPORT_SYNTAX);        return MOD_CONT;    }    if (!stricmp("channels", av[0])) {        filename = sstrdup("channels.xml");        xml_export_channels(filename);        notice_lang(s_StatServ, u, STATS_EXPORT_CHANNELS, "channels.xml");    } else if (!stricmp("users", av[0])) {        filename = sstrdup("users.xml");        xml_export_users(filename);        notice_lang(s_StatServ, u, STATS_EXPORT_USERS, "users.xml");    } else if (!stricmp("tld", av[0])) {        filename = sstrdup("tld.xml");        xml_export_tld(filename);        notice_lang(s_StatServ, u, STATS_EXPORT_TLD, "tld.xml");    } else if (!stricmp("servers", av[0])) {        filename = sstrdup("servers.xml");        xml_export_servers(filename);        notice_lang(s_StatServ, u, STATS_EXPORT_SERVERS, "servers.xml");    } else if (!stricmp("stats", av[0])) {        filename = sstrdup("stats.xml");        xml_export_stats(filename);        notice_lang(s_StatServ, u, STATS_EXPORT_STATS, "stats.xml");    } else if (!stricmp("all", av[0])) {        filename = sstrdup("denora.xml");        xml_export_all(filename);        notice_lang(s_StatServ, u, STATS_EXPORT_ALL, "denora.xml");    } else if (!stricmp("ctcp", av[0])) {        filename = sstrdup("ctcp.xml");        xml_export_ctcp(filename);        notice_lang(s_StatServ, u, STATS_EXPORT_ALL, "ctcp.xml");    } else {        syntax_error(s_StatServ, u, "EXPORT", STATS_EXPORT_SYNTAX);    }    free(filename);    return MOD_CONT;}
开发者ID:danopia,项目名称:denora,代码行数:42,


示例7: makedir

int makedir(char *d){  char temp[PATHLEN];  int x;  for (*temp='/0';;)  {    if (!do_unattended)    {      printf("/rCreate dir `%s' [Y,n]? ",d);      fgets(temp,PATHLEN,stdin);      Strip_Trailing(temp, '/n');      *temp=(char)toupper(*temp);      Compiling(-1, NULL, NULL);    }    if (do_unattended || *temp=='Y' || *temp=='/n' || *temp=='/0')    {      char *fn;      printf("/rCreating directory `%s'/n", d);      Compiling(-1, NULL, NULL);      fn=sstrdup(d);      Strip_Trailing(fn, PATH_DELIM);      x=make_dir(fn);      free(fn);      return x;    }    else if (*temp=='N')      return 0;  }}
开发者ID:klamonte,项目名称:maximus,代码行数:39,


示例8: nefarious_cmd_join

/* ABAAB J #ircops 1098031328 */void nefarious_cmd_join(char *user, char *channel, time_t chantime){    Uid *ud;    char *modes = NULL;    ud = find_uid(user);    if (started) {        send_cmd((ud ? ud->uid : user), "J %s %ld", channel,                 (long int) chantime);    } else {        if (AutoOp && AutoMode) {            modes = sstrdup(AutoMode);            modes++;            /* since the first char is +, we skip it */            send_cmd(p10id, "B %s %ld %s:%s", channel,                     (long int) chantime, (ud ? ud->uid : user), modes);        } else {            send_cmd(p10id, "B %s %ld %s", channel,                     (long int) chantime, (ud ? ud->uid : user));        }    }}
开发者ID:danopia,项目名称:denora,代码行数:23,


示例9: helpserv

void helpserv(const char *whoami, const char *source, char *buf){    char *cmd, *topic, *s;#if defined(IRC_UNDERNET_P10)    User *u = finduser(source);        if (!u)        return;#endif            topic = buf ? sstrdup(buf) : NULL;    cmd = strtok(buf, " ");    if (cmd && stricmp(cmd, "/1PING") == 0) {	if (!(s = strtok(NULL, "")))	    s = "/1";#if defined(IRC_UNDERNET_P10)	notice(s_HelpServ, u->numerico, "/1PING %s", s);    } else {        do_help(whoami, u->numerico, topic);    #else        notice(s_HelpServ, source, "/1PING %s", s);    } else if (stricmp(cmd, "/1VERSION/1") == 0) {
开发者ID:LuizEnciso,项目名称:services-bdd,代码行数:22,


示例10: basic_aggregator_config

static intbasic_aggregator_config (const char *key, const char *value){		int status=0;		if (strcasecmp ("Aggregators_config_file", key) == 0)		{				if(configuration_filename) sfree (configuration_filename);				configuration_filename = sstrdup (value);		}		else		{				ERROR (OUTPUT_PREFIX_STRING "Unknown config option: %s", key);				return (-1);		}		if(NULL == configuration_filename) {				ERROR (OUTPUT_PREFIX_STRING "No configuration filename 'Aggregators_config_file' was set in the collectd config file");				return(-1);		}		return (status);}
开发者ID:sseshachala,项目名称:xervmon_collectd_pw,代码行数:22,


示例11: match_userip

int match_userip(const char *mask, User * user, char *iphost){    char *mask2;    char *nick, *username, *host;    int result;    if (!mask || !*mask) {        return 0;    }    mask2 = sstrdup(mask);    if (strchr(mask2, '!')) {        nick = strtok(mask2, "!");        username = strtok(NULL, "@");    } else {        nick = NULL;        username = strtok(mask2, "@");    }    host = strtok(NULL, "");    if (!username || !host) {        free(mask2);        return 0;    }    if (nick) {        result = match_wild_nocase(nick, user->nick)            && match_wild_nocase(username, user->username)            && (match_wild_nocase(host, iphost)                || match_wild_nocase(host, user->vhost));    } else {        result = match_wild_nocase(username, user->username)            && (match_wild_nocase(host, iphost)                || match_wild_nocase(host, user->vhost));    }    free(mask2);    return result;}
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:39,


示例12: addEventHook

/** * Add a message to the MessageHash. * @param msgTable the MessageHash we want to add a message to * @param m the Message we want to add * @return MOD_ERR_OK on a successful add. **/int addEventHook(EvtHookHash * hookEvtTable[], EvtHook * evh){    /* We can assume both param's have been checked by this point.. */    int index = 0;    EvtHookHash *current = NULL;    EvtHookHash *newHash = NULL;    EvtHookHash *lastHash = NULL;    if (!hookEvtTable || !evh) {        return MOD_ERR_PARAMS;    }    index = CMD_HASH(evh->name);    for (current = hookEvtTable[index]; current; current = current->next) {        if (stricmp(evh->name, current->name) == 0) {   /* the msg exist's we are a addHead */            evh->next = current->evh;            current->evh = evh;            if (debug)                alog("debug: existing msg: (0x%p), new msg (0x%p)",                     (void *) evh->next, (void *) evh);            return MOD_ERR_OK;        }        lastHash = current;    }    if ((newHash = malloc(sizeof(EvtHookHash))) == NULL) {        fatal("Out of memory");    }    newHash->next = NULL;    newHash->name = sstrdup(evh->name);    newHash->evh = evh;    if (lastHash == NULL)        hookEvtTable[index] = newHash;    else        lastHash->next = newHash;    return MOD_ERR_OK;}
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:45,


示例13: do_nickupdate

/** * The /ns update command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/static int do_nickupdate(User * u){    NickAlias *na;    if (!nick_identified(u)) {        notice_lang(s_NickServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);    } else {        na = u->na;        do_setmodes(u);        check_memos(u);        if (na->last_realname)            free(na->last_realname);        na->last_realname = sstrdup(u->realname);        na->status |= NS_IDENTIFIED;        na->last_seen = time(NULL);        if (ircd->vhost) {            do_on_id(u);        }        notice_lang(s_NickServ, u, NICK_UPDATE_SUCCESS, s_NickServ);    }    return MOD_CONT;}
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:27,


示例14: log_err

static c_psql_database_t *c_psql_database_new (const char *name){	c_psql_database_t *db;	db = (c_psql_database_t *)malloc (sizeof (*db));	if (NULL == db) {		log_err ("Out of memory.");		return NULL;	}	db->conn = NULL;	C_COMPLAIN_INIT (&db->conn_complaint);	db->proto_version = 0;	db->server_version = 0;	db->max_params_num = 0;	db->q_prep_areas   = NULL;	db->queries        = NULL;	db->queries_num    = 0;	db->interval   = 0;	db->database   = sstrdup (name);	db->host       = NULL;	db->port       = NULL;	db->user       = NULL;	db->password   = NULL;	db->sslmode    = NULL;	db->krbsrvname = NULL;	db->service    = NULL;	return db;} /* c_psql_database_new */
开发者ID:ceph,项目名称:collectd-4.10.1,代码行数:38,


示例15: sizeof

static c_psql_database_t *c_psql_database_new (const char *name){	c_psql_database_t *db;	++databases_num;	if (NULL == (databases = (c_psql_database_t *)realloc (databases,				databases_num * sizeof (*databases)))) {		log_err ("Out of memory.");		exit (5);	}	db = databases + (databases_num - 1);	db->conn = NULL;	C_COMPLAIN_INIT (&db->conn_complaint);	db->proto_version = 0;	db->server_version = 0;	db->max_params_num = 0;	db->queries        = NULL;	db->queries_num    = 0;	db->database   = sstrdup (name);	db->host       = NULL;	db->port       = NULL;	db->user       = NULL;	db->password   = NULL;	db->sslmode    = NULL;	db->krbsrvname = NULL;	db->service    = NULL;	return db;} /* c_psql_database_new */
开发者ID:absperf,项目名称:collectd,代码行数:38,


示例16: moduleAddEventHook

/** * Add a module message to the IRCD message hash * @param m the Message to add * @param pos the Position to add the message to, e.g. MOD_HEAD, MOD_TAIL, MOD_UNIQUE * @return MOD_ERR_OK on success, althing else on fail. **/int moduleAddEventHook(EvtHook * evh){    int status;    if (!evh) {        return MOD_ERR_PARAMS;    }    if (!mod_current_module) {        return MOD_ERR_UNKNOWN;    }                           /* shouldnt happen */    evh->core = 0;    if (!evh->mod_name) {        evh->mod_name = sstrdup(mod_current_module->name);    }    status = addEventHook(EVENTHOOKS, evh);    if (debug) {        displayHookFromHash(evh->name);    }    return status;}
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:29,


示例17: moduleAddEventHandler

/** * Add a module message to the IRCD message hash * @param m the Message to add * @param pos the Position to add the message to, e.g. MOD_HEAD, MOD_TAIL, MOD_UNIQUE * @return MOD_ERR_OK on success, althing else on fail. **/int moduleAddEventHandler(EvtMessage * evm){    int status;    if (!evm) {        return MOD_ERR_PARAMS;    }    if (!mod_current_module) {        return MOD_ERR_UNKNOWN;    }                           /* shouldnt happen */    evm->core = 0;    if (!evm->mod_name) {        evm->mod_name = sstrdup(mod_current_module->name);    }    status = addEventHandler(EVENT, evm);    if (debug) {        displayEvtMessageFromHash(evm->name);    }    return status;}
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:29,


示例18: denora_event_capab

/* Event: PROTOCTL */int denora_event_capab(char *source, int ac, char **av){    int argc = 5;    char *argv[5];    if (strcasecmp(av[0], "START") == 0) {        /* reset CAPAB */        has_globopsmod = 0;    } else if (strcasecmp(av[0], "MODULES") == 0               && strstr(av[1], "m_globops.so")) {        has_globopsmod = 1;    } else if (strcasecmp(av[0], "END") == 0) {        if (has_globopsmod == 0) {            send_cmd(NULL,                     "ERROR :m_globops.so is not loaded. This is required by Denora");            denora->qmsg =                sstrdup                ("Remote server does not have the m_globops.so module loaded, and this is required.");            denora->quitting = 1;            return MOD_STOP;        }        /* Generate a fake capabs parsing call so things like NOQUIT work         * fine. It's ugly, but it works....         */        argv[0] = sstrdup("NOQUIT");        argv[1] = sstrdup("SSJ3");        argv[2] = sstrdup("NICK2");        argv[3] = sstrdup("VL");        argv[4] = sstrdup("TLKEXT");        capab_parse(argc, argv);        free(argv[0]);        free(argv[1]);        free(argv[2]);        free(argv[3]);        free(argv[4]);    }    return MOD_CONT;}
开发者ID:danopia,项目名称:denora,代码行数:42,


示例19: GetSystemInfo

/** * Return the CPU architecture * @return char that needs to be free'd */char *WindowsCPUArchitecture(void){    SYSTEM_INFO si;    char buf[BUFSIZE];    char *cpuarch;    GetSystemInfo(&si);    if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {        cpuarch = sstrdup("x64 (AMD or Intel)");    } else if (si.wProcessorArchitecture ==               PROCESSOR_ARCHITECTURE_IA32_ON_WIN64) {        cpuarch = sstrdup("Emmulation /"WOW64/"");    } else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {        cpuarch = sstrdup("Intel Itanium Processor Family (IPF)");    } else if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) {        cpuarch = sstrdup("x86");    } else {        cpuarch = sstrdup("Unknown processor");    }    ircsnprintf(buf, sizeof(buf), "arch: %s  number %d", cpuarch,                si.dwNumberOfProcessors);    return sstrdup(buf);}
开发者ID:danopia,项目名称:denora,代码行数:27,


示例20: ds_get

static int ds_get (char ***ret, /* {{{ */                   const data_set_t *ds, const value_list_t *vl,                   const rrdcreate_config_t *cfg){    char **ds_def;    int ds_num;    char min[32];    char max[32];    char buffer[128];    ds_def = (char **) malloc (ds->ds_num * sizeof (char *));    if (ds_def == NULL)    {        char errbuf[1024];        ERROR ("rrdtool plugin: malloc failed: %s",               sstrerror (errno, errbuf, sizeof (errbuf)));        return (-1);    }    memset (ds_def, '/0', ds->ds_num * sizeof (char *));    for (ds_num = 0; ds_num < ds->ds_num; ds_num++)    {        data_source_t *d = ds->ds + ds_num;        char *type;        int status;        ds_def[ds_num] = NULL;        if (d->type == DS_TYPE_COUNTER)            type = "COUNTER";        else if (d->type == DS_TYPE_GAUGE)            type = "GAUGE";        else if (d->type == DS_TYPE_DERIVE)            type = "DERIVE";        else if (d->type == DS_TYPE_ABSOLUTE)            type = "ABSOLUTE";        else        {            ERROR ("rrdtool plugin: Unknown DS type: %i",                   d->type);            break;        }        if (isnan (d->min))        {            sstrncpy (min, "U", sizeof (min));        }        else            ssnprintf (min, sizeof (min), "%f", d->min);        if (isnan (d->max))        {            sstrncpy (max, "U", sizeof (max));        }        else            ssnprintf (max, sizeof (max), "%f", d->max);        status = ssnprintf (buffer, sizeof (buffer),                            "DS:%s:%s:%i:%s:%s",                            d->name, type,                            (cfg->heartbeat > 0) ? cfg->heartbeat : (2 * vl->interval),                            min, max);        if ((status < 1) || ((size_t) status >= sizeof (buffer)))            break;        ds_def[ds_num] = sstrdup (buffer);    } /* for ds_num = 0 .. ds->ds_num */    if (ds_num != ds->ds_num)    {        ds_free (ds_num, ds_def);        return (-1);    }    *ret = ds_def;    return (ds_num);} /* }}} int ds_get */
开发者ID:xchenum,项目名称:collectd,代码行数:78,


示例21: rra_get

/* * * * * * * * * * * WARNING:  Magic * * * * * * * * * * */static int rra_get (char ***ret, const value_list_t *vl, /* {{{ */                    const rrdcreate_config_t *cfg){    char **rra_def;    int rra_num;    int *rts;    int  rts_num;    int rra_max;    int span;    int cdp_num;    int cdp_len;    int i, j;    char buffer[128];    /* The stepsize we use here: If it is user-set, use it. If not, use the     * interval of the value-list. */    int ss;    if (cfg->rrarows <= 0)    {        *ret = NULL;        return (-1);    }    if ((cfg->xff < 0) || (cfg->xff >= 1.0))    {        *ret = NULL;        return (-1);    }    ss = (cfg->stepsize > 0) ? cfg->stepsize : vl->interval;    if (ss <= 0)    {        *ret = NULL;        return (-1);    }    /* Use the configured timespans or fall back to the built-in defaults */    if (cfg->timespans_num != 0)    {        rts = cfg->timespans;        rts_num = cfg->timespans_num;    }    else    {        rts = rra_timespans;        rts_num = rra_timespans_num;    }    rra_max = rts_num * rra_types_num;    if ((rra_def = (char **) malloc ((rra_max + 1) * sizeof (char *))) == NULL)        return (-1);    memset (rra_def, '/0', (rra_max + 1) * sizeof (char *));    rra_num = 0;    cdp_len = 0;    for (i = 0; i < rts_num; i++)    {        span = rts[i];        if ((span / ss) < cfg->rrarows)            span = ss * cfg->rrarows;        if (cdp_len == 0)            cdp_len = 1;        else            cdp_len = (int) floor (((double) span)                                   / ((double) (cfg->rrarows * ss)));        cdp_num = (int) ceil (((double) span)                              / ((double) (cdp_len * ss)));        for (j = 0; j < rra_types_num; j++)        {            int status;            if (rra_num >= rra_max)                break;            status = ssnprintf (buffer, sizeof (buffer), "RRA:%s:%.10f:%u:%u",                                rra_types[j], cfg->xff, cdp_len, cdp_num);            if ((status < 0) || ((size_t) status >= sizeof (buffer)))            {                ERROR ("rra_get: Buffer would have been truncated.");                continue;            }            rra_def[rra_num++] = sstrdup (buffer);        }    }//.........这里部分代码省略.........
开发者ID:xchenum,项目名称:collectd,代码行数:101,


示例22: handle_putval

int handle_putval (FILE *fh, char *buffer){	char *command;	char *identifier;	char *hostname;	char *plugin;	char *plugin_instance;	char *type;	char *type_instance;	int   status;	int   values_submitted;	char *identifier_copy;	const data_set_t *ds;	value_list_t vl = VALUE_LIST_INIT;	DEBUG ("utils_cmd_putval: handle_putval (fh = %p, buffer = %s);",			(void *) fh, buffer);	command = NULL;	status = parse_string (&buffer, &command);	if (status != 0)	{		print_to_socket (fh, "-1 Cannot parse command./n");		return (-1);	}	assert (command != NULL);	if (strcasecmp ("PUTVAL", command) != 0)	{		print_to_socket (fh, "-1 Unexpected command: `%s'./n", command);		return (-1);	}	identifier = NULL;	status = parse_string (&buffer, &identifier);	if (status != 0)	{		print_to_socket (fh, "-1 Cannot parse identifier./n");		return (-1);	}	assert (identifier != NULL);	/* parse_identifier() modifies its first argument,	 * returning pointers into it */	identifier_copy = sstrdup (identifier);	status = parse_identifier (identifier_copy, &hostname,			&plugin, &plugin_instance,			&type, &type_instance);	if (status != 0)	{		DEBUG ("handle_putval: Cannot parse identifier `%s'.",				identifier);		print_to_socket (fh, "-1 Cannot parse identifier `%s'./n",				identifier);		sfree (identifier_copy);		return (-1);	}	if ((strlen (hostname) >= sizeof (vl.host))			|| (strlen (plugin) >= sizeof (vl.plugin))			|| ((plugin_instance != NULL)				&& (strlen (plugin_instance) >= sizeof (vl.plugin_instance)))			|| ((type_instance != NULL)				&& (strlen (type_instance) >= sizeof (vl.type_instance))))	{		print_to_socket (fh, "-1 Identifier too long./n");		sfree (identifier_copy);		return (-1);	}	sstrncpy (vl.host, hostname, sizeof (vl.host));	sstrncpy (vl.plugin, plugin, sizeof (vl.plugin));	sstrncpy (vl.type, type, sizeof (vl.type));	if (plugin_instance != NULL)		sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance));	if (type_instance != NULL)		sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));	ds = plugin_get_ds (type);	if (ds == NULL) {		print_to_socket (fh, "-1 Type `%s' isn't defined./n", type);		sfree (identifier_copy);		return (-1);	}	/* Free identifier_copy */	hostname = NULL;	plugin = NULL; plugin_instance = NULL;	type = NULL;   type_instance = NULL;	sfree (identifier_copy);	vl.values_len = ds->ds_num;	vl.values = (value_t *) malloc (vl.values_len * sizeof (value_t));	if (vl.values == NULL)	{		print_to_socket (fh, "-1 malloc failed./n");		return (-1);//.........这里部分代码省略.........
开发者ID:KIvosak,项目名称:collectd,代码行数:101,


示例23: log_err

static c_psql_database_t *c_psql_database_new (const char *name){	c_psql_database_t **tmp;	c_psql_database_t  *db;	db = (c_psql_database_t *)malloc (sizeof(*db));	if (NULL == db) {		log_err ("Out of memory.");		return NULL;	}	tmp = (c_psql_database_t **)realloc (databases,			(databases_num + 1) * sizeof (*databases));	if (NULL == tmp) {		log_err ("Out of memory.");		sfree (db);		return NULL;	}	databases = tmp;	databases[databases_num] = db;	++databases_num;	db->conn = NULL;	C_COMPLAIN_INIT (&db->conn_complaint);	db->proto_version = 0;	db->server_version = 0;	db->max_params_num = 0;	db->q_prep_areas   = NULL;	db->queries        = NULL;	db->queries_num    = 0;	db->writers        = NULL;	db->writers_num    = 0;	pthread_mutex_init (&db->db_lock, /* attrs = */ NULL);	db->interval   = 0;	db->commit_interval = 0;	db->next_commit     = 0;	db->database   = sstrdup (name);	db->host       = NULL;	db->port       = NULL;	db->user       = NULL;	db->password   = NULL;	db->instance   = sstrdup (name);	db->sslmode    = NULL;	db->krbsrvname = NULL;	db->service    = NULL;	db->ref_cnt    = 0;	return db;} /* c_psql_database_new */
开发者ID:BrianB2,项目名称:collectd,代码行数:63,


示例24: alog

//.........这里部分代码省略.........            add_akill(NULL, mask, s_OperServ,                      time(NULL) + dotime(DefConAKILL),                      DefConAkillReason ? DefConAkillReason :                      "DEFCON AKILL");            if (check_akill(nick, username, host, vhost, ipbuf)) {/*            return NULL; */            }        }        /* SGLINE */        if (ircd->sgline) {            if (check_sgline(nick, realname))                return NULL;        }        /* SQLINE */        if (ircd->sqline) {            if (check_sqline(nick, 0))                return NULL;        }        /* SZLINE */        if (ircd->szline && ircd->nickip) {            if (check_szline(nick, ipbuf))                return NULL;        }        /* Now check for session limits */        if (LimitSessions && !is_ulined(server)            && !add_session(nick, host, ipbuf))            return NULL;        /* Allocate User structure and fill it in. */        user = new_user(nick);        user->username = sstrdup(username);        user->host = sstrdup(host);        user->server = findserver(servlist, server);        user->realname = sstrdup(realname);        user->timestamp = ts;        user->my_signon = time(NULL);        user->chost = vhost ? sstrdup(vhost) : sstrdup(host);        user->vhost = vhost ? sstrdup(vhost) : sstrdup(host);        if (uid) {            user->uid = sstrdup(uid);   /* p10/ts6 stuff */        } else {            user->uid = NULL;        }        user->vident = sstrdup(username);        /* We now store the user's ip in the user_ struct,         * because we will use it in serveral places -- DrStein */        if (ircd->nickip) {            user->hostip = sstrdup(ipbuf);        } else {            user->hostip = NULL;        }        if (svid == 0) {            display_news(user, NEWS_LOGON);            display_news(user, NEWS_RANDOM);        }        if (svid == 2 && user->na) {            /* We do not yet know if the user should be identified or not.             * mark him as recognized for now.              * It s up to the protocol module to make sure this either becomes ID'd or             * is invalidated. ~ Viper */            if (debug) 
开发者ID:Elemental-IRCd,项目名称:anope,代码行数:67,


示例25: do_identify

/** * The /ns identify command. * @param u The user who issued the command * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. **/int do_identify(User * u){    char *pass = strtok(NULL, " ");    NickAlias *na;    NickRequest *nr;    int res;    char tsbuf[16];    char modes[512];    int len;    if (!pass) {        syntax_error(s_NickServ, u, "IDENTIFY", NICK_IDENTIFY_SYNTAX);    } else if (!(na = u->na)) {        if ((nr = findrequestnick(u->nick))) {            notice_lang(s_NickServ, u, NICK_IS_PREREG);        } else {            notice_lang(s_NickServ, u, NICK_NOT_REGISTERED);        }    } else if (na->status & NS_VERBOTEN) {        notice_lang(s_NickServ, u, NICK_X_FORBIDDEN, na->nick);    } else if (na->nc->flags & NI_SUSPENDED) {        notice_lang(s_NickServ, u, NICK_X_SUSPENDED, na->nick);    } else if (nick_identified(u)) {        notice_lang(s_NickServ, u, NICK_ALREADY_IDENTIFIED);    } else if (!(res = enc_check_password(pass, na->nc->pass))) {        alog("%s: Failed IDENTIFY for %s!%[email
C++ sstrerror函数代码示例
C++ sstrcpy函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。