diff options
Diffstat (limited to 'modules/addressbook/openldap-extract.h')
-rw-r--r-- | modules/addressbook/openldap-extract.h | 530 |
1 files changed, 265 insertions, 265 deletions
diff --git a/modules/addressbook/openldap-extract.h b/modules/addressbook/openldap-extract.h index 67d5741ce9..7da5800d16 100644 --- a/modules/addressbook/openldap-extract.h +++ b/modules/addressbook/openldap-extract.h @@ -110,12 +110,12 @@ typedef struct ldap_objectclass { } LDAPObjectClass; static void -vfree(gpointer *vec) +vfree (gpointer *vec) { gint i; for (i = 0; vec[i] != NULL; i++) - free(vec[i]); + free (vec[i]); } /* from schema.c */ @@ -159,7 +159,7 @@ struct token { }; static gint -get_token( const gchar ** sp, gchar ** token_val ) +get_token ( const gchar ** sp, gchar ** token_val ) { gint kind; const gchar * p; @@ -192,11 +192,11 @@ get_token( const gchar ** sp, gchar ** token_val ) (*sp)++; if (**sp == '\'') { q = *sp; - res = LDAP_MALLOC(q-p+1); + res = LDAP_MALLOC (q-p+1); if (!res) { kind = TK_OUTOFMEM; } else { - strncpy(res,p,q-p); + strncpy (res,p,q-p); res[q-p] = '\0'; *token_val = res; } @@ -208,7 +208,7 @@ get_token( const gchar ** sp, gchar ** token_val ) default: kind = TK_BAREWORD; p = *sp; - while ( !LDAP_SPACE(**sp) && + while ( !LDAP_SPACE (**sp) && **sp != '(' && **sp != ')' && **sp != '$' && @@ -216,11 +216,11 @@ get_token( const gchar ** sp, gchar ** token_val ) **sp != '\0' ) (*sp)++; q = *sp; - res = LDAP_MALLOC(q-p+1); + res = LDAP_MALLOC (q-p+1); if (!res) { kind = TK_OUTOFMEM; } else { - strncpy(res,p,q-p); + strncpy (res,p,q-p); res[q-p] = '\0'; *token_val = res; } @@ -234,15 +234,15 @@ get_token( const gchar ** sp, gchar ** token_val ) /* Gobble optional whitespace */ static void -parse_whsp(const gchar **sp) +parse_whsp (const gchar **sp) { - while (LDAP_SPACE(**sp)) + while (LDAP_SPACE (**sp)) (*sp)++; } /* Parse a sequence of dot-separated decimal strings */ static gchar * -ldap_int_parse_numericoid(const gchar **sp, gint *code, const gint flags) +ldap_int_parse_numericoid (const gchar **sp, gint *code, const gint flags) { gchar * res = NULL; const gchar * start = *sp; @@ -257,7 +257,7 @@ ldap_int_parse_numericoid(const gchar **sp, gint *code, const gint flags) } /* Each iteration of this loop gets one decimal string */ while (**sp) { - if (!LDAP_DIGIT(**sp)) { + if (!LDAP_DIGIT (**sp)) { /* * Initial gchar is not a digit or gchar after dot is * not a digit @@ -266,7 +266,7 @@ ldap_int_parse_numericoid(const gchar **sp, gint *code, const gint flags) return NULL; } (*sp)++; - while (LDAP_DIGIT(**sp)) + while (LDAP_DIGIT (**sp)) (*sp)++; if (**sp != '.') break; @@ -286,20 +286,20 @@ ldap_int_parse_numericoid(const gchar **sp, gint *code, const gint flags) if (flags & LDAP_SCHEMA_SKIP) { res = (gchar *)start; } else { - res = LDAP_MALLOC(len+1); + res = LDAP_MALLOC (len+1); if (!res) { *code = LDAP_SCHERR_OUTOFMEM; - return(NULL); + return (NULL); } - strncpy(res,start,len); + strncpy (res,start,len); res[len] = '\0'; } - return(res); + return (res); } /* Parse a qdescr or a list of them enclosed in () */ static gchar ** -parse_qdescrs(const gchar **sp, gint *code) +parse_qdescrs (const gchar **sp, gint *code) { gchar ** res; gchar ** res1; @@ -308,58 +308,58 @@ parse_qdescrs(const gchar **sp, gint *code) gint size; gint pos; - parse_whsp(sp); - kind = get_token(sp,&sval); + parse_whsp (sp); + kind = get_token (sp,&sval); if (kind == TK_LEFTPAREN) { /* Let's presume there will be at least 2 entries */ size = 3; - res = LDAP_CALLOC(3,sizeof(gchar *)); + res = LDAP_CALLOC (3,sizeof (gchar *)); if (!res) { *code = LDAP_SCHERR_OUTOFMEM; return NULL; } pos = 0; while (1) { - parse_whsp(sp); - kind = get_token(sp,&sval); + parse_whsp (sp); + kind = get_token (sp,&sval); if (kind == TK_RIGHTPAREN) break; if (kind == TK_QDESCR) { if (pos == size-2) { size++; - res1 = LDAP_REALLOC(res,size*sizeof(gchar *)); + res1 = LDAP_REALLOC (res,size*sizeof (gchar *)); if (!res1) { - LDAP_VFREE(res); - LDAP_FREE(sval); + LDAP_VFREE (res); + LDAP_FREE (sval); *code = LDAP_SCHERR_OUTOFMEM; - return(NULL); + return (NULL); } res = res1; } res[pos++] = sval; res[pos] = NULL; - parse_whsp(sp); + parse_whsp (sp); } else { - LDAP_VFREE(res); - LDAP_FREE(sval); + LDAP_VFREE (res); + LDAP_FREE (sval); *code = LDAP_SCHERR_UNEXPTOKEN; - return(NULL); + return (NULL); } } - parse_whsp(sp); - return(res); + parse_whsp (sp); + return (res); } else if (kind == TK_QDESCR) { - res = LDAP_CALLOC(2,sizeof(gchar *)); + res = LDAP_CALLOC (2,sizeof (gchar *)); if (!res) { *code = LDAP_SCHERR_OUTOFMEM; return NULL; } res[0] = sval; res[1] = NULL; - parse_whsp(sp); + parse_whsp (sp); return res; } else { - LDAP_FREE(sval); + LDAP_FREE (sval); *code = LDAP_SCHERR_BADNAME; return NULL; } @@ -367,7 +367,7 @@ parse_qdescrs(const gchar **sp, gint *code) /* Parse a woid or a $-separated list of them enclosed in () */ static gchar ** -parse_oids(const gchar **sp, gint *code, const gint allow_quoted) +parse_oids (const gchar **sp, gint *code, const gint allow_quoted) { gchar ** res; gchar ** res1; @@ -382,48 +382,48 @@ parse_oids(const gchar **sp, gint *code, const gint allow_quoted) * we are very liberal in what we accept as an OID. Maybe * refine later. */ - parse_whsp(sp); - kind = get_token(sp,&sval); + parse_whsp (sp); + kind = get_token (sp,&sval); if (kind == TK_LEFTPAREN) { /* Let's presume there will be at least 2 entries */ size = 3; - res = LDAP_CALLOC(3,sizeof(gchar *)); + res = LDAP_CALLOC (3,sizeof (gchar *)); if (!res) { *code = LDAP_SCHERR_OUTOFMEM; return NULL; } pos = 0; - parse_whsp(sp); - kind = get_token(sp,&sval); + parse_whsp (sp); + kind = get_token (sp,&sval); if ( kind == TK_BAREWORD || ( allow_quoted && kind == TK_QDSTRING ) ) { res[pos++] = sval; res[pos] = NULL; } else { *code = LDAP_SCHERR_UNEXPTOKEN; - LDAP_FREE(sval); - LDAP_VFREE(res); + LDAP_FREE (sval); + LDAP_VFREE (res); return NULL; } - parse_whsp(sp); + parse_whsp (sp); while (1) { - kind = get_token(sp,&sval); + kind = get_token (sp,&sval); if (kind == TK_RIGHTPAREN) break; if (kind == TK_DOLLAR) { - parse_whsp(sp); - kind = get_token(sp,&sval); + parse_whsp (sp); + kind = get_token (sp,&sval); if ( kind == TK_BAREWORD || ( allow_quoted && kind == TK_QDSTRING ) ) { if (pos == size-2) { size++; - res1 = LDAP_REALLOC(res,size*sizeof(gchar *)); + res1 = LDAP_REALLOC (res,size*sizeof (gchar *)); if (!res1) { - LDAP_FREE(sval); - LDAP_VFREE(res); + LDAP_FREE (sval); + LDAP_VFREE (res); *code = LDAP_SCHERR_OUTOFMEM; - return(NULL); + return (NULL); } res = res1; } @@ -431,53 +431,53 @@ parse_oids(const gchar **sp, gint *code, const gint allow_quoted) res[pos] = NULL; } else { *code = LDAP_SCHERR_UNEXPTOKEN; - LDAP_FREE(sval); - LDAP_VFREE(res); + LDAP_FREE (sval); + LDAP_VFREE (res); return NULL; } - parse_whsp(sp); + parse_whsp (sp); } else { *code = LDAP_SCHERR_UNEXPTOKEN; - LDAP_FREE(sval); - LDAP_VFREE(res); + LDAP_FREE (sval); + LDAP_VFREE (res); return NULL; } } - parse_whsp(sp); - return(res); + parse_whsp (sp); + return (res); } else if ( kind == TK_BAREWORD || ( allow_quoted && kind == TK_QDSTRING ) ) { - res = LDAP_CALLOC(2,sizeof(gchar *)); + res = LDAP_CALLOC (2,sizeof (gchar *)); if (!res) { - LDAP_FREE(sval); + LDAP_FREE (sval); *code = LDAP_SCHERR_OUTOFMEM; return NULL; } res[0] = sval; res[1] = NULL; - parse_whsp(sp); + parse_whsp (sp); return res; } else { - LDAP_FREE(sval); + LDAP_FREE (sval); *code = LDAP_SCHERR_BADNAME; return NULL; } } static void -ldap_objectclass_free(LDAPObjectClass * oc) +ldap_objectclass_free (LDAPObjectClass * oc) { - LDAP_FREE(oc->oc_oid); - if (oc->oc_names) LDAP_VFREE(oc->oc_names); - if (oc->oc_desc) LDAP_FREE(oc->oc_desc); - if (oc->oc_sup_oids) LDAP_VFREE(oc->oc_sup_oids); - if (oc->oc_at_oids_must) LDAP_VFREE(oc->oc_at_oids_must); - if (oc->oc_at_oids_may) LDAP_VFREE(oc->oc_at_oids_may); - LDAP_FREE(oc); + LDAP_FREE (oc->oc_oid); + if (oc->oc_names) LDAP_VFREE (oc->oc_names); + if (oc->oc_desc) LDAP_FREE (oc->oc_desc); + if (oc->oc_sup_oids) LDAP_VFREE (oc->oc_sup_oids); + if (oc->oc_at_oids_must) LDAP_VFREE (oc->oc_at_oids_must); + if (oc->oc_at_oids_may) LDAP_VFREE (oc->oc_at_oids_may); + LDAP_FREE (oc); } static LDAPObjectClass * -ldap_str2objectclass( LDAP_CONST gchar * s, +ldap_str2objectclass ( LDAP_CONST gchar * s, gint * code, LDAP_CONST gchar ** errp, LDAP_CONST unsigned flags ) @@ -503,7 +503,7 @@ ldap_str2objectclass( LDAP_CONST gchar * s, } *errp = s; - oc = LDAP_CALLOC(1,sizeof(LDAPObjectClass)); + oc = LDAP_CALLOC (1,sizeof (LDAPObjectClass)); if (!oc) { *code = LDAP_SCHERR_OUTOFMEM; @@ -511,11 +511,11 @@ ldap_str2objectclass( LDAP_CONST gchar * s, } oc->oc_kind = LDAP_SCHEMA_STRUCTURAL; - kind = get_token(&ss,&sval); + kind = get_token (&ss,&sval); if (kind != TK_LEFTPAREN) { *code = LDAP_SCHERR_NOLEFTPAREN; - LDAP_FREE(sval); - ldap_objectclass_free(oc); + LDAP_FREE (sval); + ldap_objectclass_free (oc); return NULL; } @@ -526,14 +526,14 @@ ldap_str2objectclass( LDAP_CONST gchar * s, * in the wrong format or even no OID at all. We do our best to * extract info from those servers. */ - parse_whsp(&ss); + parse_whsp (&ss); savepos = ss; - oc->oc_oid = ldap_int_parse_numericoid(&ss,code,0); + oc->oc_oid = ldap_int_parse_numericoid (&ss,code,0); if (!oc->oc_oid) { if ((flags & LDAP_SCHEMA_ALLOW_ALL) && (ss == savepos)) { /* Backtracking */ ss = savepos; - kind = get_token(&ss,&sval); + kind = get_token (&ss,&sval); if (kind == TK_BAREWORD) { if ( !strcasecmp(sval, "NAME") || !strcasecmp(sval, "DESC") || @@ -551,196 +551,196 @@ ldap_str2objectclass( LDAP_CONST gchar * s, LDAP_SCHEMA_ALLOW_OID_MACRO ) { /* Non-numerical OID, ignore */ gint len = ss-savepos; - oc->oc_oid = LDAP_MALLOC(len+1); - strncpy(oc->oc_oid, savepos, len); + oc->oc_oid = LDAP_MALLOC (len+1); + strncpy (oc->oc_oid, savepos, len); oc->oc_oid[len] = 0; } } - LDAP_FREE(sval); + LDAP_FREE (sval); } else { *errp = ss; - ldap_objectclass_free(oc); + ldap_objectclass_free (oc); return NULL; } } - parse_whsp(&ss); + parse_whsp (&ss); /* * Beyond this point we will be liberal an accept the items * in any order. */ while (1) { - kind = get_token(&ss,&sval); + kind = get_token (&ss,&sval); switch (kind) { case TK_EOS: *code = LDAP_SCHERR_NORIGHTPAREN; *errp = ss; - ldap_objectclass_free(oc); + ldap_objectclass_free (oc); return NULL; case TK_RIGHTPAREN: return oc; case TK_BAREWORD: if (!strcasecmp(sval,"NAME")) { - LDAP_FREE(sval); + LDAP_FREE (sval); if (seen_name) { *code = LDAP_SCHERR_DUPOPT; *errp = ss; - ldap_objectclass_free(oc); - return(NULL); + ldap_objectclass_free (oc); + return (NULL); } seen_name = 1; - oc->oc_names = parse_qdescrs(&ss,code); + oc->oc_names = parse_qdescrs (&ss,code); if (!oc->oc_names) { if (*code != LDAP_SCHERR_OUTOFMEM) *code = LDAP_SCHERR_BADNAME; *errp = ss; - ldap_objectclass_free(oc); + ldap_objectclass_free (oc); return NULL; } } else if (!strcasecmp(sval,"DESC")) { - LDAP_FREE(sval); + LDAP_FREE (sval); if (seen_desc) { *code = LDAP_SCHERR_DUPOPT; *errp = ss; - ldap_objectclass_free(oc); - return(NULL); + ldap_objectclass_free (oc); + return (NULL); } seen_desc = 1; - parse_whsp(&ss); - kind = get_token(&ss,&sval); + parse_whsp (&ss); + kind = get_token (&ss,&sval); if (kind != TK_QDSTRING) { *code = LDAP_SCHERR_UNEXPTOKEN; *errp = ss; - LDAP_FREE(sval); - ldap_objectclass_free(oc); + LDAP_FREE (sval); + ldap_objectclass_free (oc); return NULL; } oc->oc_desc = sval; - parse_whsp(&ss); + parse_whsp (&ss); } else if (!strcasecmp(sval,"OBSOLETE")) { - LDAP_FREE(sval); + LDAP_FREE (sval); if (seen_obsolete) { *code = LDAP_SCHERR_DUPOPT; *errp = ss; - ldap_objectclass_free(oc); - return(NULL); + ldap_objectclass_free (oc); + return (NULL); } seen_obsolete = 1; oc->oc_obsolete = LDAP_SCHEMA_YES; - parse_whsp(&ss); + parse_whsp (&ss); } else if (!strcasecmp(sval,"SUP")) { - LDAP_FREE(sval); + LDAP_FREE (sval); if (seen_sup) { *code = LDAP_SCHERR_DUPOPT; *errp = ss; - ldap_objectclass_free(oc); - return(NULL); + ldap_objectclass_free (oc); + return (NULL); } seen_sup = 1; - oc->oc_sup_oids = parse_oids(&ss, + oc->oc_sup_oids = parse_oids (&ss, code, flags); if (!oc->oc_sup_oids) { *errp = ss; - ldap_objectclass_free(oc); + ldap_objectclass_free (oc); return NULL; } } else if (!strcasecmp(sval,"ABSTRACT")) { - LDAP_FREE(sval); + LDAP_FREE (sval); if (seen_kind) { *code = LDAP_SCHERR_DUPOPT; *errp = ss; - ldap_objectclass_free(oc); - return(NULL); + ldap_objectclass_free (oc); + return (NULL); } seen_kind = 1; oc->oc_kind = LDAP_SCHEMA_ABSTRACT; - parse_whsp(&ss); + parse_whsp (&ss); } else if (!strcasecmp(sval,"STRUCTURAL")) { - LDAP_FREE(sval); + LDAP_FREE (sval); if (seen_kind) { *code = LDAP_SCHERR_DUPOPT; *errp = ss; - ldap_objectclass_free(oc); - return(NULL); + ldap_objectclass_free (oc); + return (NULL); } seen_kind = 1; oc->oc_kind = LDAP_SCHEMA_STRUCTURAL; - parse_whsp(&ss); + parse_whsp (&ss); } else if (!strcasecmp(sval,"AUXILIARY")) { - LDAP_FREE(sval); + LDAP_FREE (sval); if (seen_kind) { *code = LDAP_SCHERR_DUPOPT; *errp = ss; - ldap_objectclass_free(oc); - return(NULL); + ldap_objectclass_free (oc); + return (NULL); } seen_kind = 1; oc->oc_kind = LDAP_SCHEMA_AUXILIARY; - parse_whsp(&ss); + parse_whsp (&ss); } else if (!strcasecmp(sval,"MUST")) { - LDAP_FREE(sval); + LDAP_FREE (sval); if (seen_must) { *code = LDAP_SCHERR_DUPOPT; *errp = ss; - ldap_objectclass_free(oc); - return(NULL); + ldap_objectclass_free (oc); + return (NULL); } seen_must = 1; - oc->oc_at_oids_must = parse_oids(&ss,code,0); + oc->oc_at_oids_must = parse_oids (&ss,code,0); if (!oc->oc_at_oids_must) { *errp = ss; - ldap_objectclass_free(oc); + ldap_objectclass_free (oc); return NULL; } - parse_whsp(&ss); + parse_whsp (&ss); } else if (!strcasecmp(sval,"MAY")) { - LDAP_FREE(sval); + LDAP_FREE (sval); if (seen_may) { *code = LDAP_SCHERR_DUPOPT; *errp = ss; - ldap_objectclass_free(oc); - return(NULL); + ldap_objectclass_free (oc); + return (NULL); } seen_may = 1; - oc->oc_at_oids_may = parse_oids(&ss,code,0); + oc->oc_at_oids_may = parse_oids (&ss,code,0); if (!oc->oc_at_oids_may) { *errp = ss; - ldap_objectclass_free(oc); + ldap_objectclass_free (oc); return NULL; } - parse_whsp(&ss); + parse_whsp (&ss); } else if (sval[0] == 'X' && sval[1] == '-') { /* Should be parse_qdstrings */ - ext_vals = parse_qdescrs(&ss, code); + ext_vals = parse_qdescrs (&ss, code); if (!ext_vals) { *errp = ss; - ldap_objectclass_free(oc); + ldap_objectclass_free (oc); return NULL; } #if 0 - if ( add_extension(&oc->oc_extensions, + if ( add_extension (&oc->oc_extensions, sval, ext_vals) ) { *code = LDAP_SCHERR_OUTOFMEM; *errp = ss; - LDAP_FREE(sval); - ldap_objectclass_free(oc); + LDAP_FREE (sval); + ldap_objectclass_free (oc); return NULL; } #endif } else { *code = LDAP_SCHERR_UNEXPTOKEN; *errp = ss; - LDAP_FREE(sval); - ldap_objectclass_free(oc); + LDAP_FREE (sval); + ldap_objectclass_free (oc); return NULL; } break; default: *code = LDAP_SCHERR_UNEXPTOKEN; *errp = ss; - LDAP_FREE(sval); - ldap_objectclass_free(oc); + LDAP_FREE (sval); + ldap_objectclass_free (oc); return NULL; } } @@ -752,10 +752,10 @@ ldap_str2objectclass( LDAP_CONST gchar * s, #define LDAP_UTF8_INCR(p) ((p)=LDAP_UTF8_NEXT((p))) #define ldap_x_utf8_to_ucs4(str) g_utf8_get_char(str) -static gchar *ldap_utf8_strchr( const gchar *str, const gchar *chr ) +static gchar *ldap_utf8_strchr ( const gchar *str, const gchar *chr ) { - for (; *str != '\0'; LDAP_UTF8_INCR(str) ) { - if (ldap_x_utf8_to_ucs4( str ) == ldap_x_utf8_to_ucs4( chr )) { + for (; *str != '\0'; LDAP_UTF8_INCR (str) ) { + if (ldap_x_utf8_to_ucs4 ( str ) == ldap_x_utf8_to_ucs4 ( chr )) { return (gchar *) str; } } @@ -763,14 +763,14 @@ static gchar *ldap_utf8_strchr( const gchar *str, const gchar *chr ) return NULL; } -static gsize ldap_utf8_strcspn( const gchar *str, const gchar *set ) +static gsize ldap_utf8_strcspn ( const gchar *str, const gchar *set ) { const gchar *cstr; const gchar *cset; - for (cstr = str; *cstr != '\0'; LDAP_UTF8_INCR(cstr)) { - for (cset = set; *cset != '\0'; LDAP_UTF8_INCR(cset)) { - if (ldap_x_utf8_to_ucs4( cstr ) == ldap_x_utf8_to_ucs4( cset )) { + for (cstr = str; *cstr != '\0'; LDAP_UTF8_INCR (cstr)) { + for (cset = set; *cset != '\0'; LDAP_UTF8_INCR (cset)) { + if (ldap_x_utf8_to_ucs4 ( cstr ) == ldap_x_utf8_to_ucs4 ( cset )) { return cstr - str; } } @@ -779,18 +779,18 @@ static gsize ldap_utf8_strcspn( const gchar *str, const gchar *set ) return cstr - str; } -static gsize ldap_utf8_strspn( const gchar *str, const gchar *set ) +static gsize ldap_utf8_strspn ( const gchar *str, const gchar *set ) { const gchar *cstr; const gchar *cset; - for (cstr = str; *cstr != '\0'; LDAP_UTF8_INCR(cstr)) { - for (cset = set; ; LDAP_UTF8_INCR(cset)) { + for (cstr = str; *cstr != '\0'; LDAP_UTF8_INCR (cstr)) { + for (cset = set; ; LDAP_UTF8_INCR (cset)) { if (*cset == '\0') { return cstr - str; } - if (ldap_x_utf8_to_ucs4( cstr ) == ldap_x_utf8_to_ucs4( cset )) { + if (ldap_x_utf8_to_ucs4 ( cstr ) == ldap_x_utf8_to_ucs4 ( cset )) { break; } } @@ -799,7 +799,7 @@ static gsize ldap_utf8_strspn( const gchar *str, const gchar *set ) return cstr - str; } -static gchar *ldap_utf8_strtok(gchar *str, const gchar *sep, gchar **last) +static gchar *ldap_utf8_strtok (gchar *str, const gchar *sep, gchar **last) { gchar *begin; gchar *end; @@ -808,17 +808,17 @@ static gchar *ldap_utf8_strtok(gchar *str, const gchar *sep, gchar **last) begin = str ? str : *last; - begin += ldap_utf8_strspn( begin, sep ); + begin += ldap_utf8_strspn ( begin, sep ); if (*begin == '\0') { *last = NULL; return NULL; } - end = &begin[ ldap_utf8_strcspn( begin, sep ) ]; + end = &begin[ ldap_utf8_strcspn ( begin, sep ) ]; if (*end != '\0') { - gchar *next = LDAP_UTF8_NEXT( end ); + gchar *next = LDAP_UTF8_NEXT ( end ); *end = '\0'; end = next; } @@ -868,7 +868,7 @@ typedef struct ldap_url_desc { /* from url.c */ static const gchar * -skip_url_prefix( +skip_url_prefix ( const gchar *url, gint *enclosedp, const gchar **scheme ) @@ -880,7 +880,7 @@ skip_url_prefix( const gchar *p; if (url == NULL) { - return( NULL ); + return ( NULL ); } p = url; @@ -894,48 +894,48 @@ skip_url_prefix( } /* skip leading "URL:" (if any) */ - if (strncasecmp( p, LDAP_URL_URLCOLON, LDAP_URL_URLCOLON_LEN ) == 0) { + if (strncasecmp ( p, LDAP_URL_URLCOLON, LDAP_URL_URLCOLON_LEN ) == 0) { p += LDAP_URL_URLCOLON_LEN; } /* check for "ldap://" prefix */ - if (strncasecmp( p, LDAP_URL_PREFIX, LDAP_URL_PREFIX_LEN ) == 0) { + if (strncasecmp ( p, LDAP_URL_PREFIX, LDAP_URL_PREFIX_LEN ) == 0) { /* skip over "ldap://" prefix and return success */ p += LDAP_URL_PREFIX_LEN; *scheme = "ldap"; - return( p ); + return ( p ); } /* check for "ldaps://" prefix */ - if (strncasecmp( p, LDAPS_URL_PREFIX, LDAPS_URL_PREFIX_LEN ) == 0) { + if (strncasecmp ( p, LDAPS_URL_PREFIX, LDAPS_URL_PREFIX_LEN ) == 0) { /* skip over "ldaps://" prefix and return success */ p += LDAPS_URL_PREFIX_LEN; *scheme = "ldaps"; - return( p ); + return ( p ); } /* check for "ldapi://" prefix */ - if (strncasecmp( p, LDAPI_URL_PREFIX, LDAPI_URL_PREFIX_LEN ) == 0) { + if (strncasecmp ( p, LDAPI_URL_PREFIX, LDAPI_URL_PREFIX_LEN ) == 0) { /* skip over "ldapi://" prefix and return success */ p += LDAPI_URL_PREFIX_LEN; *scheme = "ldapi"; - return( p ); + return ( p ); } #ifdef LDAP_CONNECTIONLESS /* check for "cldap://" prefix */ - if (strncasecmp( p, LDAPC_URL_PREFIX, LDAPC_URL_PREFIX_LEN ) == 0) { + if (strncasecmp ( p, LDAPC_URL_PREFIX, LDAPC_URL_PREFIX_LEN ) == 0) { /* skip over "cldap://" prefix and return success */ p += LDAPC_URL_PREFIX_LEN; *scheme = "cldap"; - return( p ); + return ( p ); } #endif - return( NULL ); + return ( NULL ); } -static gint str2scope( const gchar *p ) +static gint str2scope ( const gchar *p ) { if (strcasecmp( p, "one" ) == 0) { return LDAP_SCOPE_ONELEVEL; @@ -953,53 +953,53 @@ static gint str2scope( const gchar *p ) return LDAP_SCOPE_SUBTREE; } - return( -1 ); + return ( -1 ); } static void -ldap_free_urldesc( LDAPURLDesc *ludp ) +ldap_free_urldesc ( LDAPURLDesc *ludp ) { if (ludp == NULL) { return; } if (ludp->lud_scheme != NULL) { - LDAP_FREE( ludp->lud_scheme ); + LDAP_FREE ( ludp->lud_scheme ); } if (ludp->lud_host != NULL) { - LDAP_FREE( ludp->lud_host ); + LDAP_FREE ( ludp->lud_host ); } if (ludp->lud_dn != NULL) { - LDAP_FREE( ludp->lud_dn ); + LDAP_FREE ( ludp->lud_dn ); } if (ludp->lud_filter != NULL) { - LDAP_FREE( ludp->lud_filter); + LDAP_FREE ( ludp->lud_filter); } if (ludp->lud_attrs != NULL) { - LDAP_VFREE( ludp->lud_attrs ); + LDAP_VFREE ( ludp->lud_attrs ); } if (ludp->lud_exts != NULL) { - LDAP_VFREE( ludp->lud_exts ); + LDAP_VFREE ( ludp->lud_exts ); } - LDAP_FREE( ludp ); + LDAP_FREE ( ludp ); } static gint -ldap_int_unhex( gint c ) +ldap_int_unhex ( gint c ) { - return( c >= '0' && c <= '9' ? c - '0' + return ( c >= '0' && c <= '9' ? c - '0' : c >= 'A' && c <= 'F' ? c - 'A' + 10 : c - 'a' + 10 ); } static void -ldap_pvt_hex_unescape( gchar *s ) +ldap_pvt_hex_unescape ( gchar *s ) { /* * Remove URL hex escapes from s... done in place. The basic concept for @@ -1026,7 +1026,7 @@ ldap_pvt_hex_unescape( gchar *s ) } static gchar ** -ldap_str2charray( const gchar *str_in, const gchar *brkstr ) +ldap_str2charray ( const gchar *str_in, const gchar *brkstr ) { gchar **res; gchar *str, *s; @@ -1034,39 +1034,39 @@ ldap_str2charray( const gchar *str_in, const gchar *brkstr ) gint i; /* protect the input string from strtok */ - str = LDAP_STRDUP( str_in ); + str = LDAP_STRDUP ( str_in ); if (str == NULL) { return NULL; } i = 1; for (s = str; *s; s++) { - if (ldap_utf8_strchr( brkstr, s ) != NULL) { + if (ldap_utf8_strchr ( brkstr, s ) != NULL) { i++; } } - res = (gchar **) LDAP_MALLOC( (i + 1) * sizeof(gchar *) ); + res = (gchar **) LDAP_MALLOC ( (i + 1) * sizeof (gchar *) ); if (res == NULL) { - LDAP_FREE( str ); + LDAP_FREE ( str ); return NULL; } i = 0; - for (s = ldap_utf8_strtok( str, brkstr, &lasts); + for (s = ldap_utf8_strtok ( str, brkstr, &lasts); s != NULL; - s = ldap_utf8_strtok( NULL, brkstr, &lasts ) ) + s = ldap_utf8_strtok ( NULL, brkstr, &lasts ) ) { - res[i] = LDAP_STRDUP( s ); + res[i] = LDAP_STRDUP ( s ); if (res[i] == NULL) { for (--i; i >= 0; i--) { - LDAP_FREE( res[i] ); + LDAP_FREE ( res[i] ); } - LDAP_FREE( res ); - LDAP_FREE( str ); + LDAP_FREE ( res ); + LDAP_FREE ( str ); return NULL; } @@ -1075,12 +1075,12 @@ ldap_str2charray( const gchar *str_in, const gchar *brkstr ) res[i] = NULL; - LDAP_FREE( str ); - return( res ); + LDAP_FREE ( str ); + return ( res ); } static gint -ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) +ldap_url_parse_ext ( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) { /* * Pick apart the pieces of an LDAP URL. @@ -1099,25 +1099,25 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) *ludpp = NULL; /* pessimistic */ - url_tmp = skip_url_prefix( url_in, &enclosed, &scheme ); + url_tmp = skip_url_prefix ( url_in, &enclosed, &scheme ); if (url_tmp == NULL) { return LDAP_URL_ERR_BADSCHEME; } - assert( scheme ); + assert ( scheme ); /* make working copy of the remainder of the URL */ - url = LDAP_STRDUP( url_tmp ); + url = LDAP_STRDUP ( url_tmp ); if (url == NULL) { return LDAP_URL_ERR_MEM; } if (enclosed) { - p = &url[strlen(url)-1]; + p = &url[strlen (url)-1]; if (*p != '>') { - LDAP_FREE( url ); + LDAP_FREE ( url ); return LDAP_URL_ERR_BADENCLOSURE; } @@ -1125,10 +1125,10 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) } /* allocate return struct */ - ludp = (LDAPURLDesc *)LDAP_CALLOC( 1, sizeof( LDAPURLDesc )); + ludp = (LDAPURLDesc *)LDAP_CALLOC ( 1, sizeof ( LDAPURLDesc )); if (ludp == NULL) { - LDAP_FREE( url ); + LDAP_FREE ( url ); return LDAP_URL_ERR_MEM; } @@ -1142,16 +1142,16 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) ludp->lud_filter = NULL; ludp->lud_exts = NULL; - ludp->lud_scheme = LDAP_STRDUP( scheme ); + ludp->lud_scheme = LDAP_STRDUP ( scheme ); if (ludp->lud_scheme == NULL) { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_MEM; } /* scan forward for '/' that marks end of hostport and begin. of dn */ - p = strchr( url, '/' ); + p = strchr ( url, '/' ); if (p != NULL) { /* terminate hostport; point to start of dn */ @@ -1160,46 +1160,46 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) /* IPv6 syntax with [ip address]:port */ if (*url == '[') { - r = strchr( url, ']' ); + r = strchr ( url, ']' ); if (r == NULL) { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_BADURL; } *r++ = '\0'; - q = strchr( r, ':' ); + q = strchr ( r, ':' ); } else { - q = strchr( url, ':' ); + q = strchr ( url, ':' ); } if (q != NULL) { gchar *next; *q++ = '\0'; - ldap_pvt_hex_unescape( q ); + ldap_pvt_hex_unescape ( q ); if (*q == '\0') { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_BADURL; } - ludp->lud_port = strtol( q, &next, 10 ); + ludp->lud_port = strtol ( q, &next, 10 ); if (next == NULL || next[0] != '\0') { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_BADURL; } } - ldap_pvt_hex_unescape( url ); + ldap_pvt_hex_unescape ( url ); /* If [ip address]:port syntax, url is [ip and we skip the [ */ - ludp->lud_host = LDAP_STRDUP( url + ( *url == '[' ) ); + ludp->lud_host = LDAP_STRDUP ( url + ( *url == '[' ) ); if (ludp->lud_host == NULL) { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_MEM; } @@ -1212,35 +1212,35 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) * but we need to account for it. Fortunately it can't be confused with * anything real. */ - if ( (p == NULL) && (q != NULL) && ((q = strchr( q, '?')) != NULL)) { + if ( (p == NULL) && (q != NULL) && ((q = strchr ( q, '?')) != NULL)) { q++; /* ? immediately followed by question */ if ( *q == '?') { q++; if (*q != '\0') { /* parse dn part */ - ldap_pvt_hex_unescape( q ); - ludp->lud_dn = LDAP_STRDUP( q ); + ldap_pvt_hex_unescape ( q ); + ludp->lud_dn = LDAP_STRDUP ( q ); } else { ludp->lud_dn = LDAP_STRDUP( "" ); } if (ludp->lud_dn == NULL) { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_MEM; } } } if (p == NULL) { - LDAP_FREE( url ); + LDAP_FREE ( url ); *ludpp = ludp; return LDAP_URL_SUCCESS; } /* scan forward for '?' that may marks end of dn */ - q = strchr( p, '?' ); + q = strchr ( p, '?' ); if (q != NULL) { /* terminate dn part */ @@ -1249,28 +1249,28 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) if (*p != '\0') { /* parse dn part */ - ldap_pvt_hex_unescape( p ); - ludp->lud_dn = LDAP_STRDUP( p ); + ldap_pvt_hex_unescape ( p ); + ludp->lud_dn = LDAP_STRDUP ( p ); } else { ludp->lud_dn = LDAP_STRDUP( "" ); } if (ludp->lud_dn == NULL) { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_MEM; } if (q == NULL) { /* no more */ - LDAP_FREE( url ); + LDAP_FREE ( url ); *ludpp = ludp; return LDAP_URL_SUCCESS; } /* scan forward for '?' that may marks end of attributes */ p = q; - q = strchr( p, '?' ); + q = strchr ( p, '?' ); if (q != NULL) { /* terminate attributes part */ @@ -1279,26 +1279,26 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) if (*p != '\0') { /* parse attributes */ - ldap_pvt_hex_unescape( p ); + ldap_pvt_hex_unescape ( p ); ludp->lud_attrs = ldap_str2charray( p, "," ); if (ludp->lud_attrs == NULL) { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_BADATTRS; } } if (q == NULL) { /* no more */ - LDAP_FREE( url ); + LDAP_FREE ( url ); *ludpp = ludp; return LDAP_URL_SUCCESS; } /* scan forward for '?' that may marks end of scope */ p = q; - q = strchr( p, '?' ); + q = strchr ( p, '?' ); if (q != NULL) { /* terminate the scope part */ @@ -1307,26 +1307,26 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) if (*p != '\0') { /* parse the scope */ - ldap_pvt_hex_unescape( p ); - ludp->lud_scope = str2scope( p ); + ldap_pvt_hex_unescape ( p ); + ludp->lud_scope = str2scope ( p ); if (ludp->lud_scope == -1) { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_BADSCOPE; } } if (q == NULL) { /* no more */ - LDAP_FREE( url ); + LDAP_FREE ( url ); *ludpp = ludp; return LDAP_URL_SUCCESS; } /* scan forward for '?' that may marks end of filter */ p = q; - q = strchr( p, '?' ); + q = strchr ( p, '?' ); if (q != NULL) { /* terminate the filter part */ @@ -1335,40 +1335,40 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) if (*p != '\0') { /* parse the filter */ - ldap_pvt_hex_unescape( p ); + ldap_pvt_hex_unescape ( p ); if (!*p) { /* missing filter */ - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_BADFILTER; } - LDAP_FREE( ludp->lud_filter ); - ludp->lud_filter = LDAP_STRDUP( p ); + LDAP_FREE ( ludp->lud_filter ); + ludp->lud_filter = LDAP_STRDUP ( p ); if (ludp->lud_filter == NULL) { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_MEM; } } if (q == NULL) { /* no more */ - LDAP_FREE( url ); + LDAP_FREE ( url ); *ludpp = ludp; return LDAP_URL_SUCCESS; } /* scan forward for '?' that may marks end of extensions */ p = q; - q = strchr( p, '?' ); + q = strchr ( p, '?' ); if (q != NULL) { /* extra '?' */ - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_BADURL; } @@ -1376,13 +1376,13 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) ludp->lud_exts = ldap_str2charray( p, "," ); if (ludp->lud_exts == NULL) { - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_BADEXTS; } for (i=0; ludp->lud_exts[i] != NULL; i++) { - ldap_pvt_hex_unescape( ludp->lud_exts[i] ); + ldap_pvt_hex_unescape ( ludp->lud_exts[i] ); if (*ludp->lud_exts[i] == '!') { /* count the number of critical extensions */ @@ -1392,21 +1392,21 @@ ldap_url_parse_ext( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) if (i == 0) { /* must have 1 or more */ - LDAP_FREE( url ); - ldap_free_urldesc( ludp ); + LDAP_FREE ( url ); + ldap_free_urldesc ( ludp ); return LDAP_URL_ERR_BADEXTS; } /* no more */ *ludpp = ludp; - LDAP_FREE( url ); + LDAP_FREE ( url ); return LDAP_URL_SUCCESS; } static gint -ldap_url_parse( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) +ldap_url_parse ( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) { - gint rc = ldap_url_parse_ext( url_in, ludpp ); + gint rc = ldap_url_parse_ext ( url_in, ludpp ); if (rc != LDAP_URL_SUCCESS) { return rc; @@ -1417,7 +1417,7 @@ ldap_url_parse( LDAP_CONST gchar *url_in, LDAPURLDesc **ludpp ) } if ((*ludpp)->lud_host != NULL && *(*ludpp)->lud_host == '\0') { - LDAP_FREE( (*ludpp)->lud_host ); + LDAP_FREE ( (*ludpp)->lud_host ); (*ludpp)->lud_host = NULL; } |