lex_test.c revision f73e404eb9e1d314f85128cae48cdee036b405ec
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * Copyright (C) 1998, 1999, 2000 Internet Software Consortium.
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * Permission to use, copy, modify, and distribute this software for any
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * purpose with or without fee is hereby granted, provided that the above
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * copyright notice and this permission notice appear in all copies.
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrewsprint_token(isc_token_t *tokenp, FILE *stream) {
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews fprintf(stream, "NUMBER %lu", tokenp->value.as_ulong);
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews fprintf(stream, "SPECIAL %c", tokenp->value.as_char);
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews FATAL_ERROR(__FILE__, __LINE__, "Unexpected type %d",
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews unsigned int options = 0;
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews while ((c = isc_commandline_parse(argc, argv, "qmcs")) != -1) {
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews switch (c) {
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews /* Set up to lex DNS master file. */
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews options = ISC_LEXOPT_DNSMULTILINE | ISC_LEXOPT_ESCAPE |
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews isc_lex_setcomments(lex, ISC_LEXCOMMENT_DNSMASTERFILE);
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews /* Set up to lex DNS config file. */
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews RUNTIME_CHECK(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS);
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews while ((result = isc_lex_gettoken(lex, options, &token)) ==
901b5fb3b3fa409a42ac7e93b7643f373997305bMark Andrews printf("Result: %s\n", isc_result_totext(result));