Lines Matching refs:ctx

65 static int	parse_config_file(struct hesiod_p *ctx, const char *filename);
66 static char ** get_txt_records(struct hesiod_p *ctx, int class,
68 static int init(struct hesiod_p *ctx);
77 struct hesiod_p *ctx;
80 ctx = malloc(sizeof(struct hesiod_p));
81 if (ctx == 0) {
86 memset(ctx, 0, sizeof (*ctx));
88 if (parse_config_file(ctx, _PATH_HESIOD_CONF) < 0) {
93 ctx->LHS = malloc(strlen(DEF_LHS) + 1);
94 ctx->RHS = malloc(strlen(DEF_RHS) + 1);
95 if (ctx->LHS == NULL || ctx->RHS == NULL) {
99 strcpy(ctx->LHS, DEF_LHS); /* (checked) */
100 strcpy(ctx->RHS, DEF_RHS); /* (checked) */
111 if (ctx->RHS)
112 free(ctx->RHS);
113 ctx->RHS = malloc(RHSlen);
114 if (!ctx->RHS) {
119 strcpy(ctx->RHS, cp); /* (checked) */
121 strcpy(ctx->RHS, "."); /* (checked) */
122 strcat(ctx->RHS, cp); /* (checked) */
130 if (!ctx->RHS) {
136 if (res_ninit(ctx->res) < 0)
140 *context = ctx;
144 hesiod_end(ctx);
153 struct hesiod_p *ctx = (struct hesiod_p *) context;
156 if (ctx->res)
157 res_nclose(ctx->res);
158 if (ctx->RHS)
159 free(ctx->RHS);
160 if (ctx->LHS)
161 free(ctx->LHS);
162 if (ctx->res && ctx->free_res)
163 (*ctx->free_res)(ctx->res);
164 free(ctx);
174 struct hesiod_p *ctx = (struct hesiod_p *) context;
191 RHS = ctx->RHS;
200 (ctx->LHS ? strlen(ctx->LHS) : 0) + 4)) == NULL) {
212 if (ctx->LHS) {
213 if (ctx->LHS[0] != '.')
215 strcat(bindname, ctx->LHS);
233 struct hesiod_p *ctx = (struct hesiod_p *) context;
239 if (init(ctx) == -1) {
244 if ((retvec = get_txt_records(ctx, C_IN, bindname))) {
252 retvec = get_txt_records(ctx, C_HS, bindname);
272 parse_config_file(struct hesiod_p *ctx, const char *filename) {
281 if (ctx->RHS)
282 free(ctx->RHS);
283 if (ctx->LHS)
284 free(ctx->LHS);
285 ctx->RHS = ctx->LHS = 0;
312 cpp = &ctx->LHS;
314 cpp = &ctx->RHS;
330 if (ctx->RHS)
331 free(ctx->RHS);
332 if (ctx->LHS)
333 free(ctx->LHS);
334 ctx->RHS = ctx->LHS = 0;
343 get_txt_records(struct hesiod_p *ctx, int class, const char *name) {
360 n = res_nmkquery(ctx->res, QUERY, name, class, T_TXT, NULL, 0,
366 n = res_nsend(ctx->res, qbuf, n, abuf, MAX_HESRESP);
464 struct hesiod_p *ctx = context;
466 if (!ctx->res) {
474 __hesiod_res_set(ctx, res, free);
477 return (ctx->res);
483 struct hesiod_p *ctx = context;
485 if (ctx->res && ctx->free_res) {
486 res_nclose(ctx->res);
487 (*ctx->free_res)(ctx->res);
490 ctx->res = res;
491 ctx->free_res = free_res;
495 init(struct hesiod_p *ctx) {
497 if (!ctx->res && !__hesiod_res_get(ctx))
500 if (((ctx->res->options & RES_INIT) == 0U) &&
501 (res_ninit(ctx->res) == -1))