1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 3*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 4*7c478bd9Sstevel@tonic-gate */ 5*7c478bd9Sstevel@tonic-gate 6*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 7*7c478bd9Sstevel@tonic-gate 8*7c478bd9Sstevel@tonic-gate /* 9*7c478bd9Sstevel@tonic-gate * prof-int.h 10*7c478bd9Sstevel@tonic-gate */ 11*7c478bd9Sstevel@tonic-gate 12*7c478bd9Sstevel@tonic-gate #ifndef __PROF_INT_H 13*7c478bd9Sstevel@tonic-gate 14*7c478bd9Sstevel@tonic-gate #include <time.h> 15*7c478bd9Sstevel@tonic-gate #include <com_err.h> 16*7c478bd9Sstevel@tonic-gate #include "prof_err.h" 17*7c478bd9Sstevel@tonic-gate #include <profile.h> 18*7c478bd9Sstevel@tonic-gate 19*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) || defined(_MSDOS) || defined(_WIN32) 20*7c478bd9Sstevel@tonic-gate #define PROTOTYPE(x) x 21*7c478bd9Sstevel@tonic-gate #else 22*7c478bd9Sstevel@tonic-gate #define PROTOTYPE(x) () 23*7c478bd9Sstevel@tonic-gate #endif 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate #if defined(_MSDOS) 26*7c478bd9Sstevel@tonic-gate /* From k5-config.h */ 27*7c478bd9Sstevel@tonic-gate #define SIZEOF_INT 2 28*7c478bd9Sstevel@tonic-gate #define SIZEOF_SHORT 2 29*7c478bd9Sstevel@tonic-gate #define SIZEOF_LONG 4 30*7c478bd9Sstevel@tonic-gate #endif 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #if defined(_WIN32) 33*7c478bd9Sstevel@tonic-gate #define SIZEOF_INT 4 34*7c478bd9Sstevel@tonic-gate #define SIZEOF_SHORT 2 35*7c478bd9Sstevel@tonic-gate #define SIZEOF_LONG 4 36*7c478bd9Sstevel@tonic-gate #endif 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #if defined(macintosh) 39*7c478bd9Sstevel@tonic-gate #define NO_SYS_TYPES_H 40*7c478bd9Sstevel@tonic-gate #define NO_SYS_STAT_H 41*7c478bd9Sstevel@tonic-gate #endif 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate typedef long prf_magic_t; 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* 46*7c478bd9Sstevel@tonic-gate * This is the structure which stores the profile information for a 47*7c478bd9Sstevel@tonic-gate * particular configuration file. 48*7c478bd9Sstevel@tonic-gate */ 49*7c478bd9Sstevel@tonic-gate struct _prf_file_t { 50*7c478bd9Sstevel@tonic-gate prf_magic_t magic; 51*7c478bd9Sstevel@tonic-gate char *comment; 52*7c478bd9Sstevel@tonic-gate profile_filespec_t filespec; 53*7c478bd9Sstevel@tonic-gate struct profile_node *root; 54*7c478bd9Sstevel@tonic-gate time_t timestamp; 55*7c478bd9Sstevel@tonic-gate int flags; 56*7c478bd9Sstevel@tonic-gate int upd_serial; 57*7c478bd9Sstevel@tonic-gate struct _prf_file_t *next; 58*7c478bd9Sstevel@tonic-gate }; 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate typedef struct _prf_file_t *prf_file_t; 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate /* 63*7c478bd9Sstevel@tonic-gate * The profile flags 64*7c478bd9Sstevel@tonic-gate */ 65*7c478bd9Sstevel@tonic-gate #define PROFILE_FILE_RW 0x0001 66*7c478bd9Sstevel@tonic-gate #define PROFILE_FILE_DIRTY 0x0002 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate /* 69*7c478bd9Sstevel@tonic-gate * This structure defines the high-level, user visible profile_t 70*7c478bd9Sstevel@tonic-gate * object, which is used as a handle by users who need to query some 71*7c478bd9Sstevel@tonic-gate * configuration file(s) 72*7c478bd9Sstevel@tonic-gate */ 73*7c478bd9Sstevel@tonic-gate struct _profile_t { 74*7c478bd9Sstevel@tonic-gate prf_magic_t magic; 75*7c478bd9Sstevel@tonic-gate prf_file_t first_file; 76*7c478bd9Sstevel@tonic-gate }; 77*7c478bd9Sstevel@tonic-gate 78*7c478bd9Sstevel@tonic-gate typedef struct _profile_options { 79*7c478bd9Sstevel@tonic-gate char *name; 80*7c478bd9Sstevel@tonic-gate int *value; 81*7c478bd9Sstevel@tonic-gate int found; 82*7c478bd9Sstevel@tonic-gate } profile_options_boolean; 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate typedef struct _profile_times { 85*7c478bd9Sstevel@tonic-gate char *name; 86*7c478bd9Sstevel@tonic-gate char **value; 87*7c478bd9Sstevel@tonic-gate int found; 88*7c478bd9Sstevel@tonic-gate } profile_option_strings; 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate /* 91*7c478bd9Sstevel@tonic-gate * Used by the profile iterator in prof_get.c 92*7c478bd9Sstevel@tonic-gate */ 93*7c478bd9Sstevel@tonic-gate #define PROFILE_ITER_LIST_SECTION 0x0001 94*7c478bd9Sstevel@tonic-gate #define PROFILE_ITER_SECTIONS_ONLY 0x0002 95*7c478bd9Sstevel@tonic-gate #define PROFILE_ITER_RELATIONS_ONLY 0x0004 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate #define PROFILE_ITER_FINAL_SEEN 0x0100 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate /* 100*7c478bd9Sstevel@tonic-gate * Check if a filespec is last in a list (NULL on UNIX, invalid FSSpec on MacOS 101*7c478bd9Sstevel@tonic-gate */ 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate #ifdef PROFILE_USES_PATHS 104*7c478bd9Sstevel@tonic-gate #define PROFILE_LAST_FILESPEC(x) (((x) == NULL) || ((x)[0] == '\0')) 105*7c478bd9Sstevel@tonic-gate #else 106*7c478bd9Sstevel@tonic-gate #define PROFILE_LAST_FILESPEC(x) (((x).vRefNum == 0) && ((x).parID == 0) && ((x).name[0] == '\0')) 107*7c478bd9Sstevel@tonic-gate #endif 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate /* profile_parse.c */ 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate errcode_t profile_parse_file 112*7c478bd9Sstevel@tonic-gate PROTOTYPE((FILE *f, struct profile_node **root)); 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate errcode_t profile_write_tree_file 115*7c478bd9Sstevel@tonic-gate PROTOTYPE((struct profile_node *root, FILE *dstfile)); 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate /* prof_tree.c */ 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate void profile_free_node 121*7c478bd9Sstevel@tonic-gate PROTOTYPE((struct profile_node *relation)); 122*7c478bd9Sstevel@tonic-gate 123*7c478bd9Sstevel@tonic-gate errcode_t profile_create_node 124*7c478bd9Sstevel@tonic-gate PROTOTYPE((const char *name, const char *value, 125*7c478bd9Sstevel@tonic-gate struct profile_node **ret_node)); 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate errcode_t profile_verify_node 128*7c478bd9Sstevel@tonic-gate PROTOTYPE((struct profile_node *node)); 129*7c478bd9Sstevel@tonic-gate 130*7c478bd9Sstevel@tonic-gate errcode_t profile_add_node 131*7c478bd9Sstevel@tonic-gate PROTOTYPE ((struct profile_node *section, 132*7c478bd9Sstevel@tonic-gate const char *name, const char *value, 133*7c478bd9Sstevel@tonic-gate struct profile_node **ret_node)); 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate errcode_t profile_make_node_final 136*7c478bd9Sstevel@tonic-gate PROTOTYPE((struct profile_node *node)); 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate int profile_is_node_final 139*7c478bd9Sstevel@tonic-gate PROTOTYPE((struct profile_node *node)); 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate const char *profile_get_node_name 142*7c478bd9Sstevel@tonic-gate PROTOTYPE((struct profile_node *node)); 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate const char *profile_get_node_value 145*7c478bd9Sstevel@tonic-gate PROTOTYPE((struct profile_node *node)); 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate errcode_t profile_find_node 148*7c478bd9Sstevel@tonic-gate PROTOTYPE ((struct profile_node *section, 149*7c478bd9Sstevel@tonic-gate const char *name, const char *value, 150*7c478bd9Sstevel@tonic-gate int section_flag, void **state, 151*7c478bd9Sstevel@tonic-gate struct profile_node **node)); 152*7c478bd9Sstevel@tonic-gate 153*7c478bd9Sstevel@tonic-gate errcode_t profile_find_node_relation 154*7c478bd9Sstevel@tonic-gate PROTOTYPE ((struct profile_node *section, 155*7c478bd9Sstevel@tonic-gate const char *name, void **state, 156*7c478bd9Sstevel@tonic-gate char **ret_name, char **value)); 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate errcode_t profile_find_node_subsection 159*7c478bd9Sstevel@tonic-gate PROTOTYPE ((struct profile_node *section, 160*7c478bd9Sstevel@tonic-gate const char *name, void **state, 161*7c478bd9Sstevel@tonic-gate char **ret_name, struct profile_node **subsection)); 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate errcode_t profile_get_node_parent 164*7c478bd9Sstevel@tonic-gate PROTOTYPE ((struct profile_node *section, 165*7c478bd9Sstevel@tonic-gate struct profile_node **parent)); 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate errcode_t profile_delete_node_relation 168*7c478bd9Sstevel@tonic-gate PROTOTYPE ((struct profile_node *section, const char *name)); 169*7c478bd9Sstevel@tonic-gate 170*7c478bd9Sstevel@tonic-gate errcode_t profile_find_node_name 171*7c478bd9Sstevel@tonic-gate PROTOTYPE ((struct profile_node *section, void **state, 172*7c478bd9Sstevel@tonic-gate char **ret_name)); 173*7c478bd9Sstevel@tonic-gate 174*7c478bd9Sstevel@tonic-gate errcode_t profile_node_iterator_create 175*7c478bd9Sstevel@tonic-gate PROTOTYPE((profile_t profile, const char **names, 176*7c478bd9Sstevel@tonic-gate int flags, void **ret_iter)); 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate void profile_node_iterator_free 179*7c478bd9Sstevel@tonic-gate PROTOTYPE((void **iter_p)); 180*7c478bd9Sstevel@tonic-gate 181*7c478bd9Sstevel@tonic-gate errcode_t profile_node_iterator 182*7c478bd9Sstevel@tonic-gate PROTOTYPE((void **iter_p, struct profile_node **ret_node, 183*7c478bd9Sstevel@tonic-gate char **ret_name, char **ret_value)); 184*7c478bd9Sstevel@tonic-gate 185*7c478bd9Sstevel@tonic-gate errcode_t profile_remove_node 186*7c478bd9Sstevel@tonic-gate PROTOTYPE((struct profile_node *node)); 187*7c478bd9Sstevel@tonic-gate 188*7c478bd9Sstevel@tonic-gate errcode_t profile_set_relation_value 189*7c478bd9Sstevel@tonic-gate PROTOTYPE((struct profile_node *node, const char *new_value)); 190*7c478bd9Sstevel@tonic-gate 191*7c478bd9Sstevel@tonic-gate errcode_t profile_rename_node 192*7c478bd9Sstevel@tonic-gate PROTOTYPE((struct profile_node *node, const char *new_name)); 193*7c478bd9Sstevel@tonic-gate 194*7c478bd9Sstevel@tonic-gate /* prof_file.c */ 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate errcode_t profile_open_file 197*7c478bd9Sstevel@tonic-gate PROTOTYPE ((const_profile_filespec_t file, prf_file_t *ret_prof)); 198*7c478bd9Sstevel@tonic-gate 199*7c478bd9Sstevel@tonic-gate errcode_t profile_update_file 200*7c478bd9Sstevel@tonic-gate PROTOTYPE ((prf_file_t profile)); 201*7c478bd9Sstevel@tonic-gate 202*7c478bd9Sstevel@tonic-gate errcode_t profile_flush_file 203*7c478bd9Sstevel@tonic-gate PROTOTYPE ((prf_file_t profile)); 204*7c478bd9Sstevel@tonic-gate 205*7c478bd9Sstevel@tonic-gate void profile_free_file 206*7c478bd9Sstevel@tonic-gate PROTOTYPE ((prf_file_t profile)); 207*7c478bd9Sstevel@tonic-gate 208*7c478bd9Sstevel@tonic-gate errcode_t profile_close_file 209*7c478bd9Sstevel@tonic-gate PROTOTYPE ((prf_file_t profile)); 210*7c478bd9Sstevel@tonic-gate 211*7c478bd9Sstevel@tonic-gate /* prof_init.c -- included from profile.h */ 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate /* prof_get.c */ 214*7c478bd9Sstevel@tonic-gate 215*7c478bd9Sstevel@tonic-gate errcode_t profile_get_value 216*7c478bd9Sstevel@tonic-gate PROTOTYPE ((profile_t profile, const char **names, 217*7c478bd9Sstevel@tonic-gate const char **ret_value)); 218*7c478bd9Sstevel@tonic-gate /* Others included from profile.h */ 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate /* prof_set.c -- included from profile.h */ 221*7c478bd9Sstevel@tonic-gate 222*7c478bd9Sstevel@tonic-gate #define __PROF_INT_H 223*7c478bd9Sstevel@tonic-gate #endif 224