Click
Loading...
Searching...
No Matches
confparse.hh
Go to the documentation of this file.
1// -*- c-basic-offset: 4; related-file-name: "../../lib/confparse.cc" -*-
2#ifndef CLICK_CONFPARSE_HH
3#define CLICK_CONFPARSE_HH
5#include <click/string.hh>
6#include <click/vector.hh>
7struct in_addr;
8#if HAVE_IP6
9struct in6_addr;
10#endif
11CLICK_DECLS
12class ErrorHandler;
13class StringAccum;
14class Timestamp;
15#ifndef CLICK_TOOL
16class Element;
17class Router;
18class Handler;
19class HandlerCall;
20# define CP_VA_PARSE_ARGS_REST const Element*, ErrorHandler*, ...
21# define CP_OPT_CONTEXT , const Element* context = 0
22# define CP_CONTEXT , const Element* context
23# define CP_PASS_CONTEXT , context
24#else
25# define CP_VA_PARSE_ARGS_REST ErrorHandler*, ...
26# define CP_OPT_CONTEXT
27# define CP_CONTEXT
28# define CP_PASS_CONTEXT
29#endif
30#ifndef CLICK_COMPILING_CONFPARSE_CC
31# define CLICK_CONFPARSE_DEPRECATED CLICK_DEPRECATED
32#else
33# define CLICK_CONFPARSE_DEPRECATED /* */
34#endif
35#if __GNUC__ <= 3
36# define CP_SENTINEL
37#else
38# define CP_SENTINEL __attribute__((sentinel))
39#endif
41
43
44const char* cp_skip_space(const char* begin, const char* end);
45const char* cp_skip_comment_space(const char* begin, const char* end);
46const char* cp_skip_double_quote(const char* begin, const char* end);
47bool cp_eat_space(String &str);
48inline bool cp_is_space(const String &str);
49bool cp_is_word(const String &str);
50bool cp_is_click_id(const String &str);
51
52String cp_uncomment(const String &str);
53String cp_unquote(const String &str);
54const char* cp_process_backslash(const char* begin, const char* end, StringAccum &sa);
55String cp_quote(const String &str, bool allow_newlines = false);
56
57void cp_argvec(const String& str, Vector<String>& conf);
59
60void cp_spacevec(const String& str, Vector<String>& conf);
61
71
72String cp_unspacevec(const String *begin, const String *end);
73inline String cp_unspacevec(const Vector<String> &conf);
74
82String cp_shift_delimiter(String &str, char delim);
83
85
87
88enum CpErrors {
89 CPE_OK = 0,
90 CPE_FORMAT,
91 CPE_NEGATIVE,
92 CPE_OVERFLOW,
93 CPE_INVALID,
94 CPE_MEMORY,
95 CPE_NOUNITS
96};
97extern int cp_errno;
98
99// strings and words
100bool cp_string(const String& str, String* result, String *rest = 0);
101bool cp_word(const String& str, String* result, String *rest = 0);
102bool cp_keyword(const String& str, String* result, String *rest = 0);
103
104bool cp_bool(const String& str, bool* result);
105
106// numbers
107enum { cp_basic_integer_whole = 64 };
108const char *cp_basic_integer(const char *begin, const char *end, int flags, int size, void *result);
109
110inline const char *cp_integer(const char *begin, const char *end, int base, int *result);
111inline const char *cp_integer(const char *begin, const char *end, int base, unsigned *result);
112inline const char *cp_integer(const char *begin, const char *end, int base, long *result);
113inline const char *cp_integer(const char *begin, const char *end, int base, unsigned long *result);
115inline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, unsigned *result);
116inline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, unsigned long *result);
118#if HAVE_LONG_LONG
119inline const char *cp_integer(const char *begin, const char *end, int base, long long *result);
120inline const char *cp_integer(const char *begin, const char *end, int base, unsigned long long *result);
122inline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, unsigned long long *result);
124#elif HAVE_INT64_TYPES && !HAVE_INT64_IS_LONG
125inline const char *cp_integer(const char *begin, const char *end, int base, int64_t *result);
126inline const char *cp_integer(const char *begin, const char *end, int base, uint64_t *result);
128inline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, uint64_t *result);
130#endif
131
132inline bool cp_integer(const String &str, int base, int *result);
133inline bool cp_integer(const String &str, int base, unsigned int *result);
134inline bool cp_integer(const String &str, int base, long *result);
135inline bool cp_integer(const String &str, int base, unsigned long *result);
136#if HAVE_LONG_LONG
137inline bool cp_integer(const String &str, int base, long long *result);
138inline bool cp_integer(const String &str, int base, unsigned long long *result);
139#elif HAVE_INT64_TYPES && !HAVE_INT64_IS_LONG
140inline bool cp_integer(const String &str, int base, int64_t *result);
141inline bool cp_integer(const String &str, int base, uint64_t *result);
142#endif
143
144inline bool cp_integer(const String &str, int *result);
145inline bool cp_integer(const String &str, unsigned int *result);
146inline bool cp_integer(const String &str, long *result);
147inline bool cp_integer(const String &str, unsigned long *result);
148#if HAVE_LONG_LONG
149inline bool cp_integer(const String &str, long long *result);
150inline bool cp_integer(const String &str, unsigned long long *result);
151#elif HAVE_INT64_TYPES && !HAVE_INT64_IS_LONG
152inline bool cp_integer(const String &str, int64_t *result);
153inline bool cp_integer(const String &str, uint64_t *result);
154#endif
155
156#define CP_REAL2_MAX_FRAC_BITS 28
157bool cp_real2(const String& str, int frac_bits, int32_t* result);
158bool cp_real2(const String& str, int frac_bits, uint32_t* result);
159bool cp_real10(const String& str, int frac_digits, int32_t* result);
160bool cp_real10(const String& str, int frac_digits, uint32_t* result);
161bool cp_real10(const String& str, int frac_digits, uint32_t* result_int, uint32_t* result_frac);
162#if HAVE_FLOAT_TYPES
163bool cp_double(const String& str, double* result);
164#endif
165
166bool cp_seconds_as(const String& str, int frac_digits, uint32_t* result);
167bool cp_seconds_as_milli(const String& str, uint32_t* result);
168bool cp_seconds_as_micro(const String& str, uint32_t* result);
169#if HAVE_FLOAT_TYPES
170bool cp_seconds(const String& str, double* result);
171#endif
172bool cp_time(const String &str, Timestamp *result, bool allow_negative = false);
173bool cp_time(const String& str, struct timeval* result);
174
175bool cp_bandwidth(const String& str, uint64_t* result);
176
177// network addresses
178class IPAddressList;
179bool cp_ip_address(const String& str, IPAddress* result CP_OPT_CONTEXT);
180inline bool cp_ip_address(const String& str, struct in_addr* result CP_OPT_CONTEXT);
181bool cp_ip_address(const String& str, unsigned char* result CP_OPT_CONTEXT);
182bool cp_ip_prefix(const String& str, IPAddress* result_addr, IPAddress* result_mask, bool allow_bare_address CP_OPT_CONTEXT);
183bool cp_ip_prefix(const String& str, unsigned char* result_addr, unsigned char* result_mask, bool allow_bare_address CP_OPT_CONTEXT);
184bool cp_ip_prefix(const String& str, IPAddress* result_addr, IPAddress* result_mask CP_OPT_CONTEXT);
185bool cp_ip_prefix(const String& str, unsigned char* result_addr, unsigned char* result_mask CP_OPT_CONTEXT);
186bool cp_ip_address_list(const String& str, Vector<IPAddress>* result CP_OPT_CONTEXT);
187
188#if HAVE_IP6
189class IP6Address;
190bool cp_ip6_address(const String& str, IP6Address* result CP_OPT_CONTEXT);
191inline bool cp_ip6_address(const String& str, struct in6_addr* result CP_OPT_CONTEXT);
192bool cp_ip6_address(const String& str, unsigned char* result CP_OPT_CONTEXT);
193bool cp_ip6_prefix(const String& str, IP6Address* result_addr, int* result_prefix, bool allow_bare_address CP_OPT_CONTEXT);
194bool cp_ip6_prefix(const String& str, unsigned char* result_addr, int* result_prefix, bool allow_bare_address CP_OPT_CONTEXT);
195bool cp_ip6_prefix(const String& str, unsigned char* result_addr, unsigned char* result_mask, bool allow_bare_address CP_OPT_CONTEXT);
196bool cp_ip6_prefix(const String& str, IP6Address* result_addr, IP6Address* result_mask, bool allow_bare_address CP_OPT_CONTEXT);
197#endif
198
199class EtherAddress;
200bool cp_ethernet_address(const String& str, EtherAddress* result CP_OPT_CONTEXT);
201bool cp_ethernet_address(const String& str, unsigned char* result CP_OPT_CONTEXT);
202
203bool cp_tcpudp_port(const String& str, int proto, uint16_t* result CP_OPT_CONTEXT);
204
205#if !CLICK_TOOL
206Element *cp_element(const String &str, const Element *context, ErrorHandler *errh = 0, const char *argname = 0);
207Element *cp_element(const String &str, Router *router, ErrorHandler *errh = 0, const char *argname = 0);
208bool cp_handler_name(const String& str, Element** result_element, String* result_hname, const Element* context, ErrorHandler* errh=0);
209bool cp_handler(const String& str, int flags, Element** result_element, const Handler** result_handler, const Element* context, ErrorHandler* errh=0);
210#endif
211
212#if CLICK_USERLEVEL || CLICK_TOOL
213bool cp_filename(const String& str, String* result);
214bool cp_file_offset(const String& str, off_t* result);
215#endif
216
217#if !CLICK_TOOL
218bool cp_anno(const String &str, int size, int *result CP_OPT_CONTEXT);
219#endif
221
223
224int cp_va_kparse(const Vector<String>& conf, CP_VA_PARSE_ARGS_REST) CP_SENTINEL;
225int cp_va_kparse(const String& str, CP_VA_PARSE_ARGS_REST) CP_SENTINEL;
226int cp_va_space_kparse(const String& str, CP_VA_PARSE_ARGS_REST) CP_SENTINEL;
227int cp_va_kparse_keyword(const String& str, CP_VA_PARSE_ARGS_REST) CP_SENTINEL;
228int cp_va_kparse_remove_keywords(Vector<String>& conf, CP_VA_PARSE_ARGS_REST) CP_SENTINEL;
229
230int cp_assign_arguments(const Vector<String> &argv, const String *param_begin, const String *param_end, Vector<String>* values = 0);
231
234
237 cpkN = 0,
238 cpkM = 1,
239 cpkP = 2,
240 cpkC = 4,
241 cpkD = 8,
242 cpkNormal = cpkN,
243 cpkMandatory = cpkM,
244 cpkPositional = cpkP,
245 cpkConfirm = cpkC,
246 cpkDeprecated = cpkD
247};
248
250typedef const char *CpVaParseCmd;
251
252extern const CpVaParseCmd
253 cpEnd,
269#if HAVE_INT64_TYPES
272#endif
276#if HAVE_FLOAT_TYPES
278#endif
305#if CLICK_USERLEVEL || CLICK_TOOL
308#endif
309#if !CLICK_TOOL
311#endif
316// old names, here for compatibility:
317extern const CpVaParseCmd
318 cpInterval CLICK_CONFPARSE_DEPRECATED, // struct timeval*
319 cpReadHandlerCall CLICK_CONFPARSE_DEPRECATED, // HandlerCall**
320 cpWriteHandlerCall CLICK_CONFPARSE_DEPRECATED; // HandlerCall**
322
324
325String cp_unparse_bool(bool value);
326String cp_unparse_real2(int32_t value, int frac_bits);
327String cp_unparse_real2(uint32_t value, int frac_bits);
328#if HAVE_INT64_TYPES
329String cp_unparse_real2(int64_t value, int frac_bits);
330String cp_unparse_real2(uint64_t value, int frac_bits);
331#endif
332String cp_unparse_real10(int32_t value, int frac_digits);
333String cp_unparse_real10(uint32_t value, int frac_digits);
334String cp_unparse_milliseconds(uint32_t value);
335String cp_unparse_microseconds(uint32_t value);
336String cp_unparse_interval(const Timestamp& value) CLICK_DEPRECATED;
337String cp_unparse_interval(const struct timeval& value) CLICK_DEPRECATED;
338String cp_unparse_bandwidth(uint32_t value);
340
342
343int cp_va_parse(const Vector<String>& conf, CP_VA_PARSE_ARGS_REST) CLICK_DEPRECATED;
344int cp_va_parse(const String& str, CP_VA_PARSE_ARGS_REST) CLICK_DEPRECATED;
345int cp_va_space_parse(const String& str, CP_VA_PARSE_ARGS_REST) CLICK_DEPRECATED;
346int cp_va_parse_keyword(const String& str, CP_VA_PARSE_ARGS_REST) CLICK_DEPRECATED;
347int cp_va_parse_remove_keywords(Vector<String>& conf, int first, CP_VA_PARSE_ARGS_REST) CLICK_DEPRECATED;
348// Argument syntax:
349// cp_va_arg ::= cpEnd // terminates argument list (not 0!)
350// | cpOptional | cpKeywords | cpIgnore... // manipulators
351// | CpVaParseCmd cmd, const char *description,
352// [Optional Helpers], Results
353// // Helpers and Results depend on 'cmd';
354// // see table above
355// | const char *keyword, CpVaParseCmd cmd, const char *description,
356// [Optional Helpers], Results
357// // keyword argument, within cpKeywords or
358// // cpMandatoryKeywords
359// | const char *keyword, CpVaParseCmd cmd, const char *description,
360// bool *keyword_given, [Optional Helpers], Results
361// // keyword argument, within cpConfirmKeywords
362// Returns the number of result arguments set, or negative on error.
363// Stores no values in the result arguments on error.
365
367
368struct cp_value;
369struct cp_argtype;
370
371typedef void (*cp_parsefunc)(cp_value* value, const String& arg,
372 ErrorHandler* errh, const char* argdesc CP_CONTEXT);
373typedef void (*cp_storefunc)(cp_value* value CP_CONTEXT);
374
375struct cp_argtype {
376 const char* name;
377 cp_argtype* next;
378 cp_parsefunc parse;
379 cp_storefunc store;
380 void* user_data;
381 int flags;
382 const char* description;
383 int internal;
384 int use_count;
385};
386
387struct cp_value {
388 // set by cp_va_parse:
389 const cp_argtype* argtype;
390 const char* keyword;
391 const char* description CLICK_CONFPARSE_DEPRECATED;
392 union {
393 int i;
394 const char *c_str;
395 void *p;
396 } extra;
397 void* store;
398 void* store2;
399 bool* store_confirm;
400 // set by parsefunc, used by storefunc:
401 union {
402 bool b;
403 int i;
404 unsigned u;
405 int16_t s16;
406 uint16_t u16;
407 int32_t s32;
408 uint32_t u32;
409#if HAVE_INT64_TYPES
410 int64_t s64;
411 int64_t i64 CLICK_DEPRECATED;
412 uint64_t u64;
413#endif
414 size_t size;
415#if HAVE_FLOAT_TYPES
416 double d;
417#endif
418 unsigned char address[16];
419 int is[4];
420#ifndef CLICK_TOOL
421 Element *element;
422#endif
423 void *p;
424 } v, v2;
425 String v_string;
426 String v2_string;
427};
428
429enum {
430 cpArgNormal = 0, cpArgStore2 = 1, cpArgExtraInt = 2,
431 cpArgExtraCStr = 4, cpArgAllowNumbers = 8
432};
433int cp_register_argtype(const char* name, const char* description, int flags,
434 cp_parsefunc parsefunc, cp_storefunc storefunc,
435 void* user_data = 0);
436void cp_unregister_argtype(const char* name);
437
438int cp_register_stringlist_argtype(const char* name, const char* description,
439 int flags);
440int cp_extend_stringlist_argtype(const char* name, ...);
441// Takes: const char* name, int value, ...., const char* ender = (const char*)0
443
445bool cp_seconds_as(int want_power, const String& str, uint32_t* result) CLICK_DEPRECATED;
446
447#define cp_integer64 cp_integer
448#define cp_unsigned64 cp_integer
449#define cp_unsigned cp_integer
450#define cp_unsigned_real10 cp_real10
451#define cp_unsigned_real2 cp_real2
453
460{
461 return cp_unspacevec(conf.begin(), conf.end());
462}
463
466inline bool cp_is_space(const String& str)
467{
468 return cp_skip_space(str.begin(), str.end()) == str.end();
469}
470
513inline const char *cp_integer(const char *begin, const char *end, int base, int *result)
514{
515 return cp_basic_integer(begin, end, base, -(int) sizeof(*result), result);
516}
517
536inline bool cp_integer(const String &str, int base, int *result)
537{
538 return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();
539}
540
541
542inline const char *cp_integer(const char *begin, const char *end, int base, unsigned *result)
543{
544 return cp_basic_integer(begin, end, base, (int) sizeof(*result), result);
545}
546
548inline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, unsigned *result)
549{
550 return reinterpret_cast<const unsigned char *>(cp_integer(reinterpret_cast<const char *>(begin), reinterpret_cast<const char *>(end), base, result));
551}
553
554
555inline const char *cp_integer(const char *begin, const char *end, int base, long *result)
556{
557 return cp_basic_integer(begin, end, base, -(int) sizeof(*result), result);
558}
559
560inline const char *cp_integer(const char *begin, const char *end, int base, unsigned long *result)
561{
562 return cp_basic_integer(begin, end, base, (int) sizeof(*result), result);
563}
564
566inline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, unsigned long *result)
567{
568 return reinterpret_cast<const unsigned char *>(cp_integer(reinterpret_cast<const char *>(begin), reinterpret_cast<const char *>(end), base, result));
569}
571
572
573#if HAVE_LONG_LONG
574
575inline const char *cp_integer(const char *begin, const char *end, int base, long long *result)
576{
577 return cp_basic_integer(begin, end, base, -(int) sizeof(*result), result);
578}
579
580inline const char *cp_integer(const char *begin, const char *end, int base, unsigned long long *result)
581{
582 return cp_basic_integer(begin, end, base, (int) sizeof(*result), result);
583}
584
586inline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, unsigned long long *result)
587{
588 return reinterpret_cast<const unsigned char *>(cp_integer(reinterpret_cast<const char *>(begin), reinterpret_cast<const char *>(end), base, result));
589}
591
592#elif HAVE_INT64_TYPES && !HAVE_INT64_IS_LONG
593
594inline const char *cp_integer(const char *begin, const char *end, int base, int64_t *result)
595{
596 return cp_basic_integer(begin, end, base, -(int) sizeof(*result), result);
597}
598
599inline const char *cp_integer(const char *begin, const char *end, int base, uint64_t *result)
600{
601 return cp_basic_integer(begin, end, base, (int) sizeof(*result), result);
602}
603
605inline const unsigned char *cp_integer(const unsigned char *begin, const unsigned char *end, int base, uint64_t *result)
606{
607 return reinterpret_cast<const unsigned char *>(cp_integer(reinterpret_cast<const char *>(begin), reinterpret_cast<const char *>(end), base, result));
608}
610
611#endif
612
613inline bool cp_integer(const String &str, int base, int *result);
614
615inline bool cp_integer(const String &str, int base, unsigned int *result)
616{
617 return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();
618}
619
620inline bool cp_integer(const String &str, int base, long *result)
621{
622 return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();
623}
624
625inline bool cp_integer(const String &str, int base, unsigned long *result)
626{
627 return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();
628}
629
630#if HAVE_LONG_LONG
631
632inline bool cp_integer(const String &str, int base, long long *result)
633{
634 return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();
635}
636
637inline bool cp_integer(const String &str, int base, unsigned long long *result)
638{
639 return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();
640}
641
642#elif HAVE_INT64_TYPES && !HAVE_INT64_IS_LONG
643
644inline bool cp_integer(const String &str, int base, int64_t *result)
645{
646 return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();
647}
648
649inline bool cp_integer(const String &str, int base, uint64_t *result)
650{
651 return cp_basic_integer(str.begin(), str.end(), base + cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();
652}
653
654#endif
655
659inline bool cp_integer(const String &str, int *result)
660{
661 return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();
662}
663
664inline bool cp_integer(const String &str, unsigned int *result)
665{
666 return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();
667}
668
669inline bool cp_integer(const String &str, long *result)
670{
671 return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();
672}
673
674inline bool cp_integer(const String &str, unsigned long *result)
675{
676 return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();
677}
678
679#if HAVE_LONG_LONG
680
681inline bool cp_integer(const String &str, long long *result)
682{
683 return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();
684}
685
686inline bool cp_integer(const String &str, unsigned long long *result)
687{
688 return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();
689}
690
691#elif HAVE_INT64_TYPES && !HAVE_INT64_IS_LONG
692
693inline bool cp_integer(const String &str, int64_t *result)
694{
695 return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, -(int) sizeof(*result), result) != str.begin();
696}
697
698inline bool cp_integer(const String &str, uint64_t *result)
699{
700 return cp_basic_integer(str.begin(), str.end(), cp_basic_integer_whole, (int) sizeof(*result), result) != str.begin();
701}
702
703#endif
704
705inline bool cp_ip_address(const String& str, struct in_addr *ina CP_CONTEXT)
706{
707 return cp_ip_address(str, reinterpret_cast<IPAddress *>(ina) CP_PASS_CONTEXT);
708}
709
710#if HAVE_IP6
711inline bool cp_ip6_address(const String& str, struct in6_addr *x CP_CONTEXT)
712{
713 return cp_ip6_address(str, reinterpret_cast<IP6Address *>(x) CP_PASS_CONTEXT);
714}
715#endif
716
718inline bool cp_seconds_as(int want_power, const String &str, uint32_t *result)
719{
720 return cp_seconds_as(str, want_power, result);
721}
722
723#if !CLICK_TOOL
724inline int cp_register_argtype(const char* name, const char* description, int flags,
725 void (*parsefunc)(cp_value *, const String &, ErrorHandler *, const char *, Element *),
726 void (*storefunc)(cp_value *, Element *),
727 void *user_data = 0) {
728 return cp_register_argtype(name, description, flags,
729 (cp_parsefunc) parsefunc,
730 (cp_storefunc) storefunc,
731 user_data);
732}
733#endif
734
735inline String cp_pop_spacevec(String &str) CLICK_DEPRECATED;
736
740inline String cp_pop_spacevec(String &str) {
741 return cp_shift_spacevec(str);
742}
743
744#undef CP_VA_ARGS_REST
745#undef CP_OPT_CONTEXT
746#undef CP_CONTEXT
747#undef CP_PASS_CONTEXT
748#undef CLICK_CONFPARSE_DEPRECATED
749#undef CP_SENTINEL
750#define cpEnd ((CpVaParseCmd) 0)
752CLICK_ENDDECLS
753#endif
Base class for Click elements.
Definition element.hh:42
Error reporting class.
Definition error.hh:90
An Ethernet address.
Definition etheraddress.hh:9
Convenience class for calling handlers.
Definition handlercall.hh:143
Represents a router's handlers.
Definition handler.hh:19
An IPv4 address.
Definition ipaddress.hh:16
A router configuration.
Definition router.hh:28
Efficiently build up Strings from pieces.
Definition straccum.hh:28
A string of characters.
Definition string.hh:22
const_iterator end() const
Return an iterator for the end of the string.
Definition string.hh:584
const_iterator begin() const
Return an iterator for the first character in the string.
Definition string.hh:576
Represents a moment or interval in time.
Definition timestamp.hh:125
Vector template.
Definition vector.hh:111
iterator end()
Return an iterator for the end of the vector.
Definition vector.hh:266
iterator begin()
Return an iterator for the first element in the vector.
Definition vector.hh:253
const CpVaParseCmd cpSecondsAsMilli
Result storage uint32_t*, parsed by cp_seconds_as_milli().
Definition confparse.hh:280
int cp_va_kparse_remove_keywords(Vector< String > &conf, const Element *context, ErrorHandler *errh,...) CP_SENTINEL
Parse and remove matching arguments from conf.
Definition confparse.cc:3913
const CpVaParseCmd cpReal10
Parse parameter int frac_digits, result storage int32_t*, parsed by cp_real10().
Definition confparse.hh:274
const CpVaParseCmd cpUnsigned
Result storage uint32_t*, parsed by cp_integer().
Definition confparse.hh:266
bool cp_double(const String &str, double *result)
Parse a real number from str.
Definition confparse.cc:1336
bool cp_time(const String &str, Timestamp *result, bool allow_negative=false)
Parse a timestamp from str.
Definition confparse.cc:1526
void cp_va_static_initialize()
Initialize the cp_va_kparse() implementation.
Definition confparse.cc:4189
void cp_spacevec(const String &str, Vector< String > &conf)
Separate a configuration string into arguments at unquoted spaces.
Definition confparse.cc:768
bool cp_tcpudp_port(const String &str, int proto, uint16_t *result, const Element *context=0)
Parse a TCP, UDP, etc. port number from str.
Definition confparse.cc:1939
String cp_unargvec(const Vector< String > &conf)
Join the strings of conf with commas and return the result.
Definition confparse.cc:815
bool cp_is_space(const String &str)
Test if str is all spaces.
Definition confparse.hh:466
bool cp_seconds_as_micro(const String &str, uint32_t *result)
Parse an amount of time in microseconds from str.
Definition confparse.cc:1480
const CpVaParseCmd cpUnsignedShort
Result storage unsigned short*, parsed by cp_integer().
Definition confparse.hh:264
const CpVaParseCmd cpIP6Prefix
Result storage IP6Address* addr and IP6Address* mask, parsed by cp_ip6_prefix().
Definition confparse.hh:302
bool cp_keyword(const String &str, String *result, String *rest=0)
Parse a keyword from str.
Definition confparse.cc:966
const CpVaParseCmd cpIPPrefix
Result storage IPAddress* addr and IPAddress *mask, parsed by cp_ip_prefix().
Definition confparse.hh:287
const CpVaParseCmd cpWord
Result storage String*, parsed by cp_word().
Definition confparse.hh:259
void cp_va_static_cleanup()
Clean up the cp_va_kparse() implementation.
Definition confparse.cc:4282
const CpVaParseCmd cpHandlerCallWrite
Result storage HandlerCall*, parsed by HandlerCall.
Definition confparse.hh:298
const CpVaParseCmd cpIP6Address
Result storage IP6Address* or equivalent, parsed by cp_ip6_address().
Definition confparse.hh:301
const CpVaParseCmd cpEnd
Use as argument name. Ends cp_va argument list.
Definition confparse.cc:2197
bool cp_handler(const String &str, int flags, Element **result_element, const Handler **result_handler, const Element *context, ErrorHandler *errh=0)
Parse a handler reference from str.
Definition confparse.cc:2108
bool cp_string(const String &str, String *result, String *rest=0)
Parse a string from str.
Definition confparse.cc:868
bool cp_real10(const String &str, int frac_digits, int32_t *result)
Parse a real number from str, representing the result as an integer with frac_digits decimal digits o...
Definition confparse.cc:1232
const CpVaParseCmd cpSize
Result storage size_t*, parsed by cp_integer().
Definition confparse.hh:267
const CpVaParseCmd cpConfirmKeywords
cp_va_parse only: Following arguments are confirmed keywords.
Definition confparse.hh:314
bool cp_seconds_as(const String &str, int frac_digits, uint32_t *result)
Parse an amount of time from str.
Definition confparse.cc:1447
bool cp_ip6_address(const String &str, IP6Address *result, const Element *context=0)
Parse an IPv6 address from str.
Definition confparse.cc:1803
const CpVaParseCmd cpNamedInteger
Parse parameter uint32_t nameinfo_type, result storage int32_t*, parsed by NameInfo::query_int.
Definition confparse.hh:268
const CpVaParseCmd cpIP6PrefixLen
Result storage IP6Address* addr and int* prefix_len, parsed by cp_ip6_prefix().
Definition confparse.hh:303
int cp_va_parse_remove_keywords(Vector< String > &conf, int first, const Element *context, ErrorHandler *errh,...)
Legacy function for parsing and removing matching arguments from conf.
Definition confparse.cc:3718
const CpVaParseCmd cpArgument
Result storage String*, accepts any argument.
Definition confparse.hh:256
const CpVaParseCmd cpTCPPort
Result storage uint16_t*, parsed by cp_tcpudp_port().
Definition confparse.hh:292
const CpVaParseCmd cpIgnoreRest
Use as argument name. No result storage; causes cp_va_kparse() to ignore unparsed arguments and any r...
Definition confparse.hh:254
int cp_va_space_parse(const String &str, const Element *context, ErrorHandler *errh,...)
Legacy function for parsing a space-separated argument string.
Definition confparse.cc:3657
const char * cp_skip_comment_space(const char *begin, const char *end)
Find the first nonspace, noncomment character in the string [begin, end).
Definition confparse.cc:361
const CpVaParseCmd cpFilename
Result storage String*, parsed by cp_filename().
Definition confparse.hh:306
bool cp_real2(const String &str, int frac_bits, int32_t *result)
Parse a fixed-point number from str.
Definition confparse.cc:1304
const CpVaParseCmd cpUnsignedReal2
Parse parameter int frac_bits, result storage uint32_t*, parsed by cp_real2().
Definition confparse.hh:273
CpKparseFlags
Type of flags for cp_va_kparse() items.
Definition confparse.hh:236
@ cpkP
Argument may be specified positionally.
Definition confparse.hh:239
@ cpkN
Default flags.
Definition confparse.hh:237
@ cpkD
Argument is deprecated.
Definition confparse.hh:241
@ cpkC
Argument presence should be confirmed.
Definition confparse.hh:240
@ cpkM
Argument is mandatory.
Definition confparse.hh:238
const CpVaParseCmd cpSecondsAsMicro
Result storage uint32_t*, parsed by cp_seconds_as_micro().
Definition confparse.hh:281
String cp_unquote(const String &str)
Remove one level of quoting from str, returning the result.
Definition confparse.cc:571
const CpVaParseCmd cpBool
Result storage bool*, parsed by cp_bool().
Definition confparse.hh:261
bool cp_ethernet_address(const String &str, EtherAddress *result, const Element *context=0)
Parse an Ethernet address from str.
Definition confparse.cc:1914
const char * cp_integer(const char *begin, const char *end, int base, int *result)
Parse an integer from [begin, end) in base base.
Definition confparse.hh:513
bool cp_anno(const String &str, int size, int *result, const Element *context=0)
Parse a packet annotation value from str.
Definition confparse.cc:2181
const CpVaParseCmd cpString
Result storage String*, parsed by cp_string().
Definition confparse.hh:258
const CpVaParseCmd cpKeyword
Result storage String*, parsed by cp_keyword().
Definition confparse.hh:260
bool cp_bool(const String &str, bool *result)
Parse a boolean from str.
Definition confparse.cc:1034
const CpVaParseCmd cpByte
Result storage unsigned char*, parsed by cp_integer().
Definition confparse.hh:262
int cp_va_space_kparse(const String &str, const Element *context, ErrorHandler *errh,...) CP_SENTINEL
Parse a space-separated argument string.
Definition confparse.cc:3841
bool cp_ip_address_list(const String &str, Vector< IPAddress > *result, const Element *context=0)
Parse a space-separated list of IP addresses from str.
Definition confparse.cc:1741
const CpVaParseCmd cpEthernetAddress
Result storage EtherAddress*, parsed by cp_ethernet_address(). Synonym for cpEtherAddress.
Definition confparse.hh:291
const CpVaParseCmd cpShort
Result storage short*, parsed by cp_integer().
Definition confparse.hh:263
bool cp_filename(const String &str, String *result)
Parse a filename string from str.
Definition confparse.cc:2145
int cp_va_kparse_keyword(const String &str, const Element *context, ErrorHandler *errh,...) CP_SENTINEL
Parse a single argument.
Definition confparse.cc:3873
const CpVaParseCmd cpUDPPort
Result storage uint16_t*, parsed by cp_tcpudp_port().
Definition confparse.hh:293
int cp_va_kparse(const Vector< String > &conf, const Element *context, ErrorHandler *errh,...) CP_SENTINEL
Parse a list of arguments.
Definition confparse.cc:3779
const CpVaParseCmd cpInteger64
Result storage int64_t*, parsed by cp_integer().
Definition confparse.hh:270
const CpVaParseCmd cpIgnore
No result storage, ignores this argument.
Definition confparse.hh:255
String cp_uncomment(const String &str)
Simplify str's whitespace and replace comments by spaces, returning the result.
Definition confparse.cc:442
bool cp_is_click_id(const String &str)
Test if str is a valid Click identifier.
Definition confparse.cc:257
String cp_unspacevec(const String *begin, const String *end)
Join the strings in [begin, end) with spaces and return the result.
Definition confparse.cc:838
bool cp_bandwidth(const String &str, uint64_t *result)
Parse a bandwidth value from str.
Definition confparse.cc:1592
const CpVaParseCmd cpUnsignedReal10
Parse parameter int frac_digits, result storage uint32_t*, parsed by cp_real10().
Definition confparse.hh:275
bool cp_ip_address(const String &str, IPAddress *result, const Element *context=0)
Parse an IP address from str.
Definition confparse.cc:1654
String cp_shift_spacevec(String &str)
Remove and return the first space-separated argument from str.
Definition confparse.cc:785
const CpVaParseCmd cpMandatoryKeywords
cp_va_parse only: Following arguments are mandatory keywords.
Definition confparse.hh:315
const char * CpVaParseCmd
Type of argument type names for cp_va_kparse() items.
Definition confparse.hh:250
const CpVaParseCmd cpBandwidth
Result storage uint32_t*, parsed by cp_bandwidth().
Definition confparse.hh:285
bool cp_word(const String &str, String *result, String *rest=0)
Parse a word from str.
Definition confparse.cc:935
const char * cp_process_backslash(const char *begin, const char *end, StringAccum &sa)
Process a backslash escape, appending results to sa.
Definition confparse.cc:477
const CpVaParseCmd cpHandlerName
Result storage Element** and String*, parsed by cp_handler_name().
Definition confparse.hh:296
bool cp_eat_space(String &str)
Remove spaces from the beginning of str.
Definition confparse.cc:227
const CpVaParseCmd cpIPAddressList
Result storage Vector<IPAddress>*, parsed by cp_ip_address_list().
Definition confparse.hh:289
const CpVaParseCmd cpOptional
cp_va_parse only: Following arguments are optional.
Definition confparse.hh:312
String cp_quote(const String &str, bool allow_newlines=false)
Return a quoted version of str.
Definition confparse.cc:629
const CpVaParseCmd cpAnno
Parse parameter int annotation_size, result storage int*, parsed by cp_anno().
Definition confparse.hh:310
const CpVaParseCmd cpTimeval
Result storage struct timeval*, parsed by cp_time().
Definition confparse.hh:284
bool cp_file_offset(const String &str, off_t *result)
Parse a file offset from str.
Definition confparse.cc:1101
bool cp_ip_prefix(const String &str, IPAddress *result_addr, IPAddress *result_mask, bool allow_bare_address, const Element *context=0)
Parse an IP address or prefix from str.
Definition confparse.cc:1703
const CpVaParseCmd cpEtherAddress
Result storage EtherAddress*, parsed by cp_ethernet_address().
Definition confparse.hh:290
bool cp_is_word(const String &str)
Test whether str is a valid "word".
Definition confparse.cc:241
const CpVaParseCmd cpKeywords
cp_va_parse only: Following arguments are keywords.
Definition confparse.hh:313
int cp_assign_arguments(const Vector< String > &argv, const String *param_begin, const String *param_end, Vector< String > *values=0)
Assign arguments from argv to values.
Definition confparse.cc:3973
bool cp_seconds(const String &str, double *result)
Parse an amount of time from str.
Definition confparse.cc:1499
const CpVaParseCmd cpHandlerCallPtrRead
Result storage HandlerCall**, parsed by HandlerCall::reset_read.
Definition confparse.hh:299
bool cp_handler_name(const String &str, Element **result_element, String *result_hname, const Element *context, ErrorHandler *errh=0)
Parse a handler name from str.
Definition confparse.cc:2044
const CpVaParseCmd cpSeconds
Result storage uint32_t*, parsed by cp_seconds_as() with frac_digits 0.
Definition confparse.hh:279
void cp_argvec(const String &str, Vector< String > &conf)
Separate a configuration string into arguments at commas.
Definition confparse.cc:697
const CpVaParseCmd cpIPAddress
Result storage IPAddress* or equivalent, parsed by cp_ip_address().
Definition confparse.hh:286
Element * cp_element(const String &str, const Element *context, ErrorHandler *errh=0, const char *argname=0)
Parse an element reference from str.
Definition confparse.cc:1972
const char * cp_skip_double_quote(const char *begin, const char *end)
Return the first character after a double-quoted string starting at begin.
Definition confparse.cc:320
const CpVaParseCmd cpFileOffset
Result storage off_t*, parsed by cp_integer().
Definition confparse.hh:307
String cp_shift_delimiter(String &str, char delim)
Remove and return the first delimiter-separated argument from str.
Definition confparse.cc:796
const char * cp_skip_space(const char *begin, const char *end)
Find the first nonspace character in the string [begin, end).
Definition confparse.cc:216
const CpVaParseCmd cpDouble
Result storage double*, parsed by cp_double().
Definition confparse.hh:277
const CpVaParseCmd cpArguments
Result storage Vector<String>*, accepts any number of arguments with the same keyword.
Definition confparse.hh:257
const CpVaParseCmd cpElementCast
Parse parameter const char*, result storage void**, parsed by cp_element() and Element::cast().
Definition confparse.hh:295
const CpVaParseCmd cpTimestamp
Result storage Timestamp*, parsed by cp_time().
Definition confparse.hh:282
int cp_va_parse(const Vector< String > &conf, const Element *context, ErrorHandler *errh,...)
Legacy function for parsing a list of arguments.
Definition confparse.cc:3601
int cp_va_parse_keyword(const String &str, const Element *context, ErrorHandler *errh,...)
Legacy function for parsing a single argument.
Definition confparse.cc:3686
const CpVaParseCmd cpHandlerCallPtrWrite
Result storage HandlerCall**, parsed by HandlerCall::reset_write.
Definition confparse.hh:300
const CpVaParseCmd cpElement
Result storage Element**, parsed by cp_element().
Definition confparse.hh:294
const CpVaParseCmd cpIP6AddressOrPrefix
Result storage IP6Address* addr and IP6Address* mask, parsed by cp_ip6_prefix().
Definition confparse.hh:304
const CpVaParseCmd cpHandlerCallRead
Result storage HandlerCall*, parsed by HandlerCall.
Definition confparse.hh:297
const CpVaParseCmd cpInteger
Result storage int32_t*, parsed by cp_integer().
Definition confparse.hh:265
bool cp_seconds_as_milli(const String &str, uint32_t *result)
Parse an amount of time in milliseconds from str.
Definition confparse.cc:1467
const CpVaParseCmd cpUnsigned64
Result storage uint64_t*, parsed by cp_integer().
Definition confparse.hh:271
bool cp_ip6_prefix(const String &str, IP6Address *result_addr, int *result_prefix, bool allow_bare_address, const Element *context=0)
Parse an IPv6 address or prefix from str.
Definition confparse.cc:1869
const CpVaParseCmd cpIPAddressOrPrefix
Result storage IPAddress* addr and IPAddress *mask, parsed by cp_ip_prefix().
Definition confparse.hh:288
const CpVaParseCmd cpTimestampSigned
Result storage Timestamp*, parsed by cp_time().
Definition confparse.hh:283
Click's String class.
Click's vector container template.