Changeset 677a45b in code for icb.c


Ignore:
Timestamp:
Apr 22, 2015, 5:28:48 PM (10 years ago)
Author:
Mike Belopuhov <mike@…>
Branches:
master
Children:
176b6ef
Parents:
5dfeb4c
Message:

Remove group passwords and introduce new tokenizer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icb.c

    r5dfeb4c r677a45b  
    168168                        return (1);
    169169                } else {
    170                         if ((ig = icb_addgroup(is, group, NULL)) == NULL) {
     170                        if ((ig = icb_addgroup(is, group)) == NULL) {
    171171                                icb_error(is, "Can't create group %s", group);
    172172                                return (0);
     
    441441 */
    442442struct icb_group *
    443 icb_addgroup(struct icb_session *is, char *name, char *mpass)
     443icb_addgroup(struct icb_session *is, char *name)
    444444{
    445445        struct icb_group *ig;
     
    448448                return (NULL);
    449449        strlcpy(ig->name, name, sizeof ig->name);
    450         if (mpass)
    451                 strlcpy(ig->mpass, mpass, sizeof ig->mpass);
    452450        if (is)
    453451                ig->mod = is;
     
    628626
    629627/*
     628 *  icb_token: copies a sequence of characters delimited by the 'sep' character
     629 *             from the source buffer 'buf' at offset indicated by 'bufptr' to
     630 *             the destination buffer 'dst' and sets 'bufptr' to the next byte
     631 *             after 'sep'.
     632 */
     633int
     634icb_token(char *buf, int len, char **bufptr, char *dst, int dlen, int sep)
     635{
     636        char *start;
     637        int i, ret;
     638
     639        if (buf == NULL || len <= 0 || dlen <= 0)
     640                return (0);
     641        if (*bufptr == NULL)
     642                *bufptr = buf;
     643        start = *bufptr;
     644        for (i = *bufptr - buf; i < len; i++, (*bufptr)++) {
     645                if (**bufptr == sep || **bufptr == '\0') {
     646                        /* copy and null terminate the token */
     647                        ret = strlcpy(dst, start,
     648                            MIN(*bufptr - start + 1, dlen));
     649                        if (**bufptr != '\0')
     650                                (*bufptr)++;
     651                        return (ret);
     652                }
     653        }
     654        /*
     655         * Reached the end of the buffer without finding a field separator
     656         * nor the end of line character.  If we have advanced our pointer
     657         * we should copy the resulting single field out.
     658         */
     659        if (*bufptr - start > 0) {
     660                ret = strlcpy(dst, start, MIN(*bufptr - start + 1, dlen));
     661                return (ret);
     662        }
     663        return (0);
     664}
     665
     666/*
    630667 *  icb_vis: strnvis-like function that escapes percentages as well
    631668 */
Note: See TracChangeset for help on using the changeset viewer.