Comment: | Added an lc_seterrstr() function |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f953f16a77c572d5c5e61ea30ba7d6ff |
User & Date: | rkeene on 2006-12-16 17:06:08 |
Other Links: | manifest | tags |
2006-12-17
| ||
00:11 | Updated libconfig to reset lc_errno at the start of each function check-in: c8032b5a5e user: rkeene tags: trunk | |
2006-12-16
| ||
17:06 | Added an lc_seterrstr() function check-in: f953f16a77 user: rkeene tags: trunk | |
17:06 | Subversion to Fossil Copy Commit. Please Ignore. Recording copying lc_geterrstr.3.in to lc_seterrstr.3.in. check-in: 9f254f7f02 user: rkeene tags: trunk | |
Modified build/build_web_manpages from [15a48182c3] to [30cc606ea6].
1 2 3 4 5 6 7 8 9 10 | #! /bin/bash if [ ! -f libconfig.3 ]; then cd .. fi if [ ! -f libconfig.3 ]; then echo 'Could not find libconfig.3, aborting.' >&2 exit 1 fi | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #! /bin/bash if [ ! -f libconfig.3 ]; then cd .. fi if [ ! -f libconfig.3 ]; then echo 'Could not find libconfig.3, aborting.' >&2 exit 1 fi for file in lc_cleanup lc_geterrno lc_geterrstr lc_seterrstr lc_process lc_process_file lc_register_callback lc_register_var libconfig; do man2html -H "REPLACE" -M "/ME" < ${file}.3 | grep -iv '^Content-Type:' | sed 's@"http://REPLACE/ME?\([0-9]*\)+\([^"]*\)"@"\2.htm"@;s@http://REPLACE/ME@@g' > /web/rkeene/docs/oss/libconfig/${file}.htm done |
build/prep.sh became executable with contents [3f4d67e154].
Modified lc_cleanup.3.in from [1a58c9eea6] to [efcfee978b].
︙ | ︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrstr (3), .BR lc_geterrno (3), .BR lc_process_file (3), .BR lc_process (3) | > > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_seterrstr (3), .BR lc_geterrstr (3), .BR lc_geterrno (3), .BR lc_process_file (3), .BR lc_process (3) |
Modified lc_geterrno.3.in from [cd34ea9cd7] to [d8407e858d].
︙ | ︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrstr (3), .BR lc_cleanup (3), .BR lc_process_file (3), .BR lc_process (3) | > > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrstr (3), .BR lc_seterrstr (3), .BR lc_cleanup (3), .BR lc_process_file (3), .BR lc_process (3) |
Modified lc_geterrstr.3.in from [72b9664bc6] to [36f9da08c6].
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrno (3), .BR lc_cleanup (3), .BR lc_process_file (3), .BR lc_process (3) | > > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_seterrstr (3), .BR lc_geterrno (3), .BR lc_cleanup (3), .BR lc_process_file (3), .BR lc_process (3) |
Modified lc_process.3.in from [95fe0e123b] to [0f2dddbaaa].
︙ | ︙ | |||
95 96 97 98 99 100 101 102 103 104 105 106 107 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrno (3), .BR lc_geterrstr (3), .BR lc_cleanup (3), .BR lc_process_file (3) | > > | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrno (3), .BR lc_seterrstr (3), .BR lc_geterrstr (3), .BR lc_cleanup (3), .BR lc_process_file (3) |
Modified lc_process_file.3.in from [ea98de7617] to [aecb56c52b].
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrno (3), .BR lc_geterrstr (3), .BR lc_cleanup (3), .BR lc_process (3) | > > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrno (3), .BR lc_geterrstr (3), .BR lc_seterrstr (3), .BR lc_cleanup (3), .BR lc_process (3) |
Modified lc_register_callback.3.in from [cea18abe88] to [caede5b68d].
︙ | ︙ | |||
149 150 151 152 153 154 155 | .TP LC_CBRET_OKAY Returning LC_CBRET_OKAY from a callback indicates that all went well and further processing may continue. .TP LC_CBRET_ERROR Returnning LC_CBRET_ERROR from a callback indicates that the command failed for some reason, the error will be passed back down the chain back to the .BR lc_process (3) | | | | | | | 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | .TP LC_CBRET_OKAY Returning LC_CBRET_OKAY from a callback indicates that all went well and further processing may continue. .TP LC_CBRET_ERROR Returnning LC_CBRET_ERROR from a callback indicates that the command failed for some reason, the error will be passed back down the chain back to the .BR lc_process (3) call that began processing the configuration data. If LC_CBRET_ERROR is returned from a callback that begins a section, the entire section is ignored. If LC_CBRET_ERROR is returned from a callback that ends a section, the error is ignored. .SH "RETURN VALUE" On success 0 is returned, otherwise -1 is returned. .SH EXAMPLE .nf #include <libconfig.h> #include <strings.h> #include <stdlib.h> #include <stdio.h> int callback_ifmodule(const char *shortvar, const char *var, const char *arguments, const char *value, lc_flags_t flags, void *extra) { if (flags == LC_FLAGS_SECTIONEND) { return(LC_CBRET_OKAY); } if (flags != LC_FLAGS_SECTIONSTART) { lc_seterrstr("IfModule can only be used as a \\ section."); return(LC_CBRET_ERROR); } if (arguments == NULL) { lc_seterrstr("You must specify an argument to \\ IfModule."); return(LC_CBRET_ERROR); } printf("IfModule %s\\n", arguments); if (strcasecmp(arguments, "MyModule") == 0) { return(LC_CBRET_IGNORESECTION); |
︙ | ︙ | |||
221 222 223 224 225 226 227 228 229 230 231 232 233 | .SH ERRORS .TP .B ENOMEM Memory could not be allocated to create the needed internal structures. .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_geterrno (3), .BR lc_geterrstr (3), .BR lc_cleanup (3), .BR lc_process_file (3), .BR lc_process (3) | > > | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | .SH ERRORS .TP .B ENOMEM Memory could not be allocated to create the needed internal structures. .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), .BR lc_geterrno (3), .BR lc_geterrstr (3), .BR lc_seterrstr (3), .BR lc_cleanup (3), .BR lc_process_file (3), .BR lc_process (3) |
Modified lc_register_var.3.in from [6224b99a5a] to [26c717cf6a].
︙ | ︙ | |||
142 143 144 145 146 147 148 149 150 151 152 153 154 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR lc_register_callback (3), .BR lc_geterrno (3), .BR lc_geterrstr (3), .BR lc_cleanup (3), .BR lc_process_file (3), .BR lc_process (3) | > > | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | } return(EXIT_SUCCESS); } .fi .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_callback (3), .BR lc_geterrno (3), .BR lc_geterrstr (3), .BR lc_seterrstr (3), .BR lc_cleanup (3), .BR lc_process_file (3), .BR lc_process (3) |
Modified lc_seterrstr.3.in from [72b9664bc6] to [eb760dc316].
1 2 | .TH LC_GETERRSTR 3 "25 Oct 04" "@PACKAGE_STRING@" .SH NAME | | | | < | < < < < < < < < < < < < < < < | < < | < < < < < < < < < < < < < < < < < < < < > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | .TH LC_GETERRSTR 3 "25 Oct 04" "@PACKAGE_STRING@" .SH NAME lc_geterrstr \- Set an error message from a callback. .SH SYNOPSIS .B #include <libconfig.h> .sp .BI "void lc_seterrstr(const char *" errstr ");" .SH DESCRIPTION The .BR lc_seterrstr (3) function sets a human readable error message to be returned by .BR lc_geterrstr (3) function when an error is returned from a callback function. The value is ignored if the error is not related to a callback. .SH "SEE ALSO" .BR libconfig (3), .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterrno (3), .BR lc_geterrstr (3), .BR lc_cleanup (3), .BR lc_process_file (3), .BR lc_process (3) |
Modified libconfig.3.in from [08444a4029] to [93e1c94d05].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | .BI "int lc_process(int " argc ", char **" argv ", const char *" appname ", lc_conf_type_t " type ", const char *" extra ");" .BI "lc_err_t lc_geterrno(void);" .BI "char *lc_geterrstr(void);" .SH DESCRIPTION Libconfig is a library to provide easy access to configuration data in a consistent and logical manner. Variables (registered through .BR lc_register_var (3) or .BR lc_register_callback (3)) are processed with the .BR lc_process (3) | > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | .BI "int lc_process(int " argc ", char **" argv ", const char *" appname ", lc_conf_type_t " type ", const char *" extra ");" .BI "lc_err_t lc_geterrno(void);" .BI "char *lc_geterrstr(void);" .BI "void lc_geterrstr(const char *" errstr ");" .SH DESCRIPTION Libconfig is a library to provide easy access to configuration data in a consistent and logical manner. Variables (registered through .BR lc_register_var (3) or .BR lc_register_callback (3)) are processed with the .BR lc_process (3) |
︙ | ︙ | |||
73 74 75 76 77 78 79 80 81 82 | .fi .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterr (3), .BR lc_geterrstr (3), .BR lc_cleanup (3), .BR lc_process (3), .BR lc_process_file (3) | > | 75 76 77 78 79 80 81 82 83 84 85 | .fi .SH "SEE ALSO" .BR lc_register_var (3), .BR lc_register_callback (3), .BR lc_geterr (3), .BR lc_geterrstr (3), .BR lc_seterrstr (3), .BR lc_cleanup (3), .BR lc_process (3), .BR lc_process_file (3) |
Modified libconfig.c from [341b40c218] to [508cc92a36].
︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #ifdef HAVE_PWD_H #include <pwd.h> #endif struct lc_varhandler_st *varhandlers = NULL; lc_err_t lc_errno = LC_ERR_NONE; const char *lc_errfile = NULL; int lc_optind = 0; int lc_errline = 0; extern char **environ; static int lc_process_var_string(void *data, const char *value, const char **endptr) { | > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #ifdef HAVE_PWD_H #include <pwd.h> #endif struct lc_varhandler_st *varhandlers = NULL; lc_err_t lc_errno = LC_ERR_NONE; const char *lc_err_usererrmsg = NULL; const char *lc_errfile = NULL; int lc_optind = 0; int lc_errline = 0; extern char **environ; static int lc_process_var_string(void *data, const char *value, const char **endptr) { |
︙ | ︙ | |||
977 978 979 980 981 982 983 984 985 986 987 988 989 990 | next = handler->_next; free(handler); handler = next; } varhandlers = NULL; return; } int lc_process(int argc, char **argv, const char *appname, lc_conf_type_t type, const char *extra) { | > > > > > > | 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 | next = handler->_next; free(handler); handler = next; } if (lc_err_usererrmsg) { free((char *) lc_err_usererrmsg); lc_err_usererrmsg = NULL; } varhandlers = NULL; return; } int lc_process(int argc, char **argv, const char *appname, lc_conf_type_t type, const char *extra) { |
︙ | ︙ | |||
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 | retval = lc_errno; lc_errno = LC_ERR_NONE; return(retval); } char *lc_geterrstr(void) { static char retval[512]; | > > > > | | 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 | retval = lc_errno; lc_errno = LC_ERR_NONE; return(retval); } void lc_seterrstr(const char *usererrmsg) { lc_err_usererrmsg = strdup(usererrmsg); } char *lc_geterrstr(void) { static char retval[512]; const char *errmsg = NULL; switch (lc_errno) { case LC_ERR_NONE: errmsg = "Success"; break; case LC_ERR_INVCMD: errmsg = "Invalid command or option"; |
︙ | ︙ | |||
1042 1043 1044 1045 1046 1047 1048 | case LC_ERR_BADFORMAT: errmsg = "Bad data specified or incorrect format."; break; case LC_ERR_CANTOPEN: errmsg = "Can't open file."; break; case LC_ERR_CALLBACK: | > > > | > | 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 | case LC_ERR_BADFORMAT: errmsg = "Bad data specified or incorrect format."; break; case LC_ERR_CANTOPEN: errmsg = "Can't open file."; break; case LC_ERR_CALLBACK: if (lc_err_usererrmsg) { errmsg = lc_err_usererrmsg; } else { errmsg = "Error return from application handler."; } break; case LC_ERR_ENOMEM: errmsg = "Insuffcient memory."; break; } /* |
︙ | ︙ |
Modified libconfig.h.in from [6dd0b27349] to [a51c1e0b82].
︙ | ︙ | |||
76 77 78 79 80 81 82 83 84 85 86 87 88 89 | __BLANK_LINE__ int lc_process(int argc, char **argv, const char *appname, lc_conf_type_t type, const char *extra); int lc_register_callback(const char *var, char opt, lc_var_type_t type, int (*callback)(const char *, const char *, const char *, const char *, lc_flags_t, void *), void *extra); int lc_register_var(const char *var, lc_var_type_t type, void *data, char opt); lc_err_t lc_geterrno(void); char *lc_geterrstr(void); int lc_process_file(const char *appname, const char *pathname, lc_conf_type_t type); void lc_cleanup(void); __BLANK_LINE__ !define LC_CBRET_IGNORESECTION (255) | > | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | __BLANK_LINE__ int lc_process(int argc, char **argv, const char *appname, lc_conf_type_t type, const char *extra); int lc_register_callback(const char *var, char opt, lc_var_type_t type, int (*callback)(const char *, const char *, const char *, const char *, lc_flags_t, void *), void *extra); int lc_register_var(const char *var, lc_var_type_t type, void *data, char opt); lc_err_t lc_geterrno(void); void lc_seterrstr(const char *usererrstr); char *lc_geterrstr(void); int lc_process_file(const char *appname, const char *pathname, lc_conf_type_t type); void lc_cleanup(void); __BLANK_LINE__ !define LC_CBRET_IGNORESECTION (255) |
︙ | ︙ |