コード例 #1
0
ファイル: utils.c プロジェクト: idunham/dtextra
int main(int argc,char **argv)
{
    char
        *p;
    char
        *keyword,
        *value,
        buf[1024];

    if (argc != 2)
        exit(1);

    (void) strcpy(buf,argv[1]);
    p=buf;

    while((keyword=mystrtok(p,":")) != (char *) NULL)
    {
        p=(char *) NULL;
        value=mystrtok(p,"|&");
        if (value == (char *) NULL)
        {
            (void) fprintf(stderr,"parameter %s requires a value\n",
                keyword);
            exit(1);
        }
        (void) fprintf(stderr,"keyword=%s value=%s\n",keyword,value);
    }
}
コード例 #2
0
ファイル: strtok2.c プロジェクト: naiyt/kandr
int main(int argc, char const *argv[])
{
	char delimeters[] = "?,|";
	char str[] = "Oh hi! Please, split with ?, commas, pipes|and|nothing|else.";
	char *splitting;

	splitting = mystrtok(str, delimeters);
	while(splitting != NULL) {
		printf("%s\n", splitting);;
		splitting = mystrtok(NULL, delimeters);	
	}

	printf("\n");

	char *splitting2;

	splitting2 = strtok(str, delimeters);
	while(splitting2 != NULL) {
		printf("%s\n", splitting2);;
		splitting2 = strtok(NULL, delimeters);	
	}

	
	return 0;
}
コード例 #3
0
ファイル: verify_clnt.c プロジェクト: ajinkya93/netbsd-src
static void update(char *query)
{
    char   *addr;
    char   *status_text;
    char   *cp = query;

    if ((addr = mystrtok(&cp, " \t\r\n")) == 0
	|| (status_text = mystrtok(&cp, " \t\r\n")) == 0) {
	msg_warn("bad request format");
	return;
    }
    while (*cp && ISSPACE(*cp))
	cp++;
    if (*cp == 0) {
	msg_warn("bad request format");
	return;
    }
    switch (verify_clnt_update(query, atoi(status_text), cp)) {
    case VRFY_STAT_OK:
	vstream_printf("OK\n");
	vstream_fflush(VSTREAM_OUT);
	break;
    case VRFY_STAT_BAD:
	msg_warn("bad request format");
	break;
    case VRFY_STAT_FAIL:
	msg_warn("request failed");
	break;
    }
}
コード例 #4
0
ファイル: lib.c プロジェクト: anamarce/proyectoFinalSISO
unsigned int findFileBlockInPath(char *fileName)
{
	char * path; 
	char * directoryName;
	int tokens,directoryEntryNumber;
	unsigned int directoryBlockNumber;
	directoryBlock directory;
	int tokenPosition = 2;
	fileName = getData(fileName);
	path = (char*)mallocFS(mystrlen(fileName));
	path = getData(strcpy(fileName, path));
	 tokens= qtytoken(path, '/');
	directoryName = getData(mystrtok(path, '/', tokenPosition));
	directoryEntryNumber = 0;
	directoryBlockNumber = ROOTBLOCK;
	readsector(2, &directory);
	if (directoryName[0] == '\0')
		return directoryBlockNumber;
	while (tokenPosition <= tokens)
	{
		directoryEntryNumber = findFileInDirectory(directory, directoryName);

		if (directoryEntryNumber == -1)
		{
			return -1;
		}
		directoryBlockNumber = directory.entries[directoryEntryNumber].fileBlockStart;
		readsector(directoryBlockNumber, (char *)&directory);
		directoryName = getData(mystrtok(path, '/', tokenPosition + 1));
		tokenPosition++;
	}
	return directoryBlockNumber;
}
コード例 #5
0
ファイル: config.c プロジェクト: platinasystems/openipmi
int
get_auths(char **tokptr, unsigned int *rval, const char **err)
{
    const char *tok = mystrtok(NULL, " \t\n", tokptr);
    int  val = 0;

    while (tok) {
	if (strcmp(tok, "none") == 0)
	    val |= (1 << IPMI_AUTHTYPE_NONE);
	else if (strcmp(tok, "md2") == 0)
	    val |= (1 << IPMI_AUTHTYPE_MD2);
	else if (strcmp(tok, "md5") == 0)
	    val |= (1 << IPMI_AUTHTYPE_MD5);
	else if (strcmp(tok, "straight") == 0)
	    val |= (1 << IPMI_AUTHTYPE_STRAIGHT);
	else {
	    *err = "Invalid authorization type, must be 'none', 'md2',"
		" 'md5', or 'straight'";
	    return -1;
	}

	tok = mystrtok(NULL, " \t\n", tokptr);
    }

    *rval = val;

    return 0;
}
コード例 #6
0
ファイル: memcsv.c プロジェクト: airween/hamlib
/**  Function to break a line into a list of tokens. Delimiters are
    replaced by end-of-string characters ('\0'), and a list of pointers
    to thus created substrings is created.
    \param line (input) - a line to be tokenized, the line will be modified!
    \param token_list (output) - a resulting table containing pointers to
         tokens, or NULLs (the table will be initially nulled )
         all the pointers schould point to addresses within the line
    \param siz (input) - size of the table
    \param delim (input) - delimiter character
    \return number of tokens on success, 0 if \param token_list is too small to contain all the tokens,
            or if line was empty.
*/
static int tokenize_line(char *line, char **token_list, size_t siz, char delim)
{
    size_t i;
    char *tok;

    /* Erase the table */
    for (i = 0; i < siz; i++)
    {
        token_list[i] = NULL;
    }

    /* Empty line passed? */
    if (line == NULL)
    {
        return 0;
    }

    /* Reinitialize, find the first token */
    i = 0;
    tok = mystrtok(line, delim);

    /* Line contains no delim */
    if (tok == NULL)
    {
        return 0;
    }

    token_list[ i++ ] = tok;

    /* Find the remaining tokens */
    while (i < siz)
    {
        tok = mystrtok(NULL, delim);

        /* If NULL, no more tokens left */
        if (tok == NULL)
        {
            break;
        }

        /* Add token to the list */
        token_list[ i++ ] = tok;
    }

    /* Any tokens left? */
    if (i == siz)
    {
        return 0;
    }
    else
    {
        return i;
    }
}
コード例 #7
0
ファイル: strtok.c プロジェクト: qinke/akaedu-c-leaning
int main(void)
{
    char str[100] = "he:kl;;fjgh:fjhg; fdfjg:gfklgj";
    char *p;

    printf("%s\n", mystrtok(str, ";:"));
    while(p = mystrtok(NULL, ";:"));
    printf("%s\n", p);

    return 0;
}
コード例 #8
0
ファイル: mac_expand.c プロジェクト: TonyChengTW/Rmail
int     main(int unused_argc, char **unused_argv)
{
    VSTRING *buf = vstring_alloc(100);
    VSTRING *result = vstring_alloc(100);
    char   *cp;
    char   *name;
    char   *value;
    HTABLE *table;
    int     stat;

    while (!vstream_feof(VSTREAM_IN)) {

	table = htable_create(0);

	/*
	 * Read a block of definitions, terminated with an empty line.
	 */
	while (vstring_get_nonl(buf, VSTREAM_IN) != VSTREAM_EOF) {
	    vstream_printf("<< %s\n", vstring_str(buf));
	    vstream_fflush(VSTREAM_OUT);
	    if (VSTRING_LEN(buf) == 0)
		break;
	    cp = vstring_str(buf);
	    name = mystrtok(&cp, " \t\r\n=");
	    value = mystrtok(&cp, " \t\r\n=");
	    htable_enter(table, name, value ? mystrdup(value) : 0);
	}

	/*
	 * Read a block of patterns, terminated with an empty line or EOF.
	 */
	while (vstring_get_nonl(buf, VSTREAM_IN) != VSTREAM_EOF) {
	    vstream_printf("<< %s\n", vstring_str(buf));
	    vstream_fflush(VSTREAM_OUT);
	    if (VSTRING_LEN(buf) == 0)
		break;
	    cp = vstring_str(buf);
	    VSTRING_RESET(result);
	    stat = mac_expand(result, vstring_str(buf), MAC_EXP_FLAG_NONE,
			      (char *) 0, lookup, (char *) table);
	    vstream_printf("stat=%d result=%s\n", stat, vstring_str(result));
	    vstream_fflush(VSTREAM_OUT);
	}
	htable_free(table, myfree);
	vstream_printf("\n");
    }

    /*
     * Clean up.
     */
    vstring_free(buf);
    vstring_free(result);
    exit(0);
}
コード例 #9
0
ファイル: server_acl.c プロジェクト: Gelma/Postfix
int     main(void)
{
    VSTRING *buf = vstring_alloc(100);
    SERVER_ACL *argv;
    int     ret;
    int     have_tty = isatty(0);
    char   *bufp;
    char   *cmd;
    char   *value;
    const NAME_CODE acl_map[] = {
	SERVER_ACL_NAME_ERROR, SERVER_ACL_ACT_ERROR,
	SERVER_ACL_NAME_PERMIT, SERVER_ACL_ACT_PERMIT,
	SERVER_ACL_NAME_REJECT, SERVER_ACL_ACT_REJECT,
	SERVER_ACL_NAME_DUNNO, SERVER_ACL_ACT_DUNNO,
	0,
    };

#define VAR_SERVER_ACL "server_acl"

    while (vstring_get_nonl(buf, VSTREAM_IN) != VSTREAM_EOF) {
	bufp = STR(buf);
	if (have_tty == 0) {
	    vstream_printf("> %s\n", bufp);
	    vstream_fflush(VSTREAM_OUT);
	}
	if (*bufp == '#')
	    continue;
	if ((cmd = mystrtok(&bufp, " =")) == 0 || STREQ(cmd, "?")) {
	    vstream_printf("usage: %s=value|%s=value|address=value\n",
			   VAR_MYNETWORKS, VAR_SERVER_ACL);
	} else if ((value = mystrtok(&bufp, " =")) == 0) {
	    vstream_printf("missing value\n");
	} else if (STREQ(cmd, VAR_MYNETWORKS)) {
	    UPDATE_VAR(var_mynetworks, value);
	} else if (STREQ(cmd, VAR_SERVER_ACL)) {
	    UPDATE_VAR(var_server_acl, value);
	} else if (STREQ(cmd, "address")) {
	    server_acl_pre_jail_init(var_mynetworks, VAR_SERVER_ACL);
	    argv = server_acl_parse(var_server_acl, VAR_SERVER_ACL);
	    ret = server_acl_eval(value, argv, VAR_SERVER_ACL);
	    argv_free(argv);
	    vstream_printf("%s: %s\n", value, str_name_code(acl_map, ret));
	} else {
	    vstream_printf("unknown command: \"%s\"\n", cmd);
	}
	vstream_fflush(VSTREAM_OUT);
    }
    vstring_free(buf);
    exit(0);
}
コード例 #10
0
ファイル: mystrtok.c プロジェクト: HackLinux/C-program
int main(void)
{
	char str[] = "degh,odf;j,oi";
	const char delim[]=",;";
	char *p;
	/*fgets(str,sizeof(str),stdin)
	  str[strlen(str)] = '\0';
	  fgets(delim,sizeof(delim),stdin)
	  str[strlen(delim)] = '\0';*/
	printf("%s\n",mystrtok(str,delim));
	while(p =  mystrtok(NULL,delim))
		//printf("%s\n",mystrtok(NULL,delim));
		printf("%s\n",p);
	return 0;
}
コード例 #11
0
ファイル: config.c プロジェクト: platinasystems/openipmi
int
get_bool(char **tokptr, unsigned int *rval, const char **err)
{
    const char *tok = mystrtok(NULL, " \t\n", tokptr);

    if (!tok) {
	*err = "No boolean value given";
	return -1;
    }
    if (strcasecmp(tok, "true") == 0)
	*rval = 1;
    else if (strcasecmp(tok, "false") == 0)
	*rval = 0;
    else if (strcasecmp(tok, "on") == 0)
	*rval = 1;
    else if (strcasecmp(tok, "off") == 0)
	*rval = 0;
    else if (strcasecmp(tok, "yes") == 0)
	*rval = 1;
    else if (strcasecmp(tok, "no") == 0)
	*rval = 0;
    else if (strcasecmp(tok, "1") == 0)
	*rval = 1;
    else if (strcasecmp(tok, "0") == 0)
	*rval = 0;
    else {
	*err = "Invalid boolean value, must be 'true', 'on', 'false', or 'off'";
	return -1;
    }

    return 0;
}
コード例 #12
0
ファイル: gmx_amide_map.c プロジェクト: mreppert/g_amide
int set_atom_path(t_atom_path *p_ap, const char* str) {
	t_atom_path ap = *p_ap;
	char str_copy[maxchar];
	strcpy(str_copy, str);
	char token[maxchar], remainder[maxchar];
	strcpy(remainder, str);
	ap.length = 0;
	while(strlen(remainder)>0) {
		mystrtok(remainder, token, bond_delim);
		if(strlen(token)>5) {
			printf("Error: Atom identifier %s is too long (5 character is pdb maximum).\n", token);
			ap.length = 0;
			*p_ap = ap;
			return 0;
		}
		sscanf(token, "%s", ap.Path[ap.length]);
		ap.length++;
		if(ap.length==MAX_PATH_LENGTH) { 
			printf("Error setting atom path. Path exceeds maximum length (%d bonds): %s\n", MAX_PATH_LENGTH, str);
			return 0;
		}
	}
	*p_ap = ap;
	return 1;
}
コード例 #13
0
ファイル: config.c プロジェクト: platinasystems/openipmi
int
get_priv(char **tokptr, unsigned int *rval, const char **err)
{
    const char *tok = mystrtok(NULL, " \t\n", tokptr);

    if (!tok) {
	*err = "No privilege specified, must be 'callback', 'user',"
	    " 'operator', or 'admin'";
	return -1;
    }
    if (strcmp(tok, "callback") == 0)
	*rval = IPMI_PRIVILEGE_CALLBACK;
    else if (strcmp(tok, "user") == 0)
	*rval = IPMI_PRIVILEGE_USER;
    else if (strcmp(tok, "operator") == 0)
	*rval = IPMI_PRIVILEGE_OPERATOR;
    else if (strcmp(tok, "admin") == 0)
	*rval = IPMI_PRIVILEGE_ADMIN;
    else {
	*err = "Invalid privilege specified, must be 'callback', 'user',"
	    " 'operator', or 'admin'";
	return -1;
    }

    return 0;
}
コード例 #14
0
ファイル: lib.c プロジェクト: anamarce/proyectoFinalSISO
char * getPathName(char * pathName, int type)
{
	int lengthName = mystrlen(pathName);
	char *path = (char*)mallocFS(lengthName);
	int tokens = qtytoken(pathName, '/');
	int tokenPosition = 2;
	int i = 0;
	char *dirName = (char*)mallocFS(lengthName);
	if (tokens == 1 && type == 1)
	{
		path[0] = pathName[0];
		path[1] = '\0';
	}
	if (tokens == 2)
	{
		path[0] = '/';
		path = getData(path);
	}
	while (tokenPosition <= tokens - 1)
	{
		char *token = mystrtok(pathName, '/', tokenPosition);

		if (tokenPosition == 2)
			path = getData(mistrcat("/", token));
		else
			path = getData(mistrcat(path, token));

		if (tokenPosition < tokens - 1)
		{
			path = getData(path);
			path = mistrcat(path, "/");
			path = getData(path);
		}
		tokenPosition++;
	}

	if (type == 1)//retorna path sin la ultima carpeta o archivo
	{
		return path;
	}
	else
	{
		dirName = mystrtok(pathName, '/', tokens);
		dirName = getData(dirName);
		return dirName;
	}
}
コード例 #15
0
ファイル: name_mask.c プロジェクト: aosm/postfix
long    long_name_mask_delim_opt(const char *context,
				         const LONG_NAME_MASK * table,
			               const char *names, const char *delim,
				         int flags)
{
    const char *myname = "name_mask";
    char   *saved_names = mystrdup(names);
    char   *bp = saved_names;
    long    result = 0;
    const LONG_NAME_MASK *np;
    char   *name;
    int     (*lookup) (const char *, const char *);
    unsigned long ulval;

    if ((flags & NAME_MASK_REQUIRED) == 0)
	msg_panic("%s: missing NAME_MASK_FATAL/RETURN/WARN/IGNORE flag",
		  myname);

    if (flags & NAME_MASK_ANY_CASE)
	lookup = strcasecmp;
    else
	lookup = strcmp;

    /*
     * Break up the names string, and look up each component in the table. If
     * the name is found, merge its mask with the result.
     */
    while ((name = mystrtok(&bp, delim)) != 0) {
	for (np = table; /* void */ ; np++) {
	    if (np->name == 0) {
		if ((flags & NAME_MASK_NUMBER)
		    && hex_to_ulong(name, ~0UL, &ulval)) {
		    result |= ulval;
		} else if (flags & NAME_MASK_FATAL) {
		    msg_fatal("unknown %s value \"%s\" in \"%s\"",
			      context, name, names);
		} else if (flags & NAME_MASK_RETURN) {
		    msg_warn("unknown %s value \"%s\" in \"%s\"",
			     context, name, names);
		    myfree(saved_names);
		    return (0);
		} else if (flags & NAME_MASK_WARN) {
		    msg_warn("unknown %s value \"%s\" in \"%s\"",
			     context, name, names);
		}
		break;
	    }
	    if (lookup(name, np->name) == 0) {
		if (msg_verbose)
		    msg_info("%s: %s", myname, name);
		result |= np->mask;
		break;
	    }
	}
    }

    myfree(saved_names);
    return (result);
}
コード例 #16
0
ファイル: postconf_dbms.c プロジェクト: cloudbuy/postfix
void    register_dbms_parameters(const char *param_value,
          const char *(flag_parameter) (const char *, int, PC_MASTER_ENT *),
				         PC_MASTER_ENT *local_scope)
{
    const PC_DBMS_INFO *dp;
    char   *bufp;
    char   *db_type;
    char   *prefix;
    static VSTRING *buffer = 0;
    static VSTRING *candidate = 0;
    const char **cpp;

    /*
     * XXX This does not examine both sides of conditional macro expansion,
     * and may expand the "wrong" conditional macros. This is the best we can
     * do for legacy database configuration support.
     */
    if (buffer == 0)
	buffer = vstring_alloc(100);
    bufp = expand_parameter_value(buffer, SHOW_EVAL, param_value, local_scope);

    /*
     * Naive parsing. We don't really know if the parameter specifies free
     * text or a list of databases.
     */
    while ((db_type = mystrtok(&bufp, " ,\t\r\n")) != 0) {

	/*
	 * Skip over "proxy:" maptypes, to emulate the proxymap(8) server's
	 * behavior when opening a local database configuration file.
	 */
	while ((prefix = split_at(db_type, ':')) != 0
	       && strcmp(db_type, DICT_TYPE_PROXY) == 0)
	    db_type = prefix;

	/*
	 * Look for database:prefix where the prefix is not a pathname and
	 * the database is a known type. Synthesize candidate parameter names
	 * from the user-defined prefix and from the database-defined suffix
	 * list, and see if those parameters have a "name=value" entry in the
	 * local or global namespace.
	 */
	if (prefix != 0 && *prefix != '/' && *prefix != '.') {
	    for (dp = dbms_info; dp->db_type != 0; dp++) {
		if (strcmp(db_type, dp->db_type) == 0) {
		    for (cpp = dp->db_suffixes; *cpp; cpp++) {
			vstring_sprintf(candidate ? candidate :
					(candidate = vstring_alloc(30)),
					"%s_%s", prefix, *cpp);
			flag_parameter(STR(candidate),
				    PC_PARAM_FLAG_DBMS | PC_PARAM_FLAG_USER,
				       local_scope);
		    }
		    break;
		}
	    }
	}
    }
}
コード例 #17
0
static char* mystrtok_spc(char* str)
{
	char* ret = mystrtok(str, " \t");
	if (!ret) return NULL;
	if (*mystrtok_pos)
		for (; *mystrtok_pos && isspace(*mystrtok_pos); mystrtok_pos++);
	return ret;
}
コード例 #18
0
static const char *mail_version_worker(MAIL_VERSION *mp, char *cp)
{
    char   *major_field;
    char   *minor_field;
    char   *patch_field;

    /*
     * Program name.
     */
    if ((mp->program = mystrtok(&cp, "-")) == 0)
	return ("no program name");

    /*
     * Major, minor, patchlevel. If this is a stable release, then we ignore
     * text after the patchlevel, in case there are vendor extensions.
     */
    if ((major_field = mystrtok(&cp, "-")) == 0)
	return ("missing major version");

    if ((minor_field = split_at(major_field, '.')) == 0)
	return ("missing minor version");
    if ((mp->major = mail_version_int(major_field)) < 0)
	return ("bad major version");
    patch_field = split_at(minor_field, '.');
    if ((mp->minor = mail_version_int(minor_field)) < 0)
	return ("bad minor version");

    if (patch_field == 0)
	mp->patch = -1;
    else if ((mp->patch = mail_version_int(patch_field)) < 0)
	return ("bad patchlevel");

    /*
     * Experimental release. If this is not a stable release, we take
     * everything to the end of the string.
     */
    if (patch_field != 0)
	mp->snapshot = 0;
    else if ((mp->snapshot = mystrtok(&cp, "")) == 0)
	return ("missing snapshot field");

    return (0);
}
コード例 #19
0
ファイル: argv_split.c プロジェクト: ajinkya93/netbsd-src
ARGV   *argv_split_append(ARGV *argvp, const char *string, const char *delim)
{
    char   *saved_string = mystrdup(string);
    char   *bp = saved_string;
    char   *arg;

    while ((arg = mystrtok(&bp, delim)) != 0)
	argv_add(argvp, arg, (char *) 0);
    argv_terminate(argvp);
    myfree(saved_string);
    return (argvp);
}
コード例 #20
0
ファイル: data_redirect.c プロジェクト: ajinkya93/netbsd-src
int     main(int argc, char **argv)
{
    VSTRING *inbuf = vstring_alloc(100);
    VSTRING *result = vstring_alloc(100);
    char   *bufp;
    char   *cmd;
    char   *target;
    char   *junk;

    mail_conf_read();

    while (vstring_get_nonl(inbuf, VSTREAM_IN) != VSTREAM_EOF) {
	bufp = STR(inbuf);
	if (!isatty(0)) {
	    vstream_printf("> %s\n", bufp);
	    vstream_fflush(VSTREAM_OUT);
	}
	if (*bufp == '#')
	    continue;
	if ((cmd = mystrtok(&bufp, " \t")) == 0) {
	    vstream_printf("usage: file path|map maptype:mapname\n");
	    vstream_fflush(VSTREAM_OUT);
	    continue;
	}
	target = mystrtok(&bufp, " \t");
	junk = mystrtok(&bufp, " \t");
	if (strcmp(cmd, "file") == 0 && target && !junk) {
	    data_redirect_file(result, target);
	    vstream_printf("%s -> %s\n", target, STR(result));
	} else if (strcmp(cmd, "map") == 0 && target && !junk) {
	    data_redirect_map(result, target);
	    vstream_printf("%s -> %s\n", target, STR(result));
	} else {
	    vstream_printf("usage: file path|map maptype:mapname\n");
	}
	vstream_fflush(VSTREAM_OUT);
    }
    vstring_free(inbuf);
    return (0);
}
コード例 #21
0
ファイル: match_service.c プロジェクト: ystk/debian-postfix
ARGV   *match_service_init(const char *patterns)
{
    const char *delim = " ,\t\r\n";
    ARGV   *list = argv_alloc(1);
    char   *saved_patterns = mystrdup(patterns);
    char   *bp = saved_patterns;
    const char *item;

    while ((item = mystrtok(&bp, delim)) != 0)
        argv_add(list, item, (char *) 0);
    argv_terminate(list);
    myfree(saved_patterns);
    return (list);
}
コード例 #22
0
ファイル: proxymap.c プロジェクト: KKcorps/postfix
static void post_jail_init(char *service_name, char **unused_argv)
{
    const char *sep = ", \t\r\n";
    char   *saved_filter;
    char   *bp;
    char   *type_name;

    /*
     * Are we proxy writer?
     */
    if (strcmp(service_name, MAIL_SERVICE_PROXYWRITE) == 0)
        proxy_writer = 1;
    else if (strcmp(service_name, MAIL_SERVICE_PROXYMAP) != 0)
        msg_fatal("service name must be one of %s or %s",
                  MAIL_SERVICE_PROXYMAP, MAIL_SERVICE_PROXYMAP);

    /*
     * Pre-allocate buffers.
     */
    request = vstring_alloc(10);
    request_map = vstring_alloc(10);
    request_key = vstring_alloc(10);
    request_value = vstring_alloc(10);
    map_type_name_flags = vstring_alloc(10);

    /*
     * Prepare the pre-approved list of proxied tables.
     */
    saved_filter = bp = mystrdup(proxy_writer ? var_proxy_write_maps :
                                 var_proxy_read_maps);
    proxy_auth_maps = htable_create(13);
    while ((type_name = mystrtok(&bp, sep)) != 0) {
        if (strncmp(type_name, PROXY_COLON, PROXY_COLON_LEN))
            continue;
        do {
            type_name += PROXY_COLON_LEN;
        } while (!strncmp(type_name, PROXY_COLON, PROXY_COLON_LEN));
        if (strchr(type_name, ':') != 0
                && htable_locate(proxy_auth_maps, type_name) == 0)
            (void) htable_enter(proxy_auth_maps, type_name, (char *) 0);
    }
    myfree(saved_filter);

    /*
     * Never, ever, get killed by a master signal, as that could corrupt a
     * persistent database when we're in the middle of an update.
     */
    if (proxy_writer != 0)
        setsid();
}
コード例 #23
0
ファイル: master_ent.c プロジェクト: Gelma/Postfix
static char *get_str_ent(char **bufp, char *name, char *def_val)
{
    char   *value;

    if ((value = mystrtok(bufp, master_blanks)) == 0)
	fatal_with_context("missing \"%s\" field", name);
    if (strcmp(value, "-") == 0) {
	if (def_val == 0)
	    fatal_with_context("field \"%s\" has no default value", name);
	return (def_val);
    } else {
	return (value);
    }
}
コード例 #24
0
ファイル: config.c プロジェクト: platinasystems/openipmi
int
read_bytes(char **tokptr, unsigned char *data, const char **err,
	   unsigned int len)
{
    const char *tok = mystrtok(NULL, " \t\n", tokptr);
    char *end;

    if (!tok) {
	*err = "Missing password or username";
	return -1;
    }
    if (*tok == '"') {
	unsigned int end;
	/* Ascii PW */
	tok++;
	end = strlen(tok) - 1;
	if (tok[end] != '"') {
	    *err = "ASCII password or username doesn't end in '\"'";
	    return -1;
	}
	if (end > (len - 1))
	    end = len - 1;
	memcpy(data, tok, end);
	data[end] = '\0';
	zero_extend_ascii(data, len);
    } else {
	unsigned int i;
	char         c[3];
	/* HEX pw */
	if (strlen(tok) != 32) {
	    *err = "HEX password or username not 32 HEX characters long";
	    return -1;
	}
	c[2] = '\0';
	for (i=0; i<len; i++) {
	    c[0] = *tok;
	    tok++;
	    c[1] = *tok;
	    tok++;
	    data[i] = strtoul(c, &end, 16);
	    if (*end != '\0') {
		*err = "Invalid HEX character in password or username";
		return -1;
	    }
	}
    }

    return 0;
}
コード例 #25
0
static int load_tas(TLS_DANE *dane, const char *files)
{
    int     ret = 0;
    char   *save = mystrdup(files);
    char   *buf = save;
    char   *file;

    do {
	if ((file = mystrtok(&buf, "\t\n\r ,")) != 0)
	    ret = tls_dane_load_trustfile(dane, file);
    } while (file && ret);

    myfree(save);
    return (ret);
}
コード例 #26
0
ファイル: milter.c プロジェクト: execunix/vinos
MILTERS *milter_new(const char *names,
		            int conn_timeout,
		            int cmd_timeout,
		            int msg_timeout,
		            const char *protocol,
		            const char *def_action,
		            MILTER_MACROS *macros)
{
    MILTERS *milters;
    MILTER *head = 0;
    MILTER *tail = 0;
    char   *name;
    MILTER *milter;
    const char *sep = ", \t\r\n";

    /*
     * Parse the milter list.
     */
    milters = (MILTERS *) mymalloc(sizeof(*milters));
    if (names != 0) {
	char   *saved_names = mystrdup(names);
	char   *cp = saved_names;

	while ((name = mystrtok(&cp, sep)) != 0) {
	    milter = milter8_create(name, conn_timeout, cmd_timeout,
				    msg_timeout, protocol, def_action,
				    milters);
	    if (head == 0) {
		head = milter;
	    } else {
		tail->next = milter;
	    }
	    tail = milter;
	}
	myfree(saved_names);
    }
    milters->milter_list = head;
    milters->mac_lookup = 0;
    milters->mac_context = 0;
    milters->macros = macros;
    milters->add_header = 0;
    milters->upd_header = milters->ins_header = 0;
    milters->del_header = 0;
    milters->add_rcpt = milters->del_rcpt = 0;
    milters->repl_body = 0;
    milters->chg_context = 0;
    return (milters);
}
コード例 #27
0
ファイル: gmx_amide_map.c プロジェクト: mreppert/g_amide
int read_coupsites(FILE *fp, t_amide_map *p_map) {
	int i;
	int success = 0;	// Number of map sites successfully allocated
	char line[maxchar];
	t_amide_map map = *p_map;
	
	map.CoupSites = (t_coupsite*) malloc(map.ncoupsites*sizeof(t_coupsite));
	if(map.CoupSites==NULL) {
		map.ncoupsites = 0;
		success = 0;
	}
	for(i=0; i<map.ncoupsites; i++) {
		if(fgets(line, maxchar, fp)!=NULL) {
			int natoms = count_tokens(line, path_delim);
			int error = 0;
			if(natoms>0) {
				map.CoupSites[i].AtomPaths = (t_atom_path*) malloc(natoms*sizeof(t_atom_path));
				if(map.CoupSites[i].AtomPaths!=NULL) {
					map.CoupSites[i].natoms = natoms;
					char token[maxchar], remainder[maxchar];
					int path = 0;
					strcpy(remainder, line);
					while(strlen(remainder)!=0) {
						mystrtok(remainder, token, path_delim);
						set_atom_path(&map.CoupSites[i].AtomPaths[path], token);
						path++;
					}
				} else error = 1;
			} else error = 1;
			if(error) {
				i = map.ncoupsites;
				break;
			}
			success++;
		} else return 0;
	}
	if(success<map.ncoupsites) {
		for(i=0; i<success; i++) {
			free(map.CoupSites[i].AtomPaths);
		}
		free(map.CoupSites);
		map.ncoupsites = 0;
	}
	*p_map = map;
	return 1;
}
コード例 #28
0
ファイル: master_ent.c プロジェクト: tmtm/postfix
static char *get_str_ent(char **bufp, char *name, char *def_val)
{
    char   *value;

    if ((value = mystrtok(bufp, master_blanks)) == 0)
	fatal_with_context("missing \"%s\" field", name);
    if (strcmp(value, "-") == 0) {
	if (def_val == 0)
	    fatal_with_context("field \"%s\" has no default value", name);
	if (warn_compat_break_chroot && strcmp(name, "chroot") == 0)
	    msg_info("%s: using backwards-compatible default setting "
		     "%s=%s", master_conf_context(), name, def_val);
	return (def_val);
    } else {
	return (value);
    }
}
コード例 #29
0
ファイル: maps.c プロジェクト: ystk/debian-postfix
MAPS   *maps_create(const char *title, const char *map_names, int dict_flags)
{
    const char *myname = "maps_create";
    char   *temp;
    char   *bufp;
    static char sep[] = " \t,\r\n";
    MAPS   *maps;
    char   *map_type_name;
    VSTRING *map_type_name_flags;
    DICT   *dict;

    /*
     * Initialize.
     */
    maps = (MAPS *) mymalloc(sizeof(*maps));
    maps->title = mystrdup(title);
    maps->argv = argv_alloc(2);

    /*
     * For each specified type:name pair, either register a new dictionary,
     * or increment the reference count of an existing one.
     */
    if (*map_names) {
	bufp = temp = mystrdup(map_names);
	map_type_name_flags = vstring_alloc(10);

#define OPEN_FLAGS	O_RDONLY

	while ((map_type_name = mystrtok(&bufp, sep)) != 0) {
	    vstring_sprintf(map_type_name_flags, "%s(%o,%s)",
			    map_type_name, OPEN_FLAGS,
			    dict_flags_str(dict_flags));
	    if ((dict = dict_handle(vstring_str(map_type_name_flags))) == 0)
		dict = dict_open(map_type_name, OPEN_FLAGS, dict_flags);
	    if ((dict->flags & dict_flags) != dict_flags)
		msg_panic("%s: map %s has flags 0%o, want flags 0%o",
			  myname, map_type_name, dict->flags, dict_flags);
	    dict_register(vstring_str(map_type_name_flags), dict);
	    argv_add(maps->argv, vstring_str(map_type_name_flags), ARGV_END);
	}
	myfree(temp);
	vstring_free(map_type_name_flags);
    }
    return (maps);
}
コード例 #30
0
ファイル: config.c プロジェクト: platinasystems/openipmi
int
get_uchar(char **tokptr, unsigned char *rval, const char **err)
{
    char *end;
    const char *tok = mystrtok(NULL, " \t\n", tokptr);

    if (!tok) {
	*err = "No integer value given";
	return -1;
    }

    *rval = strtoul(tok, &end, 0);
    if (*end != '\0') {
	*err = "Invalid integer value";
	return -1;
    }
    return 0;
}