Deleted Added
sdiff udiff text old ( 266114 ) new ( 276605 )
full compact
1/*
2 * services/modstack.c - stack of modules
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 29 unchanged lines hidden (view full) ---

38 *
39 * This file contains functions to help maintain a stack of modules.
40 */
41#include "config.h"
42#include <ctype.h>
43#include "services/modstack.h"
44#include "util/module.h"
45#include "util/fptr_wlist.h"
46#include "dns64/dns64.h"
47#include "iterator/iterator.h"
48#include "validator/validator.h"
49
50#ifdef WITH_PYTHONMODULE
51#include "pythonmod/pythonmod.h"
52#endif
53
54/** count number of modules (words) in the string */
55static int
56count_modules(const char* s)
57{
58 int num = 0;
59 if(!s)
60 return 0;
61 while(*s) {
62 /* skip whitespace */
63 while(*s && isspace((unsigned char)*s))
64 s++;
65 if(*s && !isspace((unsigned char)*s)) {
66 /* skip identifier */
67 num++;
68 while(*s && !isspace((unsigned char)*s))
69 s++;
70 }
71 }
72 return num;
73}
74
75void
76modstack_init(struct module_stack* stack)

--- 35 unchanged lines hidden (view full) ---

112}
113
114/** The list of module names */
115const char**
116module_list_avail(void)
117{
118 /* these are the modules available */
119 static const char* names[] = {
120 "dns64",
121#ifdef WITH_PYTHONMODULE
122 "python",
123#endif
124 "validator",
125 "iterator",
126 NULL};
127 return names;
128}
129
130/** func block get function type */
131typedef struct module_func_block* (*fbgetfunctype)(void);
132
133/** The list of module func blocks */
134static fbgetfunctype*
135module_funcs_avail(void)
136{
137 static struct module_func_block* (*fb[])(void) = {
138 &dns64_get_funcblock,
139#ifdef WITH_PYTHONMODULE
140 &pythonmod_get_funcblock,
141#endif
142 &val_get_funcblock,
143 &iter_get_funcblock,
144 NULL};
145 return fb;
146}
147
148struct
149module_func_block* module_factory(const char** str)
150{
151 int i = 0;
152 const char* s = *str;
153 const char** names = module_list_avail();
154 fbgetfunctype* fb = module_funcs_avail();
155 while(*s && isspace((unsigned char)*s))
156 s++;
157 while(names[i]) {
158 if(strncmp(names[i], s, strlen(names[i])) == 0) {
159 s += strlen(names[i]);
160 *str = s;
161 return (*fb[i])();
162 }
163 i++;

--- 52 unchanged lines hidden ---