git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1839
c9e4aea6-c8fd-4c43-8297-
357d70d61c8c
+2007-10-29 Michael Poole <mdpoole@troilus.org>
+
+ * ircd/ircd_lexer.l (YY_INPUT): Redefine to use fbgets().
+ (init_lexer): Return a value to indicate failure. Use fbopen().
+ (deinit_lexer): New function.
+
+ * ircd/s_conf.c (read_configuration_file): Update extern
+ declarations. Bail if init_lexer() fails. Call deinit_lexer()
+ rather than directly munging yyin.
+
2007-10-29 Michael Poole <mdpoole@troilus.org>
* include/gline.h: Delete declaration of gline_propagate().
2007-10-29 Michael Poole <mdpoole@troilus.org>
* include/gline.h: Delete declaration of gline_propagate().
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "ircd.h"
#include "ircd_alloc.h"
#include "ircd_string.h"
#include "ircd.h"
#include "ircd_alloc.h"
#include "ircd_string.h"
return tok ? tok->value : 0;
}
return tok ? tok->value : 0;
}
+static FBFILE *lexer_input;
+
+#undef YY_INPUT
+#define YY_INPUT(buf, res, size) res = (fbgets(buf, size, lexer_input) ? strlen(buf) : 0)
+
+int
- yyin = fopen(configfile, "r");
- if (yyin == NULL)
+ lexer_input = fbopen(configfile, "r");
+ if (lexer_input == NULL)
{
#ifdef YY_FATAL_ERROR
YY_FATAL_ERROR("Could not open the configuration file.");
#else
fprintf(stderr, "Could not open the configuration file.");
#endif
{
#ifdef YY_FATAL_ERROR
YY_FATAL_ERROR("Could not open the configuration file.");
#else
fprintf(stderr, "Could not open the configuration file.");
#endif
}
#ifdef YY_NEW_FILE
YY_NEW_FILE;
#endif
lineno = 1;
}
#ifdef YY_NEW_FILE
YY_NEW_FILE;
#endif
lineno = 1;
+ return 1;
+}
+
+void deinit_lexer(void)
+{
+ if (lexer_input != NULL)
+ {
+ fbclose(lexer_input);
+ lexer_input = NULL;
+ }
static int conf_error;
/** When non-zero, indicates that the configuration file was loaded at least once. */
static int conf_already_read;
static int conf_error;
/** When non-zero, indicates that the configuration file was loaded at least once. */
static int conf_already_read;
extern void yyparse(void);
extern void yyparse(void);
-extern void init_lexer(void);
+extern int init_lexer(void);
+extern void deinit_lexer(void);
/** Read configuration file.
* @return Zero on failure, non-zero on success. */
/** Read configuration file.
* @return Zero on failure, non-zero on success. */
conf_error = 0;
feature_unmark(); /* unmark all features for resetting later */
clear_nameservers(); /* clear previous list of DNS servers */
conf_error = 0;
feature_unmark(); /* unmark all features for resetting later */
clear_nameservers(); /* clear previous list of DNS servers */
- /* Now just open an fd. The buffering isn't really needed... */
- init_lexer();
+ if (!init_lexer())
+ return 0;
- fclose(yyin);
- yyin = NULL;
feature_mark(); /* reset unmarked features */
conf_already_read = 1;
return 1;
feature_mark(); /* reset unmarked features */
conf_already_read = 1;
return 1;