OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / ucd-snmp / original / man3 / default_store.3
1 .TH SNMP_AGENT_API 3 "27 Oct 1999"
2 .UC 5
3 .SH NAME
4 default_store \- generic storage of global data.
5 .SH SYNOPSIS
6 .nf
7 #include <ucd-snmp/ucd-snmp-config.h>
8 #include <ucd-snmp/ucd-snmp-includes.h>
9
10 int ds_set_boolean(int storeid, int which, int value);
11 int ds_get_boolean(int storeid, int which);
12 int ds_set_int(int storeid, int which, int value);
13 int ds_get_int(int storeid, int which);
14 int ds_set_string(int storeid, int which, const char *value);
15 char *ds_get_string(int storeid, int which);
16 int ds_register_config(u_char type, const char *ftype, const char *token,
17                        int storeid, int which);
18 int ds_register_premib(u_char type, const char *ftype, const char *token,
19                        int storeid, int which);
20 void ds_shutdown(void);
21 .fi
22 .SH DESCRIPTION
23 The purpose of the default storage is three-fold:
24 .IP 1)
25 To create a global storage space without creating a whole bunch of
26 globally accessible variables or a whole bunch of access functions to
27 work with more privately restricted variables.
28 .IP 2)
29 To provide a single location where the thread locking needs to be
30 implemented. At the time of this writing, however, thread locking is not
31 yet in place.
32 .IP 3)
33 To reduce the number of cross dependencies between code pieces that
34 may or may not be linked together in the long run. This provides for a
35 single location in which configuration data, for example, can be
36 stored for a separate section of code that may not be linked in to
37 the application in question.
38 .PP
39 The functions defined here implement these goals.
40 .PP
41 Currently, three data types are supported: boolean's, integers, and
42 strings. Each of based trade data types have separate storage
43 spaces. In addition, the storage space for each data type is divided
44 further by the application level.   Currently, there are two storage
45 spaces. The first is reserved for the SNMP library itself. The second 
46 is intended for use in applications and is not modified or checked by
47 the library, and, therefore, this is the space usable by you.
48 .PP
49 You can think of these storage spaces as being 3 arrays, something
50 like bool_storage[storeid][which], int_storage[storeid][which], and
51 string_storage[storeid][which].  The data is then accessed through the 
52 functions defined below.  For data you wish to store, you should use a 
53 storeid of DS_APPLICATION_ID.
54 .PP
55 The storage space used by the library is defined in the
56 default_store.h file, which currently contains the following defines:
57 .PP
58 .nf
59 /* These definitions correspond with the "storid" argument to the API */
60 #define DS_LIBRARY_ID     0
61 #define DS_APPLICATION_ID 1
62 #define DS_TOKEN_ID       2
63
64 /* These definitions correspond with the "which" argument to the API,
65    when the storeid argument is DS_LIBRARY_ID */
66 /* library booleans */
67 #define DS_LIB_MIB_ERRORS          0
68 #define DS_LIB_SAVE_MIB_DESCRS     1
69 #define DS_LIB_MIB_COMMENT_TERM    2
70 #define DS_LIB_MIB_PARSE_LABEL     3
71 #define DS_LIB_DUMP_PACKET         4
72 #define DS_LIB_LOG_TIMESTAMP       5
73 #define DS_LIB_DONT_READ_CONFIGS   6
74 #define DS_LIB_MIB_REPLACE         7  /* replace objects from latest module */
75 #define DS_LIB_PRINT_NUMERIC_ENUM  8  /* print only numeric enum values */
76 #define DS_LIB_PRINT_NUMERIC_OIDS  9  /* print only numeric enum values */
77 #define DS_LIB_DONT_BREAKDOWN_OIDS 10 /* dont print oid indexes specially */
78 #define DS_LIB_ALARM_DONT_USE_SIG  11 /* don't use the alarm() signal */
79 #define DS_LIB_PRINT_FULL_OID      12 /* print fully qualified oids */
80 #define DS_LIB_QUICK_PRINT         13 /* print very brief output for parsing */
81 #define DS_LIB_RANDOM_ACCESS       14 /* random access to oid labels */
82 #define DS_LIB_REGEX_ACCESS        15 /* regex matching to oid labels */
83 #define DS_LIB_DONT_CHECK_RANGE    16 /* don't check values for ranges on send*/
84 #define DS_LIB_NO_TOKEN_WARNINGS   17 /* no warn about unknown config tokens */
85 #define DS_LIB_NUMERIC_TIMETICKS   18 /* print timeticks as a number */
86 #define DS_LIB_ESCAPE_QUOTES       19 /* shell escape quote marks in oids */
87 #define DS_LIB_REVERSE_ENCODE      20 /* encode packets from back to front */
88 #define DS_LIB_PRINT_BARE_VALUE    21 /* just print value (not OID = value) */
89 #define DS_LIB_EXTENDED_INDEX      22 /* print extended index format [x1][x2] */
90 #define DS_LIB_PRINT_HEX_TEXT      23 /* print ASCII text along with hex strings */
91
92 /* library integers */
93 #define DS_LIB_MIB_WARNINGS  0
94 #define DS_LIB_SECLEVEL      1
95 #define DS_LIB_SNMPVERSION   2
96 #define DS_LIB_DEFAULT_PORT  3
97 #define DS_LIB_PRINT_SUFFIX_ONLY 4 /* print out only a single oid node  == 1.
98                                       like #1 but supply mib module too == 2. */
99
100 /* library strings */
101 #define DS_LIB_SECNAME           0
102 #define DS_LIB_CONTEXT           1
103 #define DS_LIB_PASSPHRASE        2
104 #define DS_LIB_AUTHPASSPHRASE    3
105 #define DS_LIB_PRIVPASSPHRASE    4
106 #define DS_LIB_OPTIONALCONFIG    5
107 #define DS_LIB_APPTYPE           6
108 #define DS_LIB_COMMUNITY         7
109 #define DS_LIB_PERSISTENT_DIR    8
110 #define DS_LIB_CONFIGURATION_DIR 9
111
112 .fi
113 .SH FUNCTIONS
114 .IP "ds_set_boolean(int storeid, int which, int value)"
115 Stores
116 .I true
117 if 
118 .I value
119 != 0 or else false into the bool_storage[storeid][which] slot.
120 .IP "int ds_get_boolean(int storeid, int which)"
121 Returns 1 if storage[storeid][which] is true, or 0 if false.
122 .IP "int ds_set_string(int storeid, int which, const char *value)"
123 Stores
124 .I value
125 into the string_storage[storeid][which] slot.
126 .IP "char *ds_get_string(int storeid, int which)"
127 Returns the string which has been stored in the
128 string_storage[storeid][which] slot.
129 .IP "ds_set_int(int storeid, int which, int value)"
130 Stores
131 .I value
132 into the int_storage[storeid][which] slot.
133 .IP "int ds_get_int(int storeid, int which)"
134 Returns the integer which has been stored in the
135 int_storage[storeid][which] slot.
136 .IP "void ds_shutdown(void)"
137 Reclaims memory used to hold information gathered by
138 ds_register_config and ds_register_premib.
139 .IP "ds_register_config(u_char type, const char *ftype, const char *token, int storeid, int which)"
140 This token registers a configuration file directive and attaches it to 
141 a default storage type and slot.  Specifically,
142 .I storeid
143 and
144 .I which
145 indicate the storage slot in the data type indicated by
146 .I type,
147 where
148 .I type
149 is either one of the following constants: ASN_BOOLEAN, ASN_INTEGER, or
150 ASN_OCTET_STR.  The
151 .I ftype
152 variable indicates the file name base string searched for the
153 .I token
154 keyword.  For example, the following call:
155 .RS
156 .IP
157 ds_register_config(ASN_INTEGER, "snmp", "testtoken", DS_APPLICATION_ID, 5)
158 .RE
159 .IP
160 would indicate that when the snmp.conf file(s) were found and parsed,
161 that any line beginning with the word "testtoken" should be read and
162 the value after "testtoken" should be stored into the
163 int_storage[DS_APPLICATION_ID][5] slot.  For example the following
164 line in the configuration file:
165 .RS
166 .IP
167 testtoken 42
168 .RE
169 .IP
170 would set int_storage[DS_APPLICATION_ID][5] = 42.
171 .SH "SEE ALSO"
172 snmp_config(5), read_config(3)
173