Lines Matching refs:source

195 	inputsource *source;
198 source = isc_mem_get(lex->mctx, sizeof(*source));
199 if (source == NULL)
201 source->result = ISC_R_SUCCESS;
202 source->is_file = is_file;
203 source->need_close = need_close;
204 source->at_eof = ISC_FALSE;
205 source->input = input;
206 source->name = isc_mem_strdup(lex->mctx, name);
207 if (source->name == NULL) {
208 isc_mem_put(lex->mctx, source, sizeof(*source));
211 source->pushback = NULL;
212 result = isc_buffer_allocate(lex->mctx, &source->pushback,
215 isc_mem_free(lex->mctx, source->name);
216 isc_mem_put(lex->mctx, source, sizeof(*source));
219 source->ignored = 0;
220 source->line = 1;
221 ISC_LIST_INITANDPREPEND(lex->sources, source, link);
232 * Open 'filename' and make it the current input source for 'lex'.
252 * Make 'stream' the current input source for 'lex'.
267 * Make 'buffer' the current input source for 'lex'.
279 inputsource *source;
287 source = HEAD(lex->sources);
288 if (source == NULL)
291 ISC_LIST_UNLINK(lex->sources, source, link);
292 if (source->is_file) {
293 if (source->need_close)
294 (void)fclose((FILE *)(source->input));
296 isc_mem_free(lex->mctx, source->name);
297 isc_buffer_free(&source->pushback);
298 isc_mem_put(lex->mctx, source, sizeof(*source));
318 pushback(inputsource *source, int c) {
319 REQUIRE(source->pushback->current > 0);
321 source->at_eof = ISC_FALSE;
324 source->pushback->current--;
326 source->line--;
330 pushandgrow(isc_lex_t *lex, inputsource *source, int c) {
331 if (isc_buffer_availablelength(source->pushback) == 0) {
337 oldlen = isc_buffer_length(source->pushback);
341 isc_buffer_usedregion(source->pushback, &used);
344 tbuf->current = source->pushback->current;
345 isc_buffer_free(&source->pushback);
346 source->pushback = tbuf;
348 isc_buffer_putuint8(source->pushback, (isc_uint8_t)c);
354 inputsource *source;
374 source = HEAD(lex->sources);
377 if (source == NULL) {
385 if (source->result != ISC_R_SUCCESS)
386 return (source->result);
389 source->saved_line = source->line;
391 if (isc_buffer_remaininglength(source->pushback) == 0 &&
392 source->at_eof)
406 isc_buffer_compact(source->pushback);
419 if (source->is_file)
420 flockfile(source->input);
424 if (isc_buffer_remaininglength(source->pushback) == 0) {
425 if (source->is_file) {
426 stream = source->input;
435 source->result = ISC_R_IOERROR;
436 result = source->result;
439 source->at_eof = ISC_TRUE;
442 buffer = source->input;
446 source->at_eof = ISC_TRUE;
454 source->result = pushandgrow(lex, source, c);
455 if (source->result != ISC_R_SUCCESS) {
456 result = source->result;
462 if (!source->at_eof) {
465 source->ignored =
466 isc_buffer_consumedlength(source->pushback);
467 c = isc_buffer_getuint8(source->pushback);
473 source->line++;
582 pushback(source, c);
599 pushback(source, c);
654 pushback(source, c);
655 if (source->result != ISC_R_SUCCESS) {
656 result = source->result;
690 pushback(source, c);
754 pushback(source, c);
789 if (source->is_file)
790 funlockfile(source->input);
860 inputsource *source;
866 source = HEAD(lex->sources);
867 REQUIRE(source != NULL);
869 REQUIRE(isc_buffer_consumedlength(source->pushback) != 0 ||
874 isc_buffer_first(source->pushback);
876 source->line = source->saved_line;
877 source->at_eof = ISC_FALSE;
883 inputsource *source;
886 source = HEAD(lex->sources);
887 REQUIRE(source != NULL);
889 REQUIRE(isc_buffer_consumedlength(source->pushback) != 0 ||
894 INSIST(source->ignored <= isc_buffer_consumedlength(source->pushback));
895 r->base = (unsigned char *)isc_buffer_base(source->pushback) +
896 source->ignored;
897 r->length = isc_buffer_consumedlength(source->pushback) -
898 source->ignored;
904 inputsource *source;
907 source = HEAD(lex->sources);
909 if (source == NULL)
912 return (source->name);
917 inputsource *source;
920 source = HEAD(lex->sources);
922 if (source == NULL)
925 return (source->line);
931 inputsource *source;
935 source = HEAD(lex->sources);
937 if (source == NULL)
942 isc_mem_free(lex->mctx, source->name);
943 source->name = newname;
949 inputsource *source;
953 source = HEAD(lex->sources);
955 if (source == NULL)
958 return (source->is_file);