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

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

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

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

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

示例1: load_drivers

static void load_drivers(void){    struct ibv_driver_name *name, *next_name;    const char *env;    char *list, *env_name;    /*     * Only use drivers passed in through the calling user's     * environment if we're not running setuid.     */    if (getuid() == geteuid()) {        if ((env = getenv("RDMAV_DRIVERS"))) {            list = strdupa(env);            while ((env_name = strsep(&list, ":;")))                load_driver(env_name);        } else if ((env = getenv("IBV_DRIVERS"))) {            list = strdupa(env);            while ((env_name = strsep(&list, ":;")))                load_driver(env_name);        }    }    for (name = driver_name_list, next_name = name ? name->next : NULL;            name;            name = next_name, next_name = name ? name->next : NULL) {        load_driver(name->name);        free(name->name);        free(name);    }}
开发者ID:CJacky,项目名称:virt-ib,代码行数:30,


示例2: parseCommandLine

void parseCommandLine(char* cmdLineTxt, char*** argv, int* argc){    int count = 1;	char *cmdLineCopy = strdupa(cmdLineTxt);	char* match = strtok(cmdLineCopy, " "); // First, count the number of arguments	while(match != NULL){        count++;        match = strtok(NULL, " ");	}    *argv = malloc(sizeof(char*) * (count+1));    (*argv)[count] = 0;    **argv = strdup("test"); // the program name would normally go in here    if (count > 1){        int i=1;        cmdLineCopy = strdupa(cmdLineTxt);        match = strtok(cmdLineCopy, " ");        do{            (*argv)[i++] = strdup(match);            match = strtok(NULL, " ");        } while(match != NULL);    }    *argc = count;}
开发者ID:JackWangCUMT,项目名称:bitmeteros,代码行数:27,


示例3: find_executable

std::string find_executable(const char *name){	struct stat s;	char *tmpPath = getenv("PATH");	char *p, *n, *path;	if (tmpPath)		path = strdupa(tmpPath);	else		path = strdupa("/bin:/var/bin:/sbin:/var/sbin");	if (name[0] == '/') { /* full path given */		if (!access(name, X_OK) && !stat(name, &s) && S_ISREG(s.st_mode))			return std::string(name);		return "";	}	p = path;	while (p) {		n = strchr(p, ':');		if (n)			*n++ = '/0';		if (*p != '/0') {			std::string tmp = std::string(p) + "/" + std::string(name);			const char *f = tmp.c_str();			if (!access(f, X_OK) && !stat(f, &s) && S_ISREG(s.st_mode))				return tmp;		}		p = n;	}	return "";}
开发者ID:UkCvs,项目名称:commando,代码行数:30,


示例4: test_string_erase

static void test_string_erase(void) {        char *x;        x = strdupa("");        assert_se(streq(string_erase(x), ""));        x = strdupa("1");        assert_se(streq(string_erase(x), "x"));        x = strdupa("12");        assert_se(streq(string_erase(x), "xx"));        x = strdupa("123");        assert_se(streq(string_erase(x), "xxx"));        x = strdupa("1234");        assert_se(streq(string_erase(x), "xxxx"));        x = strdupa("12345");        assert_se(streq(string_erase(x), "xxxxx"));        x = strdupa("123456");        assert_se(streq(string_erase(x), "xxxxxx"));        x = strdupa("1234567");        assert_se(streq(string_erase(x), "xxxxxxx"));        x = strdupa("12345678");        assert_se(streq(string_erase(x), "xxxxxxxx"));        x = strdupa("123456789");        assert_se(streq(string_erase(x), "xxxxxxxxx"));}
开发者ID:BenjaminLefoul,项目名称:systemd,代码行数:33,


示例5: _rg_write_meta

static int_rg_write_meta (DB_playItem_t *track) {    const char *path = NULL;    const char *decoder_id = NULL;    deadbeef->pl_lock ();    path = strdupa (deadbeef->pl_find_meta_raw (track, ":URI"));    int is_subtrack = deadbeef->pl_get_item_flags (track) & DDB_IS_SUBTRACK;    if (is_subtrack) {        trace ("rg_scanner: Can't write to subtrack of file: %s/n", path);        deadbeef->pl_unlock ();        return -1;    }    decoder_id = deadbeef->pl_find_meta_raw (track, ":DECODER");    if (!decoder_id) {        trace ("rg_scanner: Invalid decoder in track %s/n", path);        deadbeef->pl_unlock ();        return -1;    }    decoder_id = strdupa (decoder_id);    int match = track && decoder_id;    deadbeef->pl_unlock ();    if (match) {        int is_subtrack = deadbeef->pl_get_item_flags (track) & DDB_IS_SUBTRACK;        if (is_subtrack) {            return 0; // only write tags for actual tracks        }        // find decoder        DB_decoder_t *dec = NULL;        DB_decoder_t **decoders = deadbeef->plug_get_decoder_list ();        for (int i = 0; decoders[i]; i++) {            if (!strcmp (decoders[i]->plugin.id, decoder_id)) {                dec = decoders[i];                if (dec->write_metadata) {                    if (dec->write_metadata (track)) {                        trace ("rg_scanner: Failed to write tag to %s/n", path);                        return -1;                    }                }                else {                    trace ("rg_scanner: Writing tags is not supported for the file %s/n", path);                }                break;            }        }    }    else {        trace ("rg_scanner: Could not find matching decoder for %s/n", path);        return -1;    }    return 0;}
开发者ID:cboxdoerfer,项目名称:deadbeef,代码行数:54,


示例6: lwan_straitjacket_enforce

void lwan_straitjacket_enforce(config_t *c, config_line_t *l){    char *user_name = NULL;    char *chroot_path = NULL;    uid_t uid;    gid_t gid;    if (geteuid() != 0) {        config_error(c, "Straitjacket requires root privileges");        return;    }    while (config_read_line(c, l)) {        switch (l->type) {        case CONFIG_LINE_TYPE_LINE:            /* TODO: limit_syscalls */            if (!strcmp(l->line.key, "user")) {                user_name = strdupa(l->line.value);            } else if (!strcmp(l->line.key, "chroot")) {                chroot_path = strdupa(l->line.value);            } else {                config_error(c, "Invalid key: %s", l->line.key);                return;            }            break;        case CONFIG_LINE_TYPE_SECTION:            config_error(c, "Straitjacket accepts no sections");            return;        case CONFIG_LINE_TYPE_SECTION_END:            if (!get_user_uid_gid(user_name, &uid, &gid)) {                config_error(c, "Unknown user: %s", user_name);                return;            }            if (chroot_path) {                if (chroot(chroot_path) < 0) {                    lwan_status_critical_perror("Could not chroot() to %s",                        chroot_path);                }                lwan_status_debug("Jailed to %s", chroot_path);            }            if (!switch_to_user(uid, gid, user_name)) {                lwan_status_critical("Could not drop privileges to %s, aborting",                    user_name);            }            return;        }    }    config_error(c, "Expecting section end while parsing straitjacket");}
开发者ID:0x003e,项目名称:lwan,代码行数:52,


示例7: format_remote_host

/** * Format a QString with the MySQL host portion for a remote host.  The * resulting string will use the local subnet and mask to generate something * like "192.168.1.0/255.255.255.0" . * * @param host string with the hostname to use for the subnet and mask. * @return QString with formated result. **/QString format_remote_host(const char *hostname) {  struct in_addr local_netmask;  struct hostent *temp_hostent;  struct in_addr local_ip;  struct in_addr local_subnet;  temp_hostent=gethostbyname(hostname);  local_ip=*(struct in_addr *)temp_hostent->h_addr;  // FIXME: ideally do something smarter than just testing eth0 (see above in check_remote_server() also)  get_netmask("eth0", &local_netmask);  local_subnet.s_addr=(local_ip.s_addr & local_netmask.s_addr);  return QString().sprintf("%s/%s", strdupa(inet_ntoa(local_subnet)), strdupa(inet_ntoa(local_netmask)) );}
开发者ID:radio-helsinki-graz,项目名称:rivendell,代码行数:21,


示例8: btrfs_volume_create

int btrfs_volume_create(const char* _target){	char* prefix;	char* target;	int handle;	int result = -1;	struct btrfs_ioctl_vol_args detail = {};	prefix = strdupa(_target);	if((target = strrchr(prefix, '/'))) {		*target++ = '/0';	}	else {		prefix = ".";	}	if((handle = open(prefix, O_DIRECTORY|O_RDONLY)) < 0) {		fprintf(stderr, "%s: open %s: %m/n", __func__, prefix);		return -1;	}	strncpy(detail.name, target, BTRFS_SUBVOL_NAME_MAX);	if(ioctl(handle, BTRFS_IOC_SUBVOL_CREATE, &detail) < 0) {		fprintf(stderr, "%s: ioctl BTRFS_IOC_SUBVOL_CREATE: %m/n", __func__);		goto done;	}	result = 0;	done:	close(handle);	return result;}
开发者ID:lojix,项目名称:scim,代码行数:34,


示例9: reflink_snapshot

static int reflink_snapshot(int fd, const char *path) {        char *p, *d;        int new_fd, r;        p = strdupa(path);        d = dirname(p);        new_fd = open(d, O_TMPFILE|O_CLOEXEC|O_NOCTTY|O_RDWR, 0600);        if (new_fd < 0) {                _cleanup_free_ char *t = NULL;                r = tempfn_random(path, NULL, &t);                if (r < 0)                        return r;                new_fd = open(t, O_CLOEXEC|O_CREAT|O_NOCTTY|O_RDWR, 0600);                if (new_fd < 0)                        return -errno;                (void) unlink(t);        }        r = btrfs_reflink(fd, new_fd);        if (r < 0) {                safe_close(new_fd);                return r;        }        return new_fd;}
开发者ID:vathpela,项目名称:systemd,代码行数:30,


示例10: tags_list

static OpusTags *tags_list(DB_playItem_t *it, OggOpusFile *opusfile, int link){    const OpusTags *orig = op_tags (opusfile, link);    OpusTags *tags = calloc (1, sizeof (OpusTags));    if (!tags)        return NULL;    deadbeef->pl_lock ();    for (DB_metaInfo_t *m = deadbeef->pl_get_metadata_head (it); m; m = m->next) {        if (strchr (":!_", m->key[0])) {            break;        }        char *key = strdupa (m->key);        if (!strcasecmp(key, "R128_TRACK_GAIN")) {            continue;        }        split_tag (tags, oggedit_map_tag (key, "meta2tag"), m->value, m->valuesize);    }    deadbeef->pl_unlock ();    // preserve album art    int i = 0;    const char *tag;    while ((tag = opus_tags_query(orig, ALBUM_ART_KEY, i++))) {        split_tag (tags, ALBUM_ART_KEY, tag, (int)strlen (tag) + 1);    }    return tags;}
开发者ID:Alexey-Yakovenko,项目名称:deadbeef,代码行数:32,


示例11: match_uri

/* * Given a request URI and the URI we are checking for. * Return: *     true for a match and *     false for no match. */static bool match_uri(const char *request_uri, const char *match){	size_t rlen;	size_t mlen = strlen(match);	const char *request;	char *req = strdupa(request_uri);	/*	 * Handle URLs in the form /something/?key=value by stripping	 * everything from the ? onwards and matching on the initial part.	 */	if (strchr(request_uri, '?'))		request = strtok(req, "?");	else		request = request_uri;	rlen = strlen(request);	/*	 * The image URLs are a bit different, we only want to match on	 * the first /.../ part and they don't contain a ?.	 */	if (strstr(request, "/get_image/") && strstr(match, "/get_image/"))		return true;	else if (strncmp(request, match, mlen) == 0 && rlen == mlen)		return true;	else		return false;}
开发者ID:ac000,项目名称:compositus,代码行数:35,


示例12: build_extensions

static voidbuild_extensions(void){	assert(GL_extensions_dict == NULL);	/* create the dict */	GL_extensions_dict =		strdict_create(128, STRDICT_FL_DUPKEY);	assert(GL_extensions_dict != NULL);	const char * __extensions = (const char *)gl(GetString, GL_EXTENSIONS);	/* scan the string, identify each ' ' and replace it with '/0', then insert it	 * into GL_extensions_dict */	assert(__extensions != NULL);	char * extensions = strdupa(__extensions);	char * p = extensions;	char * pp = p;	dict_data_t data;	data.bol = TRUE;	while (*p != '/0') {		if (*p == ' ') {			*p = '/0';			dict_data_t dt;			dt = strdict_insert(GL_extensions_dict, pp, data);			assert(DICT_DATA_NULL(dt));			TRACE(OPENGL, "extension %s/n", pp);			pp = p + 1;		}		p++;	}}
开发者ID:weimingtom,项目名称:yaavg,代码行数:31,


示例13: s_mkpath

int s_mkpath(char *dir, mode_t mode) {    if (!dir) {        return(-1);    }    if (strlength(dir, 2) == 1 && dir[0] == '/') {        return(0);    }    if ( is_dir(dir) == 0 ) {        // Directory already exists, stop...        return(0);    }    if ( s_mkpath(dirname(strdupa(dir)), mode) < 0 ) {        // Return if priors failed        return(-1);    }    message(DEBUG, "Creating directory: %s/n", dir);    if ( mkdir(dir, mode) < 0 ) {        message(ERROR, "Could not create directory %s: %s/n", dir, strerror(errno));        return(-1);    }    return(0);}
开发者ID:jjohnson42,项目名称:singularity,代码行数:27,


示例14: strdupa

void CDirUtils::create_directory_recursive(const char* dirpath, mode_t permissions){    char* slash;    char* pathname = strdupa(dirpath); // _GNU_SOURCE    char* pathname_p = pathname;    // 过滤掉头部的斜杠    while ('/' == *pathname_p) ++pathname_p;    for (;;)    {        slash = strchr(pathname_p, '/');        if (NULL == slash) // 叶子目录        {            if (0 == mkdir(pathname, permissions)) break;            if (EEXIST == errno) break;            THROW_SYSCALL_EXCEPTION(NULL, errno, "mkdir");        }        *slash = '/0';        if ((-1 == mkdir(pathname, permissions)) && (errno != EEXIST))            THROW_SYSCALL_EXCEPTION(NULL, errno, "mkdir");        *slash++ = '/';        while ('/' == *slash) ++slash; // 过滤掉相连的斜杠        pathname_p = slash;    }}
开发者ID:ly20119,项目名称:mooon,代码行数:29,


示例15: container_start

/* container state */static int container_start(lua_State *L){    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);    int argc = lua_gettop(L);    char **argv = NULL;    int i,j;    int useinit = 0;    if (argc > 1) {	argv = alloca((argc+1) * sizeof(char *));	for (i = 0, j = 0; i < argc-1; i++) {	    const char *arg = luaL_checkstring(L, i+2);	    if (!strcmp(arg, "useinit"))		useinit = 1;	    else		argv[j++] = strdupa(arg);	}	argv[j] = NULL;    }    c->want_daemonize(c, true);    lua_pushboolean(L, !!c->start(c, useinit, argv));    return 1;}
开发者ID:Altiscale,项目名称:lxc,代码行数:26,


示例16: container_create

static int container_create(lua_State *L){    struct lxc_container *c = lua_unboxpointer(L, 1, CONTAINER_TYPENAME);    char *template_name = strdupa(luaL_checkstring(L, 2));    int argc = lua_gettop(L);    char **argv;    int i;    argv = alloca((argc+1) * sizeof(char *));    for (i = 0; i < argc-2; i++)	argv[i] = strdupa(luaL_checkstring(L, i+3));    argv[i] = NULL;    lua_pushboolean(L, !!c->create(c, template_name, NULL, NULL, 0, argv));    return 1;}
开发者ID:Altiscale,项目名称:lxc,代码行数:16,


示例17: slice_verify

static int slice_verify(Slice *s) {        assert(s);        if (UNIT(s)->load_state != UNIT_LOADED)                return 0;        if (UNIT_DEREF(UNIT(s)->slice)) {                char *a, *dash;                a = strdupa(UNIT(s)->id);                dash = strrchr(a, '-');                if (dash)                        strcpy(dash, ".slice");                else                        a = (char*) SPECIAL_ROOT_SLICE;                if (!unit_has_name(UNIT_DEREF(UNIT(s)->slice), a)) {                        log_unit_error(UNIT(s)->id,                                       "%s located outside its parent slice. Refusing.", UNIT(s)->id);                        return -EINVAL;                }        }        return 0;}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:25,


示例18: cmd_remove

int cmd_remove(const char* arg) {	char* ptr, *argv;	struct ncds_ds_list* ds;	struct model_list* model;	if (strlen(arg) < 7) {		cmd_remove_help();		return 1;	}	argv = strdupa(arg + strlen("remove "));	ptr = strtok(argv, " ");	ds = find_datastore(ptr);	if (ds == NULL) {		model = find_model(ptr);		if (model == NULL) {			nc_verb_error("No datastore or model /"%s/" found", ptr);			return 1;		} else {			ncds_ds_model_free(model->model);		}	} else {		ncds_free(ds->datastore);	}	remove_hint(ptr);	return 0;}
开发者ID:23171580,项目名称:libnetconf,代码行数:30,


示例19: slice_add_parent_slice

static int slice_add_parent_slice(Slice *s) {        char *a, *dash;        Unit *parent;        int r;        assert(s);        if (UNIT_ISSET(UNIT(s)->slice))                return 0;        if (unit_has_name(UNIT(s), SPECIAL_ROOT_SLICE))                return 0;        a = strdupa(UNIT(s)->id);        dash = strrchr(a, '-');        if (dash)                strcpy(dash, ".slice");        else                a = (char*) SPECIAL_ROOT_SLICE;        r = manager_load_unit(UNIT(s)->manager, a, NULL, NULL, &parent);        if (r < 0)                return r;        unit_ref_set(&UNIT(s)->slice, parent);        return 0;}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:27,


示例20: nfs_mntpath_to_xlator

xlator_t *nfs_mntpath_to_xlator (xlator_list_t *cl, char *path){        char            *volname = NULL;        char            *volptr = NULL;        size_t           pathlen;        xlator_t        *targetxl = NULL;        if ((!cl) || (!path))                return NULL;        volname = strdupa (path);        pathlen = strlen (volname);        gf_msg_trace (GF_NFS, 0, "Subvolume search: %s", path);        if (volname[0] == '/')                volptr = &volname[1];        else                volptr = &volname[0];        if (pathlen && volname[pathlen - 1] == '/')                volname[pathlen - 1] = '/0';        while (cl) {                if (strcmp (volptr, cl->xlator->name) == 0) {                        targetxl = cl->xlator;                        break;                }                cl = cl->next;        }        return targetxl;}
开发者ID:Apekhsha,项目名称:glusterfs,代码行数:34,


示例21: _exp_file_insert

/** * _exp_file_insert -- Insert the exports directory into the file structure *                     using the directory as a dict. Also hashes the dirname, *                     stores it in a uuid type, converts the uuid type to a *                     string and uses that as the key to the exports map. *                     The exports map maps an export "uuid" to an export *                     directory struct. * * @file : Exports file struct to insert into * @dir  : Export directory to insert * * Not for external use. */static void_exp_file_insert(struct exports_file *file, struct export_dir *dir){    data_t *dirdata = NULL;    uint32_t hashedval = 0;    uuid_t export_uuid = {        0,    };    char export_uuid_str[512] = {        0,    };    char *dirdup = NULL;    GF_VALIDATE_OR_GOTO(GF_EXP, file, out);    GF_VALIDATE_OR_GOTO(GF_EXP, dir, out);    dirdata = bin_to_data(dir, sizeof(*dir));    dict_set(file->exports_dict, dir->dir_name, dirdata);    dirdup = strdupa(dir->dir_name);    while (strlen(dirdup) > 0 && dirdup[0] == '/')        dirdup++;    hashedval = SuperFastHash(dirdup, strlen(dirdup));    memset(export_uuid, 0, sizeof(export_uuid));    memcpy(export_uuid, &hashedval, sizeof(hashedval));    gf_uuid_unparse(export_uuid, export_uuid_str);    dict_set(file->exports_map, export_uuid_str, dirdata);out:    return;}
开发者ID:gluster,项目名称:glusterfs,代码行数:45,


示例22: ftpService

void ftpService(int sock) {    char buf [BUF_SIZE];    char reply [BUF_SIZE];    bool terminate = false;    int n, on, i;    char *delimiters = " /n/r";    char *temp, *cmd, *arg;    // don't wait for system buffer to be full    on = 1;    if (setsockopt(sock, SOL_SOCKET, SO_OOBINLINE, (char*)&on, sizeof(on)) == -1) {        syslog(LOG_FTP | LOG_ERR, "ftpService: setsockopt: %m");        exit(1);    }    // let the peer know that you are ready    snprintf(reply, BUF_SIZE, FTP_R220, "LightFTPServer v0.1");    sendReply(sock, reply);    while (!terminate) {        // read command        memset(buf, 0, BUF_SIZE);        // TODO: loop to read all data        if ( (n = read(sock, buf, BUF_SIZE)) == -1) {            syslog(LOG_FTP | LOG_ERR, "ftpService: read: %m");            exit(1);        }        // TODO: check if command too large for buffer = not ending in CRLF        // parse cmd and arguments        temp = strdupa(buf);        cmd = strtok(temp, delimiters);        arg = strtok(NULL, delimiters);//     free(temp);        // should ignore blank commands or send a reply?        if (cmd != NULL) {            // look for handler            for (i = 0; i < _FTPCMDS_END; i++)                if (strcasecmp(cmd, ftpcmds[i]) == 0) {                    ftphandlers[i](cmd, arg, (char*)&reply, BUF_SIZE, &terminate);// 	  // say good bye and terminate// 	  if (i == FTP_CQUIT) {// 	    terminate = true;// 	    snprintf(reply, BUF_SIZE, FTP_R221);// 	  }// 	  else// 	    // handle command// 	    snprintf(reply, BUF_SIZE, FTP_R200, cmd);                    break;                }            // unknown command            if (i == _FTPCMDS_END)                snprintf(reply, BUF_SIZE, FTP_R500, cmd);            // send back reply            sendReply(sock, reply);        }    }    close(sock);}
开发者ID:BackupTheBerlios,项目名称:lightftpserver-svn,代码行数:60,


示例23: mecab_node_get_field

/** * Return the wanted_field'th field of the feature of the given node. */static std::string mecab_node_get_field(    const MeCab::Node *node,    int wanted_field) {    size_t field = 1;    char *token = strdupa(node->feature);    while (token != NULL) {        char *next = NULL;        if (*token == '"') {            char *closing_quote = strchr(token + 1, '"');            if (closing_quote && closing_quote[1] == ',') {                next = closing_quote + 1;                token++; // skip opening quote                *closing_quote = '/0'; // remove closing quote            }        }        if (!next)            next = strchr(token, ',');        if (next) {            *next = '/0';            next++;        }        if (field == wanted_field) {            return std::string(token);        }        field++;        token = next;    }    return "";}
开发者ID:Tatoeba,项目名称:nihongoparserd,代码行数:36,


示例24: strdupa

BOOL CDlgFileConv::OnInitDialog() {	CDialog::OnInitDialog();	CWnd::DragAcceptFiles();	//所有支持的编码	char *p, *charsets;	charsets = strdupa(supported_charsets);	while (p = strsep(&charsets, " "))	{		((CComboBox*)GetDlgItem(IDC_CB_SRC_CHARSET))->AddString(stringToCString(p));		((CComboBox*)GetDlgItem(IDC_CB_DST_CHARSET))->AddString(stringToCString(p));	}	//默认选择文件	m_rdSrcFile.SetCheck(TRUE);	SwitchSrcType();	m_bRecurDir = TRUE;	m_bWriteBOM = TRUE;	m_bConverting = FALSE;	m_progTotal.SetRange(0, 100);	UpdateData(FALSE);	return TRUE;  // return TRUE unless you set the focus to a control	              // EXCEPTION: OCX Property Pages should return FALSE}
开发者ID:arifeng,项目名称:CharsetAssistant,代码行数:29,


示例25: update_allowed_commands

/** * @short Updates allowed commands acording to config file SHELL_WHITELIST and SHELL_BLACKLIST *  * First removes all not at whitelist, then all from blacklist. *  * A command with empty name (string length 0) is not valid. At end we really remove them. */void update_allowed_commands(){	if (getenv("SHELL_WHITELIST")){		{ // Blacklist all.			subcommand_t *I=subcommand_list_begin(), *endI=subcommand_list_end();			for(;I!=endI;++I)				I->type|=SC_BLACKLISTED;		}		// Allow some.		char *whitelist=strdupa( getenv("SHELL_WHITELIST") );		char *I=whitelist, *endI=whitelist+strlen(whitelist);		while (*whitelist){			while (*whitelist && !isspace(*whitelist))				whitelist++;			*whitelist=0;			subcommand_t *command=subcommand_find(I);			if (command){				fprintf(stderr,"Whitelist %s/n", command->name);				command->type&=~SC_BLACKLISTED; // Clear.			}			if (whitelist>=endI)				break;			whitelist++;			while (isspace(*whitelist)) whitelist++; // Advance to next.			I=whitelist;		}	}		if (getenv("SHELL_BLACKLIST")){		char *blacklist=strdupa( getenv("SHELL_BLACKLIST") );		char *I=blacklist, *endI=blacklist+strlen(blacklist);		while (*blacklist){			while (*blacklist && !isspace(*blacklist))				blacklist++;			*blacklist=0;			subcommand_t *command=subcommand_find(I);			if (command){				fprintf(stderr,"Blacklist %s/n", command->name);				command->type|=SC_BLACKLISTED;			}			if (blacklist>=endI)				break;			blacklist++;			while (isspace(*blacklist)) blacklist++; // Advance to next.			I=blacklist;		}	}}
开发者ID:davidmoreno,项目名称:commands,代码行数:54,


示例26: runner_new

struct runner *runner_new(const char *filename){    struct runner *r;    const char *buf;    size_t size;    int err;    SOL_NULL_CHECK(filename, NULL);    r = calloc(1, sizeof(*r));    SOL_NULL_CHECK(r, NULL);    sol_ptr_vector_init(&r->file_readers);    r->parser_client.api_version = SOL_FLOW_PARSER_CLIENT_API_VERSION;    r->parser_client.data = r;    r->parser_client.read_file = read_file;    r->parser = sol_flow_parser_new(&r->parser_client, NULL);    if (!r->parser)        goto error;    r->filename = filename;    r->dirname = strdup(dirname(strdupa(filename)));    r->basename = strdup(basename(strdupa(filename)));    err = read_file(r, r->basename, &buf, &size);    if (err < 0) {        errno = -err;        goto error;    }    r->root_type = sol_flow_parse_buffer(r->parser, buf, size, filename);    if (!r->root_type)        goto error;    close_files(r);    return r;error:    close_files(r);    runner_del(r);    return NULL;}
开发者ID:kalyankondapally,项目名称:soletta,代码行数:46,


示例27: thingspeak_channel_update_send

static boolthingspeak_channel_update_send(void *data){    struct thingspeak_channel_update_data *mdata = data;    struct sol_http_param params;    struct sol_http_client_connection *connection;    char field_name[] = "fieldX";    size_t i;    int r;    sol_http_param_init(&params);    if (!sol_http_param_add(&params,        SOL_HTTP_REQUEST_PARAM_POST_FIELD("api_key", mdata->api_key))) {        SOL_WRN("Could not add API key");        goto out;    }    if (mdata->status) {        if (!sol_http_param_add(&params,            SOL_HTTP_REQUEST_PARAM_POST_FIELD("status", mdata->status))) {            SOL_WRN("Could not add status field to POST parameters");            goto out;        }    }    for (i = 0; i < ARRAY_SIZE(mdata->fields); i++) {        if (!mdata->fields[i])            continue;        field_name[sizeof("field") - 1] = i + '1';        if (!sol_http_param_add(&params,            SOL_HTTP_REQUEST_PARAM_POST_FIELD(strdupa(field_name), mdata->fields[i]))) {            SOL_WRN("Could not add status field to POST %s parameters",                field_name);            goto out;        }    }    connection = sol_http_client_request(SOL_HTTP_METHOD_POST,        mdata->endpoint, &params, thingspeak_channel_update_finished, mdata);    if (!connection) {        SOL_WRN("Could not create HTTP request");        goto out;    }    r = sol_ptr_vector_append(&mdata->pending_conns, connection);    if (r < 0) {        SOL_WRN("Failed to keep pending connection.");        sol_http_client_connection_cancel(connection);    }out:    sol_http_param_free(&params);    mdata->timeout = NULL;    return false;}
开发者ID:rchiossi,项目名称:soletta,代码行数:58,


示例28: rule_satisfiable

static bool rule_satisfiable(multiset_table *cmt, pp_linkset *ls){	unsigned int hashval;	const char * t;	char *name, *s;	pp_linkset_node *p;	int bad, n_subscripts;	for (hashval = 0; hashval < ls->hash_table_size; hashval++)	{		for (p = ls->hash_table[hashval]; p!=NULL; p=p->next)		{			/* ok, we've got our hands on one of the criterion links */			name = strdupa(p->str);			/* could actually use the string in place because we change it back */			/* now we want to see if we can satisfy this criterion link */			/* with a collection of the links in the cms table */			s = name;			if (islower((int)*s)) s++; /* skip head-dependent indicator */			for (; isupper((int)*s); s++) {}			for (;*s != '/0'; s++) if (*s != '*') *s = '#';			s = name;			t = p->str;			if (islower((int)*s)) s++; /* skip head-dependent indicator */			if (islower((int)*t)) t++; /* skip head-dependent indicator */			for (; isupper((int) *s); s++, t++) {}			/* s and t remain in lockstep */			bad = 0;			n_subscripts = 0;			for (;*s != '/0' && bad==0; s++, t++) {				if (*s == '*') continue;				n_subscripts++;				/* after the upper case part, and is not a * so must be a regular subscript */				*s = *t;				if (!match_in_cms_table(cmt, name)) bad++;				*s = '#';			}			if (n_subscripts == 0) {				/* now we handle the special case which occurs if there				   were 0 subscripts */				if (!match_in_cms_table(cmt, name)) bad++;			}			/* now if bad==0 this criterion link does the job			   to satisfy the needs of the trigger link */			if (bad == 0) return true;		}	}	return false;}
开发者ID:ampli,项目名称:link-grammar,代码行数:56,


示例29: write_checksum_file_at

static gbooleanwrite_checksum_file_at (OstreeRepo   *self,                        int dfd,                        const char *name,                        const char *sha256,                        GCancellable *cancellable,                        GError **error){    gboolean ret = FALSE;    const char *lastslash;    if (!ostree_validate_checksum_string (sha256, error))        goto out;    if (ostree_validate_checksum_string (name, NULL))    {        g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,                     "Rev name '%s' looks like a checksum", name);        goto out;    }    if (!*name)    {        g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,                     "Invalid empty ref name");        goto out;    }    lastslash = strrchr (name, '/');    if (lastslash)    {        char *parent = strdupa (name);        parent[lastslash - name] = '/0';        if (!glnx_shutil_mkdir_p_at (dfd, parent, 0777, cancellable, error))            goto out;    }    {        size_t l = strlen (sha256);        char *bufnl = alloca (l + 2);        memcpy (bufnl, sha256, l);        bufnl[l] = '/n';        bufnl[l+1] = '/0';        if (!_ostree_repo_file_replace_contents (self, dfd, name, (guint8*)bufnl, l + 1,                cancellable, error))            goto out;    }    ret = TRUE;out:    return ret;}
开发者ID:jeremycline,项目名称:ostree,代码行数:56,


示例30: NXfnammchk

bool NXfnammchk(const char* fn, const char* nam){  if(!nam || nam[0] == '/0') return false;  char* fna = _strlwr(strdupa(fn));  char* nama = _strlwr(strdupa(nam));  size_t l = strlen(fn);  char* e = nama;  for(;;)  {    char* ne = strchr(e, '|');    if(ne) ne[0] = '/0';    if(strstr(fna, e)) return true;    if(!ne) break;    e = ne+1;  }  return false;}
开发者ID:xrmb,项目名称:nxtv,代码行数:19,



注:本文中的strdupa函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


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