Lines Matching refs:ctx

61 static int	parse_config_file(struct hesiod_p *ctx, const char *filename);
62 static char ** get_txt_records(struct hesiod_p *ctx, int class,
64 static int init(struct hesiod_p *ctx);
73 struct hesiod_p *ctx; in hesiod_init() local
76 ctx = malloc(sizeof(struct hesiod_p)); in hesiod_init()
77 if (ctx == 0) { in hesiod_init()
82 memset(ctx, 0, sizeof (*ctx)); in hesiod_init()
84 if (parse_config_file(ctx, _PATH_HESIOD_CONF) < 0) { in hesiod_init()
89 ctx->LHS = malloc(strlen(DEF_LHS) + 1); in hesiod_init()
90 ctx->RHS = malloc(strlen(DEF_RHS) + 1); in hesiod_init()
91 if (ctx->LHS == NULL || ctx->RHS == NULL) { in hesiod_init()
95 strcpy(ctx->LHS, DEF_LHS); /* (checked) */ in hesiod_init()
96 strcpy(ctx->RHS, DEF_RHS); /* (checked) */ in hesiod_init()
107 if (ctx->RHS) in hesiod_init()
108 free(ctx->RHS); in hesiod_init()
109 ctx->RHS = malloc(RHSlen); in hesiod_init()
110 if (!ctx->RHS) { in hesiod_init()
115 strcpy(ctx->RHS, cp); /* (checked) */ in hesiod_init()
117 strcpy(ctx->RHS, "."); /* (checked) */ in hesiod_init()
118 strcat(ctx->RHS, cp); /* (checked) */ in hesiod_init()
126 if (!ctx->RHS) { in hesiod_init()
132 if (res_ninit(ctx->res) < 0) in hesiod_init()
136 *context = ctx; in hesiod_init()
140 hesiod_end(ctx); in hesiod_init()
149 struct hesiod_p *ctx = (struct hesiod_p *) context; in hesiod_end() local
152 if (ctx->res) in hesiod_end()
153 res_nclose(ctx->res); in hesiod_end()
154 if (ctx->RHS) in hesiod_end()
155 free(ctx->RHS); in hesiod_end()
156 if (ctx->LHS) in hesiod_end()
157 free(ctx->LHS); in hesiod_end()
158 if (ctx->res && ctx->free_res) in hesiod_end()
159 (*ctx->free_res)(ctx->res); in hesiod_end()
160 free(ctx); in hesiod_end()
170 struct hesiod_p *ctx = (struct hesiod_p *) context; in hesiod_to_bind() local
187 RHS = ctx->RHS; in hesiod_to_bind()
196 (ctx->LHS ? strlen(ctx->LHS) : 0) + 4)) == NULL) { in hesiod_to_bind()
208 if (ctx->LHS) { in hesiod_to_bind()
209 if (ctx->LHS[0] != '.') in hesiod_to_bind()
211 strcat(bindname, ctx->LHS); in hesiod_to_bind()
229 struct hesiod_p *ctx = (struct hesiod_p *) context; in hesiod_resolve() local
235 if (init(ctx) == -1) { in hesiod_resolve()
240 if ((retvec = get_txt_records(ctx, C_IN, bindname))) { in hesiod_resolve()
248 retvec = get_txt_records(ctx, C_HS, bindname); in hesiod_resolve()
268 parse_config_file(struct hesiod_p *ctx, const char *filename) { in parse_config_file() argument
277 if (ctx->RHS) in parse_config_file()
278 free(ctx->RHS); in parse_config_file()
279 if (ctx->LHS) in parse_config_file()
280 free(ctx->LHS); in parse_config_file()
281 ctx->RHS = ctx->LHS = 0; in parse_config_file()
308 cpp = &ctx->LHS; in parse_config_file()
310 cpp = &ctx->RHS; in parse_config_file()
326 if (ctx->RHS) in parse_config_file()
327 free(ctx->RHS); in parse_config_file()
328 if (ctx->LHS) in parse_config_file()
329 free(ctx->LHS); in parse_config_file()
330 ctx->RHS = ctx->LHS = 0; in parse_config_file()
339 get_txt_records(struct hesiod_p *ctx, int class, const char *name) { in get_txt_records() argument
356 n = res_nmkquery(ctx->res, QUERY, name, class, T_TXT, NULL, 0, in get_txt_records()
362 n = res_nsend(ctx->res, qbuf, n, abuf, MAX_HESRESP); in get_txt_records()
460 struct hesiod_p *ctx = context; in __hesiod_res_get() local
462 if (!ctx->res) { in __hesiod_res_get()
470 __hesiod_res_set(ctx, res, free); in __hesiod_res_get()
473 return (ctx->res); in __hesiod_res_get()
479 struct hesiod_p *ctx = context; in __hesiod_res_set() local
481 if (ctx->res && ctx->free_res) { in __hesiod_res_set()
482 res_nclose(ctx->res); in __hesiod_res_set()
483 (*ctx->free_res)(ctx->res); in __hesiod_res_set()
486 ctx->res = res; in __hesiod_res_set()
487 ctx->free_res = free_res; in __hesiod_res_set()
491 init(struct hesiod_p *ctx) { in init() argument
493 if (!ctx->res && !__hesiod_res_get(ctx)) in init()
496 if (((ctx->res->options & RES_INIT) == 0U) && in init()
497 (res_ninit(ctx->res) == -1)) in init()