| 200 | #define FUNCTION_MAX_ARGS 16 |
| 201 | |
| 202 | static char *function_expand(const char *name, int argc, char *argv[]) |
| 203 | { |
| 204 | const struct function *f; |
| 205 | int i; |
| 206 | |
| 207 | for (i = 0; i < ARRAY_SIZE(function_table); i++) { |
| 208 | f = &function_table[i]; |
| 209 | if (strcmp(f->name, name)) |
| 210 | continue; |
| 211 | |
| 212 | if (argc < f->min_args) |
| 213 | pperror("too few function arguments passed to '%s'", |
| 214 | name); |
| 215 | |
| 216 | if (argc > f->max_args) |
| 217 | pperror("too many function arguments passed to '%s'", |
| 218 | name); |
| 219 | |
| 220 | return f->func(argc, argv); |
| 221 | } |
| 222 | |
| 223 | return NULL; |
| 224 | } |
| 225 | |
| 226 | /* |
| 227 | * Variables (and user-defined functions) |
no test coverage detected