[gq-commit] gq/src util.c,1.61,1.62
Status: Beta
Brought to you by:
sur5r
From: <sta...@us...> - 2003-10-05 13:51:43
|
Update of /cvsroot/gqclient/gq/src In directory sc8-pr-cvs1:/tmp/cvs-serv9963 Modified Files: util.c Log Message: * now error_push allows for printf-style variable argument lists, very convenient: no more dealing with an extra message buffer for variable messages. Got rid of many such buffers * UTF-8 safety improvements * Got rid of most hand-knit linked list implementations, replaced them with GLists (errorchains, config->ldapservers, etc.) Index: util.c =================================================================== RCS file: /cvsroot/gqclient/gq/src/util.c,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** util.c 4 Oct 2003 10:12:27 -0000 1.61 --- util.c 5 Oct 2003 13:51:35 -0000 1.62 *************** *** 61,64 **** --- 61,65 ---- #include "mainwin.h" #include "input.h" + #include "utf8-compat.h" #include "../icons/warning.xpm" *************** *** 86,90 **** { LDAP *ld = NULL; - char message[128]; char *binddn = NULL, *bindpw = NULL; int rc = LDAP_SUCCESS; --- 87,90 ---- *************** *** 96,100 **** *ld_out = NULL; ! if (strchr(server->ldaphost, ':') != NULL) { #ifdef HAVE_LDAP_INITIALIZE rc = ldap_initialize(&ld, server->ldaphost); --- 96,100 ---- *ld_out = NULL; ! if (g_utf8_strchr(server->ldaphost, -1, ':') != NULL) { #ifdef HAVE_LDAP_INITIALIZE rc = ldap_initialize(&ld, server->ldaphost); *************** *** 104,110 **** #else ld = NULL; ! snprintf(message, sizeof(message), ! _("Sorry. No URI support available. Your LDAP toolkit does not support LDAP URIs.")); ! error_push(open_context, message); #endif } else { --- 104,109 ---- #else ld = NULL; ! error_push(open_context, ! _("Sorry. No URI support available. Your LDAP toolkit does not support LDAP URIs.")); #endif } else { *************** *** 113,119 **** if(!ld) { ! snprintf(message, sizeof(message), ! _("Failed to initialize LDAP structure.")); ! error_push(open_context, message); } else { --- 112,117 ---- if(!ld) { ! error_push(open_context, ! _("Failed to initialize LDAP structure.")); } else { *************** *** 150,156 **** { if (server->version != LDAP_VERSION3) { ! snprintf(message, sizeof(message), ! _("Couldn't set protocol version to LDAPv3.")); ! error_push(open_context, message); } } --- 148,153 ---- { if (server->version != LDAP_VERSION3) { ! error_push(open_context, ! _("Couldn't set protocol version to LDAPv3.")); } } *************** *** 159,166 **** rc = ldap_start_tls_s(ld, NULL, NULL); if(rc != LDAP_SUCCESS) { ! snprintf(message, sizeof(message), ! _("Couldn't enable TLS on the LDAP connection: %s"), ! ldap_err2string(rc)); ! error_push(open_context, message); push_ldap_addl_error(ld, open_context); ldap_unbind(ld); --- 156,162 ---- rc = ldap_start_tls_s(ld, NULL, NULL); if(rc != LDAP_SUCCESS) { ! error_push(open_context, ! _("Couldn't enable TLS on the LDAP connection: %s"), ! ldap_err2string(rc)); push_ldap_addl_error(ld, open_context); ldap_unbind(ld); *************** *** 169,176 **** } #else ! snprintf(message, sizeof(message), ! _("TLS was not found to be supported by your LDAP libraries.\n" ! "See README.TLS for more information.\n")); ! error_push(open_context, message); #endif /* defined(HAVE_TLS) */ } --- 165,171 ---- } #else ! error_push(open_context, ! _("TLS was not found to be supported by your LDAP libraries.\n" ! "See README.TLS for more information.\n")); #endif /* defined(HAVE_TLS) */ } *************** *** 181,188 **** DEFAULT_LOCAL_CACHE_SIZE); #else ! snprintf(message, sizeof(message), ! _("OpenLDAP client-side caching was not enabled.\n" ! "See configure --help for more information.\n")); ! error_push(open_context, message); #endif } --- 176,182 ---- DEFAULT_LOCAL_CACHE_SIZE); #else ! error_push(open_context, ! _("OpenLDAP client-side caching was not enabled.\n" ! "See configure --help for more information.\n")); #endif } *************** *** 251,261 **** if (rc != LDAP_SUCCESS) { /* Maybe we cannot use LDAPv3 ... try again */ - - ! snprintf(message, sizeof(message), ! _("Couldn't bind LDAP connection: %s"), ! ldap_err2string(rc)); ! error_push(open_context, message); push_ldap_addl_error(ld, open_context); statusbar_msg(""); --- 245,252 ---- if (rc != LDAP_SUCCESS) { /* Maybe we cannot use LDAPv3 ... try again */ ! error_push(open_context, ! _("Couldn't bind LDAP connection: %s"), ! ldap_err2string(rc)); push_ldap_addl_error(ld, open_context); statusbar_msg(""); *************** *** 334,355 **** /* server->bindpw[0] == 0 && */ server->enteredpw[0] == 0) { ! char *ret; ! snprintf(message, sizeof(message), ! _("Password for server %s"), server->ldaphost); ! ! if (query_popup(message, &ret, TRUE /* is_password */)) { ! if (ret) { ! strncpy(server->enteredpw, ret, ! sizeof(server->enteredpw) - 1); ! g_free(ret); ! newpw = 1; ! } else { ! server->enteredpw[0] = 0; ! } ! } else { ! return NULL; ! } } ! if(server->ldapport == 389) { snprintf(message, sizeof(message), --- 325,345 ---- /* server->bindpw[0] == 0 && */ server->enteredpw[0] == 0) { ! char *ret; ! snprintf(message, sizeof(message), ! _("Password for server %s"), server->ldaphost); ! ! if (query_popup(message, &ret, TRUE /* is_password */)) { ! if (ret) { ! g_free_if(server->enteredpw); ! server->enteredpw = ret; ! newpw = 1; ! } else { ! server->enteredpw[0] = 0; ! } ! } else { ! return NULL; ! } } ! if(server->ldapport == 389) { snprintf(message, sizeof(message), *************** *** 776,788 **** { struct ldapserver *server; ! if(name == NULL || name[0] == '\0') return(NULL); ! server = config->ldapservers; ! while(server) { if(!strcmp(server->name, name)) return(server); - server = server->next; } --- 766,778 ---- { struct ldapserver *server; ! GList *I; ! if(name == NULL || name[0] == '\0') return(NULL); ! for (I = config->servers ; I ; I = g_list_next(I)) { ! server = (struct ldapserver *) I->data; if(!strcmp(server->name, name)) return(server); } *************** *** 843,847 **** { /* SHOULD use gq_ldap_explode_dn for this */ ! char *c = strchr(child, ','); if (c && (strcasecmp(c + 1, possible_parent) == 0)) return TRUE; return FALSE; --- 833,837 ---- { /* SHOULD use gq_ldap_explode_dn for this */ ! char *c = g_utf8_strchr(child, -1, ','); if (c && (strcasecmp(c + 1, possible_parent) == 0)) return TRUE; return FALSE; *************** *** 1188,1206 **** struct gq_template *find_template_by_name(const char *templatename) { ! GList *templatelist; ! struct gq_template *template; ! template = NULL; ! templatelist = config->templates; ! while(templatelist) { ! template = (struct gq_template *) templatelist->data; if(!strcasecmp(templatename, template->name)) ! break; ! else ! template = NULL; ! templatelist = templatelist->next; } ! ! return(template); } --- 1178,1190 ---- struct gq_template *find_template_by_name(const char *templatename) { ! GList *I; ! for(I = config->templates ; I ; I = g_list_next(I)) { ! struct gq_template *template = ! (struct gq_template *) I->data; if(!strcasecmp(templatename, template->name)) ! return template; } ! return NULL; } |