Changeset 5a9b91bc0a14543e0995eba973fbeacc05aaee8b
- Timestamp:
- 07/09/08 16:47:24
(5 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1215622044 +0000
- git-parent:
[4f6de158923dd98b2ae05e8152eb38ec6e6b9d1d]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1215622044 +0000
- Message:
svn merge -r 327:330 https://labs.omniti.com/reconnoiter/branches/dev/udns .
closes #38
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rdeeaea6 |
r5a9b91b |
|
| 250 | 250 | |
|---|
| 251 | 251 | AC_FUNC_STRFTIME |
|---|
| 252 | | AC_CHECK_FUNCS(ssetugid strlcpy strnstrn openpty) |
|---|
| | 252 | AC_CHECK_FUNCS(ssetugid strlcpy strnstrn openpty inet_pton inet_ntop getopt \ |
|---|
| | 253 | poll) |
|---|
| 253 | 254 | |
|---|
| 254 | 255 | # Checks for header files. |
|---|
| … | … | |
| 505 | 506 | src/jlog/Makefile |
|---|
| 506 | 507 | src/jlog/perl/Makefile.PL |
|---|
| | 508 | src/udns/Makefile |
|---|
| 507 | 509 | src/modules/Makefile |
|---|
| 508 | 510 | src/utils/Makefile |
|---|
| r3277121 |
r5a9b91b |
|
| 28 | 28 | NOWHOLE_ARCHIVE=@NOWHOLE_ARCHIVE@ |
|---|
| 29 | 29 | |
|---|
| 30 | | SUBS=lua utils eventer modules noitedit |
|---|
| | 30 | SUBS=lua utils eventer udns modules noitedit |
|---|
| 31 | 31 | |
|---|
| 32 | 32 | NOIT_OBJS=noitd.o noit_listener.o \ |
|---|
| … | … | |
| 64 | 64 | noitd: make-subdirs $(NOIT_OBJS) |
|---|
| 65 | 65 | @$(CC) -o $@ $(NOIT_OBJS) \ |
|---|
| | 66 | udns/libudns.o \ |
|---|
| 66 | 67 | $(LDFLAGS) \ |
|---|
| 67 | 68 | $(WHOLE_ARCHIVE) \ |
|---|
| … | … | |
| 76 | 77 | stratcond: make-subdirs $(STRATCON_OBJS) |
|---|
| 77 | 78 | @$(CC) -o $@ $(STRATCON_OBJS) \ |
|---|
| | 79 | udns/libudns.o \ |
|---|
| 78 | 80 | $(LDFLAGS) \ |
|---|
| 79 | 81 | $(WHOLE_ARCHIVE) \ |
|---|
| rc4546c7 |
r5a9b91b |
|
| 19 | 19 | |
|---|
| 20 | 20 | MODULES=ping_icmp.@MODULEEXT@ http.@MODULEEXT@ postgres.@MODULEEXT@ \ |
|---|
| 21 | | lua.@MODULEEXT@ \ |
|---|
| | 21 | lua.@MODULEEXT@ dns.@MODULEEXT@ \ |
|---|
| 22 | 22 | @BUILD_MODULES@ |
|---|
| 23 | 23 | |
|---|
| … | … | |
| 42 | 42 | postgres.lo: postgres.c |
|---|
| 43 | 43 | @$(CC) $(CPPFLAGS) $(SHCFLAGS) $(PGCFLAGS) -c $< -o $@ |
|---|
| | 44 | @echo "- compiling $<" |
|---|
| | 45 | |
|---|
| | 46 | dns.@MODULEEXT@: dns.lo |
|---|
| | 47 | @$(MODULELD) $(LDFLAGS) -o $@ dns.lo |
|---|
| | 48 | @echo "- linking $@" |
|---|
| | 49 | |
|---|
| | 50 | dns.lo: dns.c |
|---|
| | 51 | @$(CC) $(CPPFLAGS) $(SHCFLAGS) -c $< -o $@ |
|---|
| 44 | 52 | @echo "- compiling $<" |
|---|
| 45 | 53 | |
|---|
| rd993405 |
r5a9b91b |
|
| 6 | 6 | #include "noit_defines.h" |
|---|
| 7 | 7 | #include "noit_check_tools.h" |
|---|
| | 8 | #include "utils/noit_str.h" |
|---|
| 8 | 9 | |
|---|
| 9 | 10 | #include <assert.h> |
|---|
| … | … | |
| 15 | 16 | } recur_closure_t; |
|---|
| 16 | 17 | |
|---|
| 17 | | int |
|---|
| | 18 | static noit_hash_table interpolation_operators = NOIT_HASH_EMPTY; |
|---|
| | 19 | |
|---|
| | 20 | static int |
|---|
| | 21 | interpolate_oper_copy(char *buff, int len, const char *replacement) { |
|---|
| | 22 | strlcpy(buff, replacement, len); |
|---|
| | 23 | return strlen(buff); |
|---|
| | 24 | } |
|---|
| | 25 | |
|---|
| | 26 | API_EXPORT(int) |
|---|
| | 27 | noit_check_interpolate_register_oper_fn(const char *name, |
|---|
| | 28 | intperpolate_oper_fn f) { |
|---|
| | 29 | noit_hash_replace(&interpolation_operators, |
|---|
| | 30 | strdup(name), strlen(name), |
|---|
| | 31 | f, |
|---|
| | 32 | free, NULL); |
|---|
| | 33 | return 0; |
|---|
| | 34 | } |
|---|
| | 35 | |
|---|
| | 36 | API_EXPORT(int) |
|---|
| 18 | 37 | noit_check_interpolate(char *buff, int len, const char *fmt, |
|---|
| 19 | 38 | noit_hash_table *attrs, |
|---|
| … | … | |
| 39 | 58 | if(*fmte == closer) { |
|---|
| 40 | 59 | /* We have a full key here */ |
|---|
| 41 | | const char *replacement; |
|---|
| | 60 | const char *replacement, *oper, *nkey; |
|---|
| | 61 | intperpolate_oper_fn oper_sprint; |
|---|
| | 62 | |
|---|
| | 63 | /* keys can be of the form: :operator:key */ |
|---|
| | 64 | oper = key; |
|---|
| | 65 | if(*oper == ':' && |
|---|
| | 66 | (nkey = strnstrn(":", 1, oper + 1, fmte - key - 1)) != NULL) { |
|---|
| | 67 | oper++; |
|---|
| | 68 | /* find oper, nkey-oper */ |
|---|
| | 69 | if(!noit_hash_retrieve(&interpolation_operators, |
|---|
| | 70 | oper, nkey - oper, |
|---|
| | 71 | (void **)&oper_sprint)) { |
|---|
| | 72 | /* else oper <- copy */ |
|---|
| | 73 | oper_sprint = interpolate_oper_copy; |
|---|
| | 74 | } |
|---|
| | 75 | nkey++; |
|---|
| | 76 | } |
|---|
| | 77 | else { |
|---|
| | 78 | oper_sprint = interpolate_oper_copy; |
|---|
| | 79 | nkey = key; |
|---|
| | 80 | } |
|---|
| 42 | 81 | if(!noit_hash_retrieve((closer == '}') ? config : attrs, |
|---|
| 43 | | key, fmte - key, (void **)&replacement)) |
|---|
| | 82 | nkey, fmte - nkey, (void **)&replacement)) |
|---|
| 44 | 83 | replacement = ""; |
|---|
| 45 | 84 | fmt = fmte + 1; /* Format points just after the end of the key */ |
|---|
| 46 | | strlcpy(cp, replacement, end-cp); |
|---|
| 47 | | cp += strlen(cp); |
|---|
| | 85 | cp += oper_sprint(cp, end-cp, replacement); |
|---|
| | 86 | *(end-1) = '\0'; /* In case the oper_sprint didn't teminate */ |
|---|
| 48 | 87 | replaced_something = 1; |
|---|
| 49 | 88 | break; |
|---|
| r4b96846 |
r5a9b91b |
|
| 14 | 14 | |
|---|
| 15 | 15 | typedef int (*dispatch_func_t)(noit_module_t *, noit_check_t *); |
|---|
| | 16 | |
|---|
| | 17 | typedef int (*intperpolate_oper_fn)(char *, int len, const char *replacement); |
|---|
| | 18 | |
|---|
| | 19 | API_EXPORT(int) |
|---|
| | 20 | noit_check_interpolate_register_oper_fn(const char *name, |
|---|
| | 21 | intperpolate_oper_fn f); |
|---|
| 16 | 22 | |
|---|
| 17 | 23 | API_EXPORT(int) |
|---|
| r5b8a066 |
r5a9b91b |
|
| 103 | 103 | #undef HAVE_STRNSTRN |
|---|
| 104 | 104 | #undef HAVE_OPENPTY |
|---|
| | 105 | #undef HAVE_INET_PTON |
|---|
| | 106 | #undef HAVE_INET_NTOP |
|---|
| | 107 | #undef HAVE_GETOPT |
|---|
| | 108 | #undef HAVE_POLL |
|---|
| 105 | 109 | |
|---|
| 106 | 110 | /* Kernel kqueue() support */ |
|---|
| rc4546c7 |
r5a9b91b |
|
| 65 | 65 | #endif |
|---|
| 66 | 66 | |
|---|
| | 67 | /* This is for udns */ |
|---|
| | 68 | #ifdef HAVE_INET_PTON |
|---|
| | 69 | #ifdef HAVE_INET_NTOP |
|---|
| | 70 | #define HAVE_INET_PTON_NTOP 1 |
|---|
| 67 | 71 | #endif |
|---|
| | 72 | #endif |
|---|
| | 73 | /* udns checks for IPv6, noit doesn't work without it */ |
|---|
| | 74 | #define HAVE_IPv6 |
|---|
| | 75 | |
|---|
| | 76 | #endif |
|---|