Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=778a9610bf9e557c7d655c9f3693148a9c4a2f8b
commit 778a9610bf9e557c7d655c9f3693148a9c4a2f8b Author: Michel Hermier <[email protected]> Date: Sat Jun 8 12:36:14 2013 +0200 libpacman: Remove this_section argument of pacman_parse_config. Loading config files should be done at one for the ligrary user. diff --git a/doc/libpacman-changes.txt b/doc/libpacman-changes.txt index f63f57a..8a36121 100644 --- a/doc/libpacman-changes.txt +++ b/doc/libpacman-changes.txt @@ -22,7 +22,7 @@ A new private (for now) library that abstract some of the usual API a 'C' progra PM_LIST is now a flib FList meaning that pacman_list(3) API will be deprecated when FLib will be stabilized. -pacman_parse_config: Do not take the pacman_cb_db_register callback argument, it's only purpose was to fill up a list of PM_DB while we can allways get it with pacman_get_option (PM_OPT_SYNCDB, ...). +pacman_parse_config: Removed the pacman_cb_db_register callback argument, it's only purpose was to fill up a list of PM_DB while we can allways get it with pacman_get_option (PM_OPT_SYNCDB, ...). Removed the_this section argument, this can be easily replaced using the Include configuration directive and dedicated configuration files. ==== Symbols added: diff --git a/lib/libpacman/pacman.c b/lib/libpacman/pacman.c index 8a2ed78..14ecc4f 100644 --- a/lib/libpacman/pacman.c +++ b/lib/libpacman/pacman.c @@ -37,6 +37,8 @@ #include <limits.h> /* PATH_MAX */ #include <stdarg.h> +#include <fstring.h> + /* pacman-g2 */ #include "pacman.h" @@ -1040,12 +1042,8 @@ int pacman_reg_match(const char *string, const char *pattern) return(_pacman_reg_match(string, pattern)); } -/** Parses a configuration file. - * @param file path to the config file. - * @param this_section the config current section being parsed - * @return 0 on success, -1 on error (pm_errno is set accordingly) - */ -int pacman_parse_config(char *file, const char *this_section) +static +int _pacman_parse_config(char *file, const char *this_section) { FILE *fp = NULL; char line[PATH_MAX+1]; @@ -1063,7 +1061,7 @@ int pacman_parse_config(char *file, const char *this_section) return(0); } - if(this_section != NULL && strlen(this_section) > 0) { + if (f_strlen (this_section) > 0) { strncpy(section, this_section, min(255, strlen(this_section))); if(!strcmp(section, "local")) { RET_ERR(PM_ERR_CONF_LOCAL, -1); @@ -1134,7 +1132,7 @@ int pacman_parse_config(char *file, const char *this_section) char conf[PATH_MAX]; strncpy(conf, ptr, PATH_MAX); _pacman_log(PM_LOG_DEBUG, _("config: including %s\n"), conf); - pacman_parse_config(conf, section); + _pacman_parse_config(conf, section); } else if(!strcmp(section, "options")) { if(!strcmp(key, "NOUPGRADE")) { char *p = ptr; @@ -1292,6 +1290,15 @@ int pacman_parse_config(char *file, const char *this_section) return(0); } +/** Parses a configuration file. + * @param file path to the config file. + * @param this_section the config current section being parsed + * @return 0 on success, -1 on error (pm_errno is set accordingly) + */ +int pacman_parse_config (char *file) { + return _pacman_parse_config (file, NULL); +} + /* @} */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/pacman.h b/lib/libpacman/pacman.h index ea138b3..c7d2efa 100644 --- a/lib/libpacman/pacman.h +++ b/lib/libpacman/pacman.h @@ -211,7 +211,7 @@ PM_LIST *pacman_pkg_getowners(char *filename); int pacman_pkg_load(char *filename, PM_PKG **pkg); int pacman_pkg_free(PM_PKG *pkg); char *pacman_fetch_pkgurl(char *url); -int pacman_parse_config(char *file, const char *this_section); +int pacman_parse_config(char *file); int pacman_pkg_vercmp(const char *ver1, const char *ver2); int pacman_reg_match(const char *string, const char *pattern); diff --git a/src/pacman-g2/pacman-g2.c b/src/pacman-g2/pacman-g2.c index 613fc9f..fea78e8 100644 --- a/src/pacman-g2/pacman-g2.c +++ b/src/pacman-g2/pacman-g2.c @@ -34,6 +34,7 @@ #include <time.h> #include <pacman.h> + /* pacman-g2 */ #include "list.h" #include "util.h" @@ -558,7 +559,7 @@ int main(int argc, char *argv[]) if(config->configfile == NULL) { config->configfile = strdup(PACCONF); } - if(pacman_parse_config(config->configfile, "") != 0) { + if(pacman_parse_config(config->configfile) != 0) { ERR(NL, _("failed to parse config (%s)\n"), pacman_strerror(pm_errno)); cleanup(1); } _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
