~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to include/net-snmp/library/text_utils.h

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-05-10 22:20:23 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20070510222023-3fr07xb9i17xvq32
Tags: upstream-5.3.1
ImportĀ upstreamĀ versionĀ 5.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef NETSNMP_TEXT_UTILS_H
 
2
#define NETSNMP_TEXT_UTILS_H
 
3
 
 
4
#ifdef _cplusplus
 
5
extern "C" {
 
6
#endif
 
7
 
 
8
    
 
9
    /*------------------------------------------------------------------
 
10
     *
 
11
     * text file processing
 
12
     *
 
13
     */
 
14
    netsnmp_container *
 
15
    netsnmp_file_text_parse(netsnmp_file *f, netsnmp_container *cin,
 
16
                            int parse_mode, u_int flags, void *context);
 
17
 
 
18
#define PM_SAVE_EVERYTHING                                             1
 
19
#define PM_INDEX_STRING_STRING                                         2
 
20
#define PM_USER_FUNCTION                                               3
 
21
 
 
22
#define PM_FLAG_NO_CONTAINER                                  0x00000001
 
23
#define PM_FLAG_SKIP_WHITESPACE                               0x00000002
 
24
 
 
25
 
 
26
    /*
 
27
     * line processing user function
 
28
     */
 
29
    struct netsnmp_line_process_info_s; /* fwd decl */
 
30
 
 
31
    typedef struct netsnmp_line_info_s {
 
32
 
 
33
        size_t                     index;
 
34
 
 
35
        char                      *line;
 
36
        size_t                     line_len;
 
37
        size_t                     line_max;
 
38
 
 
39
        char                      *start;
 
40
        size_t                     start_len;
 
41
 
 
42
    } netsnmp_line_info;
 
43
 
 
44
    typedef int (Netsnmp_Process_Text_Line)
 
45
        (netsnmp_line_info *line_info, void *mem,
 
46
         struct netsnmp_line_process_info_s* lpi);
 
47
 
 
48
    typedef struct netsnmp_line_process_info_s {
 
49
 
 
50
        size_t                     line_max; /* defaults to STRINGMAX if 0 */
 
51
        size_t                     mem_size;
 
52
 
 
53
        u_int                      flags;
 
54
 
 
55
        Netsnmp_Process_Text_Line *process;
 
56
 
 
57
        void                      *user_context;
 
58
        
 
59
    } netsnmp_line_process_info;
 
60
    
 
61
/*
 
62
 * user function return codes
 
63
 */
 
64
#define PMLP_RC_STOP_PROCESSING                           -1
 
65
#define PMLP_RC_MEMORY_USED                                0
 
66
#define PMLP_RC_MEMORY_UNUSED                              1
 
67
 
 
68
    
 
69
/** ALLOC_LINE: wasteful, but fast */
 
70
#define PMLP_FLAG_ALLOC_LINE                               0x00000001
 
71
/** STRDUP_LINE: slower if you don't keep memory in most cases */
 
72
#define PMLP_FLAG_STRDUP_LINE                              0x00000002
 
73
/** don't strip trailing newlines */
 
74
#define PMLP_FLAG_LEAVE_NEWLINE                            0x00000004
 
75
/** don't skip blank or comment lines */
 
76
#define PMLP_FLAG_PROCESS_WHITESPACE                       0x00000008
 
77
/** just process line, don't save it */
 
78
#define PMLP_FLAG_NO_CONTAINER                             0x00000010
 
79
    
 
80
 
 
81
    /*
 
82
     * a few useful pre-defined helpers
 
83
     */
 
84
 
 
85
    typedef struct netsnmp_token_value_index_s {
 
86
 
 
87
        char               *token;
 
88
        netsnmp_cvalue      value;
 
89
        size_t              index;
 
90
 
 
91
    } netsnmp_token_value_index;
 
92
 
 
93
    netsnmp_container *netsnmp_text_token_container_from_file(const char *file,
 
94
                                                              u_int flags,
 
95
                                                              netsnmp_container *c,
 
96
                                                              void *context);
 
97
/*
 
98
 * flags
 
99
 */
 
100
#define NSTTC_FLAG_TYPE_CONTEXT_DIRECT                      0x00000001
 
101
 
 
102
 
 
103
#define PMLP_TYPE_UNSIGNED                                  1
 
104
#define PMLP_TYPE_INTEGER                                   2
 
105
#define PMLP_TYPE_STRING                                    3
 
106
#define PMLP_TYPE_BOOLEAN                                   4
 
107
 
 
108
        
 
109
#ifdef _cplusplus
 
110
}
 
111
#endif
 
112
 
 
113
#endif /* NETSNMP_TEXT_UTILS_H */