Lines Matching refs:data
83 void *data;
119 /* data == NULL means cleanup */
121 ldapdb_getconn(struct ldapdb_data *data)
127 if (data == NULL) {
134 while (threaddata->data != NULL) {
135 conndata = threaddata->data;
137 if (conndata->data != NULL)
138 ldap_unbind((LDAP *)conndata->data);
139 threaddata->data = conndata->next;
149 /* look for connection data for current thread */
153 /* no data for this thread, create empty connection list */
164 threaddata->data = NULL;
174 conndata = ldapdb_find((struct ldapdb_entry *)threaddata->data,
175 data->hostport, strlen(data->hostport));
177 /* no connection data structure for this server, create one */
181 conndata->index = data->hostport;
182 conndata->size = strlen(data->hostport);
183 conndata->data = NULL;
184 ldapdb_insert((struct ldapdb_entry **)&threaddata->data,
188 return (LDAP **)&conndata->data;
192 ldapdb_bind(struct ldapdb_data *data, LDAP **ldp)
200 *ldp = ldap_open(data->hostname, data->portno);
209 if (data->tls) {
214 if (ldap_simple_bind_s(*ldp, data->bindname, data->bindpw) != LDAP_SUCCESS) {
223 struct ldapdb_data *data = dbdata;
236 ldp = ldapdb_getconn(data);
240 ldapdb_bind(data, ldp);
249 fltr = data->filterall;
256 sprintf(data->filtername, "%s))", name);
257 fltr = data->filterone;
260 msgid = ldap_search(*ldp, data->base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0);
262 ldapdb_bind(data, ldp);
264 msgid = ldap_search(*ldp, data->base, LDAP_SCOPE_SUBTREE, fltr, NULL, 0);
276 int ttl = data->defaultttl;
411 parseextensions(char *extensions, struct ldapdb_data *data)
444 data->bindname = value;
446 data->bindpw = value;
449 data->tls = value == NULL || !strcasecmp(value, "true");
461 free_data(struct ldapdb_data *data)
463 if (data->hostport != NULL)
464 isc_mem_free(ns_g_mctx, data->hostport);
465 if (data->hostname != NULL)
466 isc_mem_free(ns_g_mctx, data->hostname);
467 if (data->filterall != NULL)
468 isc_mem_put(ns_g_mctx, data->filterall, data->filteralllen);
469 if (data->filterone != NULL)
470 isc_mem_put(ns_g_mctx, data->filterone, data->filteronelen);
471 isc_mem_put(ns_g_mctx, data, sizeof(struct ldapdb_data));
479 struct ldapdb_data *data;
492 data = isc_mem_get(ns_g_mctx, sizeof(struct ldapdb_data));
493 if (data == NULL)
496 memset(data, 0, sizeof(struct ldapdb_data));
497 data->hostport = isc_mem_strdup(ns_g_mctx, argv[0] + strlen("ldap://"));
498 if (data->hostport == NULL) {
499 free_data(data);
503 data->defaultttl = defaultttl;
505 s = strchr(data->hostport, '/');
508 data->base = s;
542 if (*data->base == '\0') {
543 data->base = NULL;
551 err = parseextensions(extensions, data);
554 free_data(data);
566 if ((data->base != NULL && unhex(data->base) == NULL) ||
568 (data->bindname != NULL && unhex(data->bindname) == NULL) ||
569 (data->bindpw != NULL && unhex(data->bindpw) == NULL)) {
570 free_data(data);
578 data->filteralllen = strlen(zone) + strlen("(zoneName=)") + 1;
579 data->filteronelen = strlen(zone) + strlen("(&(zoneName=)(relativeDomainName=))") + MAXNAMELEN + 1;
581 data->filteralllen = strlen(filter) + strlen(zone) + strlen("(&(zoneName=))") + 1;
582 data->filteronelen = strlen(filter) + strlen(zone) + strlen("(&(zoneName=)(relativeDomainName=))") + MAXNAMELEN + 1;
585 data->filterall = isc_mem_get(ns_g_mctx, data->filteralllen);
586 if (data->filterall == NULL) {
587 free_data(data);
590 data->filterone = isc_mem_get(ns_g_mctx, data->filteronelen);
591 if (data->filterone == NULL) {
592 free_data(data);
597 sprintf(data->filterall, "(zoneName=%s)", zone);
598 sprintf(data->filterone, "(&(zoneName=%s)(relativeDomainName=", zone);
600 sprintf(data->filterall, "(&%s(zoneName=%s))", filter, zone);
601 sprintf(data->filterone, "(&%s(zoneName=%s)(relativeDomainName=", filter, zone);
603 data->filtername = data->filterone + strlen(data->filterone);
606 data->hostname = isc_mem_strdup(ns_g_mctx, data->hostport + (*data->hostport == '[' ? 1 : 0));
607 if (data->hostname == NULL) {
608 free_data(data);
612 if (*data->hostport == '[' &&
613 (s = strchr(data->hostname, ']')) != NULL )
616 s = data->hostname;
620 data->portno = atoi(s);
622 data->portno = LDAP_PORT;
624 *dbdata = data;
630 struct ldapdb_data *data = *dbdata;
635 free_data(data);
663 /* clean up thread data */