1 /* 2 * scf.h 3 * 4 * Copyright (C) 1997 Rasca, Berlin 1997-99 5 * EMail: thron@gmx.de 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU Library General Public License as published 9 * by the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 */ 21 22 #ifndef _SCF_H_ 23 #define _SCF_H_ 1 24 25 #define SCF_READ 1 26 #define SCF_WRITE 2 27 #define SCF_APPEND 4 28 29 #define SCF_STD 1 30 #define SCF_CAP 2 31 #define SCF_X11 4 32 #define SCF_INI 8 33 #define SCF_RAW 16 34 #define SCF_RES1 256 35 36 #define SCF_SYSTEM 1 37 #define SCF_PRIVAT 2 38 39 #define SCF_TRUE 1 40 #define SCF_FALSE 0 41 #define SCF_NO_PTR -1 42 #define SCF_NO_EOL -2 43 #define SCF_NO_RAM -3 44 #define SCF_NO_VAL -4 45 #define SCF_NO_SCF -5 46 #define SCF_IO_ERR -6 47 48 #define SCFF_VERSION "1.0" 49 /* the root/default section */ 50 #define SCF_ROOT NULL 51 #define SCF_WHITE 'W' 52 53 #define scf_id unsigned int 54 typedef unsigned char * string; 55 #ifndef uchar 56 #define uchar unsigned char 57 #endif 58 59 scf_id scf_init (const char *pname, const char *scf_file); 60 int scf_fini (scf_id id); 61 62 int scf_read (scf_id id); 63 int scf_add_section (scf_id id, char *name, char *comment); 64 int scf_has_section (scf_id id, char *sec); 65 int scf_section_has_key (scf_id id, const char *sec, const char *key); 66 #define scf_has_key(id, key) scf_section_has_key(id, SCF_ROOT, key) 67 int scf_get_type (scf_id, const string section, const string key); 68 string scf_get_val (scf_id id, const string section, const string key); 69 #define scf_val(id, key) scf_get_val(id, SCF_ROOT, key); 70 string scf_get_comment (scf_id id, const string sec, const string key); 71 int scf_get_int_val (scf_id id, const string sec, const string key, int *rv); 72 int scf_get_bool_val (scf_id id, const string sec, const string key, int *rv); 73 double scf_get_val_as_double (scf_id id, const string sec, const string key); 74 int scf_set_val (scf_id id, string sec, string key, string value, string comment); 75 int scf_open (scf_id id, int mode); 76 int scf_close (scf_id id); 77 int scf_sync (scf_id id); 78 int scf_set_mode (scf_id id, int mode, const char *kvps, const char *cs); 79 void scf_set_comment_char (unsigned int scfd, char c); 80 void scf_set_kvp_delimiter (unsigned int scfd, char c); 81 const char *scf_file_name (const char *pname, int flags); 82 int scf_strip_eol (string line); 83 int scf_next_line (scf_id id, string *line); 84 int scf_no_of_subsections (scf_id, const string sec); 85 string scf_get_array_val (scf_id, const string sec, const string key, int n); 86 int scf_get_array_int_val (scf_id, const string sec, const string key, int n, int *val); 87 88 /* */ 89 #define SCF_COMMENT 1 90 #define SCF_SECTION 2 91 #define SCF_STRING 4 92 #define SCF_INT 8 93 #define SCF_BIN 16 94 #define SCF_BOOL 32 95 #define SCF_ARRAY 64 96 97 #ifndef PATH_MAX 98 /* may be some systems don't have this predefined in limits.h!? 99 */ 100 #error "comment this out if you don't have a limits.h!" 101 #define PATH_MAX 1024 102 #endif 103 /* same .. 104 */ 105 #ifndef NAME_MAX 106 #define NAME_MAX 256 107 #endif 108 109 #endif /* _SCF_H_ */ 110 111