registry.h (4600B)
1 /* 2 * 3 * registry.h 4 * 5 * $Source: /Users/ekr/tmp/nrappkit-dump/nrappkit/src/registry/registry.h,v $ 6 * $Revision: 1.3 $ 7 * $Date: 2007/07/17 17:58:16 $ 8 * 9 * Datastore for tracking configuration and related info. 10 * 11 * 12 * Copyright (C) 2005, Network Resonance, Inc. 13 * Copyright (C) 2006, Network Resonance, Inc. 14 * All Rights Reserved 15 * 16 * Redistribution and use in source and binary forms, with or without 17 * modification, are permitted provided that the following conditions 18 * are met: 19 * 20 * 1. Redistributions of source code must retain the above copyright 21 * notice, this list of conditions and the following disclaimer. 22 * 2. Redistributions in binary form must reproduce the above copyright 23 * notice, this list of conditions and the following disclaimer in the 24 * documentation and/or other materials provided with the distribution. 25 * 3. Neither the name of Network Resonance, Inc. nor the name of any 26 * contributors to this software may be used to endorse or promote 27 * products derived from this software without specific prior written 28 * permission. 29 * 30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' 31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 34 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 40 * POSSIBILITY OF SUCH DAMAGE. 41 * 42 * 43 */ 44 45 #ifndef __REGISTRY_H__ 46 #define __REGISTRY_H__ 47 48 #include <stdio.h> 49 #include <sys/types.h> 50 #include <r_types.h> 51 #include <r_data.h> 52 53 #define NR_REG_MAX_NR_REGISTRY_LEN 128 54 #define NR_REG_MAX_TYPE_LEN 32 55 56 typedef char NR_registry[NR_REG_MAX_NR_REGISTRY_LEN]; 57 typedef char NR_registry_type[NR_REG_MAX_TYPE_LEN]; 58 59 extern NR_registry NR_TOP_LEVEL_REGISTRY; 60 61 int NR_reg_init(void); 62 63 int NR_reg_initted(void); 64 65 int NR_reg_get_char(NR_registry name, char *out); 66 int NR_reg_get_uchar(NR_registry name, UCHAR *out); 67 int NR_reg_get_uint2(NR_registry name, UINT2 *out); 68 int NR_reg_get_int4(NR_registry name, INT4 *out); 69 int NR_reg_get_uint4(NR_registry name, UINT4 *out); 70 int NR_reg_get_uint8(NR_registry name, UINT8 *out); 71 int NR_reg_get_double(NR_registry name, double *out); 72 int NR_reg_get_registry(NR_registry name, NR_registry out); 73 74 int NR_reg_get_bytes(NR_registry name, UCHAR *out, size_t size, size_t *length); 75 int NR_reg_get_string(NR_registry name, char *out, size_t size); 76 int NR_reg_get_length(NR_registry name, size_t *length); 77 78 79 int NR_reg_get2_char(NR_registry prefix, char *name, char *); 80 int NR_reg_get2_uchar(NR_registry prefix, char *name, UCHAR *); 81 int NR_reg_get2_uint2(NR_registry prefix, char *name, UINT2 *); 82 83 int NR_reg_alloc2_string(NR_registry prefix, char *name, char **); 84 int NR_reg_alloc2_data(NR_registry prefix, char *name, Data *); 85 86 int NR_reg_set_char(NR_registry name, char data); 87 int NR_reg_set_uchar(NR_registry name, UCHAR data); 88 int NR_reg_set_int4(NR_registry name, INT4 data); 89 int NR_reg_set_uint4(NR_registry name, UINT4 data); 90 91 int NR_reg_set_registry(NR_registry name); 92 93 int NR_reg_set_bytes(NR_registry name, UCHAR *data, size_t length); 94 int NR_reg_set_string(NR_registry name, char *data); 95 96 int NR_reg_set2_uchar(NR_registry prefix, char *name, UCHAR data); 97 98 int NR_reg_set2_string(NR_registry prefix, char *name, char *data); 99 100 int NR_reg_del(NR_registry name); 101 102 int NR_reg_get_child_count(NR_registry parent, unsigned int *count); 103 int NR_reg_get_child_registry(NR_registry parent, unsigned int i, NR_registry child); 104 105 /* convenience methods, call RFREE on the returned data */ 106 int NR_reg_alloc_data(NR_registry name, Data *data); 107 int NR_reg_alloc_string(NR_registry name, char **data); 108 109 #define NR_REG_CB_ACTION_ADD (1<<0) 110 #define NR_REG_CB_ACTION_CHANGE (1<<1) 111 #define NR_REG_CB_ACTION_DELETE (1<<2) 112 #define NR_REG_CB_ACTION_FINAL (1<<6) 113 int NR_reg_register_callback(NR_registry name, char action, void (*cb)(void *cb_arg, char action, NR_registry name), void *cb_arg); 114 115 int NR_reg_make_registry(NR_registry parent, char *child, NR_registry out); 116 117 #endif