util/yaz-illclient.c
struct nameval *parse_nameval( char *arg ) {
    struct nameval *nv = (struct nameval *) xmalloc(sizeof(*nv));
    char *p=arg;
    int len;
    if (!p || !*p)
        return 0; /* yeah, leaks a bit of memory. so what */
    while ( *p && ( *p != '=' ) )
        p++;
    len = p - arg;
    if (!len)
        return 0;
    nv->name = (char *) xmalloc(len+1);
    strncpy(nv->name, arg, len);
    nv->name[len]='\0';
    if (*p == '=' )
        p++; /* skip the '=' */
    else
        return 0; /* oops, no '=' */
    if (!*p)
        return 0; /* no value */
    nv->val=xstrdup(p);
    nv->next=0;
    yaz_log(YLOG_DEBUG,"parse_nameval: n='%s' v='%s'", nv->name, nv->val );
    return nv;
}
/** \brief parse a parameter string */
/* string is like 'name=value' */
\brief parse a parameter string
string is like 'name=value'
\ brief parse a parameter string string is like ' name = value '
struct nameval *parse_nameval( char *arg ) {
    struct nameval *nv = (struct nameval *) xmalloc(sizeof(*nv));
    char *p=arg;
    int len;
    if (!p || !*p)
        return 0; 
    while ( *p && ( *p != '=' ) )
        p++;
    len = p - arg;
    if (!len)
        return 0;
    nv->name = (char *) xmalloc(len+1);
    strncpy(nv->name, arg, len);
    nv->name[len]='\0';
    if (*p == '=' )
        p++; 
    else
        return 0; 
    if (!*p)
        return 0; 
    nv->val=xstrdup(p);
    nv->next=0;
    yaz_log(YLOG_DEBUG,"parse_nameval: n='%s' v='%s'", nv->name, nv->val );
    return nv;
}
struct nameval * parse_nameval ( char * arg ) { struct nameval * nv = ( struct nameval * ) xmalloc ( sizeof ( * nv ) ) ; char * p = arg ; int len ; if ( ! p || ! * p ) return 0 ; while ( * p && ( * p != ' ' ) ) p ++ ; len = p - arg ; if ( ! len ) return 0 ; nv -> name = ( char * ) xmalloc ( len + 1 ) ; strncpy ( nv -> name , arg , len ) ; nv -> name [ len ] = ' \0 ' ; if ( * p == ' ' ) p ++ ; else return 0 ; if ( ! * p ) return 0 ; nv -> val = xstrdup ( p ) ; nv -> next = 0 ; yaz_log ( YLOG_DEBUG , " " , nv -> name , nv -> val ) ; return nv ; }
\brief parse a parameter string
string is like 'name=value'
\ brief parse a parameter string string is like ' name = value '
/* yeah, leaks a bit of memory. so what */ /* skip the '=' */ /* oops, no '=' */ /* no value */