summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2019-07-28 15:06:01 +0000
committerJason Woodward2019-07-28 19:46:11 +0000
commit283d0fc9572582c596ac9e9c9d7df7f161bcfc32 (patch)
tree873bb44484e62a3461812147d3d76b076a01eecf
parent3d8d20e146829c3dfe82b246ef35da4d3b0a27b1 (diff)
downloadslapt-get-slapt_vector.tar.gz
update naming convention for data structuresslapt_vector
s/slapt_pkg_into_t/slapt_pkg_t/g s/slapt_free_pkg/slapt_pkg_t_free/g s/slapt_init_pkg/slapt_pkg_t_init/g s/slapt_rc_config/slapt_config_t/ s/slapt_init_config/slapt_config_t_init/g s/slapt_read_rc_config/slapt_config_t_read/g s/slapt_free_rc_config/slapt_config_t_free/g s/slapt_free_source/slapt_source_t_free/g s/slapt_init_source/slapt_source_t_init/g s/slapt_write_rc_config/slapt_config_t_write/g s/slapt_init_regex/slapt_regex_t_init/g s/slapt_execute_regex/slapt_regex_t_execute/g s/slapt_regex_extract_match/slapt_regex_t_extract_match/g s/slapt_free_regex/slapt_regex_t_free/g
-rw-r--r--ChangeLog2
-rw-r--r--doc/libslapt.3180
-rw-r--r--src/action.c130
-rw-r--r--src/action.h8
-rw-r--r--src/common.c8
-rw-r--r--src/common.h8
-rw-r--r--src/configuration.c36
-rw-r--r--src/configuration.h20
-rw-r--r--src/main.c118
-rw-r--r--src/main.h21
-rw-r--r--src/package.c372
-rw-r--r--src/package.h72
-rw-r--r--src/slaptcurl.c6
-rw-r--r--src/slaptcurl.h6
-rw-r--r--src/slaptgpgme.c4
-rw-r--r--src/slaptgpgme.h4
-rw-r--r--src/transaction.c124
-rw-r--r--src/transaction.h52
-rw-r--r--t/test.c2
-rw-r--r--t/test_common.c10
-rw-r--r--t/test_configuration.c22
-rw-r--r--t/test_curl.c10
-rw-r--r--t/test_packages.c72
-rw-r--r--t/test_transaction.c24
24 files changed, 656 insertions, 655 deletions
diff --git a/ChangeLog b/ChangeLog
index 994dfed..08e3901 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -205,7 +205,7 @@
packages and their dependencies so as to not try and remove uninstalled
packages
* translation updates
- * (libslapt) added slapt_write_rc_config (incorporating from gslapt)
+ * (libslapt) added slapt_config_t_write (incorporating from gslapt)
* (libslapt) added parsing of disabled sources (instead of ignoring what
gslapt creates).
* test updates
diff --git a/doc/libslapt.3 b/doc/libslapt.3
index 27a0667..f432015 100644
--- a/doc/libslapt.3
+++ b/doc/libslapt.3
@@ -6,10 +6,10 @@ libslapt \- slapt-get library
#define _GNU_SOURCE
#include <slapt.h>
-/* initialize slapt_rc_config */
-slapt_rc_config *slapt_init_config(void);
+/* initialize slapt_config_t */
+slapt_config_t *slapt_config_t_init(void);
/* parse config file for sources, excludes, and working_dir*/
-slapt_rc_config *config = slapt_read_rc_config("/etc/slapt-get/slapt-getrc");
+slapt_config_t *config = slapt_config_t_read("/etc/slapt-get/slapt-getrc");
/* get a list of installed packages */
slapt_vector_t *installed = slapt_get_installed_pkgs();
/* parse the package data, normally using config->working_dir */
@@ -18,10 +18,10 @@ slapt_vector_t *available = slapt_parse_packages_txt(data_f);
/* search for a package in a list via regex */
slapt_vector_t *results = slapt_search_pkg_list(installed,"[0-9]frg");
-slapt_free_pkg_list(results);
+slapt_pkg_t_free_list(results);
/* look for a specific package */
-slapt_pkg_info_t *pkg = slapt_get_exact_pkg(available,
+slapt_pkg_t *pkg = slapt_get_exact_pkg(available,
"slapt-get",
"0.9.10c-i386-1");
if (!slapt_is_excluded(config,pkg)) {
@@ -39,7 +39,7 @@ if (!slapt_is_excluded(config,pkg)) {
}
}
}
-slapt_free_pkg(pkg);
+slapt_pkg_t_free(pkg);
if (slapt_cmp_pkgs(pkg_a,pkg_b) = 0) {
fprintf(stderr,"%s is equal to %s\\n",pkg_a->version,pkg_b->version);
@@ -49,15 +49,15 @@ if (slapt_cmp_pkgs(pkg_a,pkg_b) = 0) {
fprintf(stderr,"%s is greater than %s\\n",pkg_a->version,pkg_b->version);
}
-slapt_free_pkg_list(available);
-slapt_free_pkg_list(installed);
-slapt_free_rc_config(config);
+slapt_pkg_t_free_list(available);
+slapt_pkg_t_free_list(installed);
+slapt_config_t_free(config);
.fi
.SH DESCRIPTION
-This is a short overview on how to use libslapt with your C programs.
+This is a short overview on how to use libslapt with your C programs.
.IP \fBCONFIGURATION\fP
.TP
-slapt-get stores the configuration information in a \fIslapt_rc_config\fP object. The configuration is parsed from the \fIslapt-getrc\fP which includes \fISOURCE\fP, \fIEXCLUDE\fP, and \fIWORKINGDIR\fP directives. Various runtime configuration options are also stored within the \fIslapt_rc_config\fP object.
+slapt-get stores the configuration information in a \fIslapt_config_t\fP object. The configuration is parsed from the \fIslapt-getrc\fP which includes \fISOURCE\fP, \fIEXCLUDE\fP, and \fIWORKINGDIR\fP directives. Various runtime configuration options are also stored within the \fIslapt_rc_config\fP object.
.nf
typedef struct {
@@ -79,25 +79,25 @@ slapt-get stores the configuration information in a \fIslapt_rc_config\fP object
bool remove_obsolete;
bool no_upgrade;
uint32_t retry;
- } slapt_rc_config;
+ } slapt_config_t;
.fi
.TP
-The \fIslapt_rc_config\fP is created with the \fIslapt_read_rc_config\fP() function by passing in the file location of the configuration to parse, or by calling \fIslapt_init_config\fP() to return an empty, initialized \fIslapt_rc_config\fP.
+The \fIslapt_config_t\fP is created with the \fIslapt_config_t_read\fP() function by passing in the file location of the configuration to parse, or by calling \fIslapt_config_t_init\fP() to return an empty, initialized \fIslapt_rc_config\fP.
.sp
-.B "slapt_rc_config *slapt_read_rc_config(const char *file_name);"
+.B "slapt_config_t *slapt_config_t_read(const char *file_name);"
.sp
-.B "slapt_rc_config *slapt_init_config(void);"
+.B "slapt_config_t *slapt_config_t_init(void);"
.sp
.TP
-and is freed by a call to the \fIslapt_free_rc_config\fP() function.
+and is freed by a call to the \fIslapt_config_t_free\fP() function.
.sp
-.B "void slapt_free_rc_config(slapt_rc_config *global_config);"
+.B "void slapt_config_t_free(slapt_config_t *global_config);"
.sp
.TP
-The slapt-getrc configuration can be written back out with \fIslapt_write_rc_config\fP.
+The slapt-getrc configuration can be written back out with \fIslapt_config_t_write\fP.
.sp
-.B "int slapt_write_rc_config(const slapt_rc_config *global_config, const char *location);"
+.B "int slapt_config_t_write(const slapt_config_t *global_config, const char *location);"
.sp
.TP
The progress callback is a function that is called while data is being downloaded. It is in the format of \fBint slapt_progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);\fP
@@ -112,18 +112,18 @@ Package sources are represented by the \fIslapt_source_t\fP type. They are crea
bool disabled;
} slapt_source_t;
.sp
-.B slapt_source_t *slapt_init_source(const char *s);
-.B void slapt_free_source(slapt_source_t *src);
+.B slapt_source_t *slapt_source_t_init(const char *s);
+.B void slapt_source_t_free(slapt_source_t *src);
.fi
.sp
.TP
-In order to initialize the slapt_rc_config->working_dir directory, \fIslapt_working_dir_init\fP() must be called. It is a fatal error to call \fIslapt_working_dir_init\fP() with a directory that the current process does not have privileges to read, write, and execute.
+In order to initialize the slapt_config_t->working_dir directory, \fIslapt_working_dir_init\fP() must be called. It is a fatal error to call \fIslapt_working_dir_init\fP() with a directory that the current process does not have privileges to read, write, and execute.
.sp
-.B "void slapt_working_dir_init(const slapt_rc_config *global_config);"
+.B "void slapt_working_dir_init(const slapt_config_t *global_config);"
.sp
.IP \fBPACKAGES\fP
.TP
-slapt-get stores packages within \fIslapt_pkg_info_t\fP objects.
+slapt-get stores packages within \fIslapt_pkg_t\fP objects.
.sp
.nf
typedef struct {
@@ -141,17 +141,17 @@ slapt-get stores packages within \fIslapt_pkg_info_t\fP objects.
uint32_t size_u;
uint32_t priority;
bool installed;
- } slapt_pkg_info_t;
+ } slapt_pkg_t;
.fi
.sp
.TP
-The \fIslapt_pkg_info_t\fP object is created and freed with \fIslapt_init_pkg\fP() and \fIslapt_free_pkg\fP(). A \fIslapt_pkg_info_t\fP can also be copied with \fIslapt_copy_pkg\fP().
+The \fIslapt_pkg_t\fP object is created and freed with \fIslapt_pkg_t_init\fP() and \fIslapt_pkg_t_free\fP(). A \fIslapt_pkg_t\fP can also be copied with \fIslapt_copy_pkg\fP().
.sp
.nf
-.B "__inline slapt_pkg_info_t *slapt_init_pkg(void);"
-.B "void slapt_free_pkg(slapt_pkg_info_t *pkg);"
-.B "slapt_pkg_info_t *slapt_copy_pkg(slapt_pkg_info_t *dst,"
-.B " slapt_pkg_info_t *src);"
+.B "slapt_pkg_t *slapt_pkg_t_init(void);"
+.B "void slapt_pkg_t_free(slapt_pkg_t *pkg);"
+.B "slapt_pkg_t *slapt_copy_pkg(slapt_pkg_t *dst,"
+.B " slapt_pkg_t *src);"
.fi
.sp
.TP
@@ -167,15 +167,15 @@ Package lists can be parsed from PACKAGES.TXT or similar formated files (such as
.fi
.sp
.TP
-Finding a specific package in a package list is done through one of the following functions. All return \fIslapt_pkg_info_t\fP, or NULL on error, except for \fIslapt_search_pkg_list\fP() which returns a list of packages as \fIslapt_vector_t\fP.
+Finding a specific package in a package list is done through one of the following functions. All return \fIslapt_pkg_t\fP, or NULL on error, except for \fIslapt_search_pkg_list\fP() which returns a list of packages as \fIslapt_vector_t\fP.
.sp
.nf
-.B "slapt_pkg_info_t *slapt_get_newest_pkg(slapt_vector_t *,"
+.B "slapt_pkg_t *slapt_get_newest_pkg(slapt_vector_t *,"
.B " const char *);"
-.B "slapt_pkg_info_t *slapt_get_exact_pkg(slapt_vector_t *list,"
+.B "slapt_pkg_t *slapt_get_exact_pkg(slapt_vector_t *list,"
.B " const char *name,"
.B " const char *version);"
-.B "slapt_pkg_info_t *slapt_get_pkg_by_details(slapt_vector_t *list,"
+.B "slapt_pkg_t *slapt_get_pkg_by_details(slapt_vector_t *list,"
.B " const char *name,"
.B " const char *version,"
.B " const char *location);"
@@ -187,10 +187,10 @@ Finding a specific package in a package list is done through one of the followin
Passing a package to \fIinstallpkg\fP, \fIupgradepkg\fP, and \fIremovepkg\fP is done through the following functions. All return 0 upon success, or non-zero on error.
.sp
.nf
-.B "int slapt_install_pkg(const slapt_rc_config *,slapt_pkg_info_t *);"
-.B "int slapt_upgrade_pkg(const slapt_rc_config *global_config,"
-.B " slapt_pkg_info_t *pkg);"
-.B "int slapt_remove_pkg(const slapt_rc_config *,slapt_pkg_info_t *);"
+.B "int slapt_install_pkg(const slapt_config_t *,slapt_pkg_t *);"
+.B "int slapt_upgrade_pkg(const slapt_config_t *global_config,"
+.B " slapt_pkg_t *pkg);"
+.B "int slapt_remove_pkg(const slapt_config_t *,slapt_pkg_t *);"
.fi
.sp
.TP
@@ -198,7 +198,7 @@ Comparing package versions is done with the \fIslapt_cmp_pkgs\fP functions. It
.sp
.nf
.B "int slapt_cmp_pkg_versions(const char *a, const char *b);"
-.B "int slapt_cmp_pkgs(slapt_pkg_info_t *a, slapt_pkg_info_t *b);"
+.B "int slapt_cmp_pkgs(slapt_pkg_t *a, slapt_pkg_t *b);"
.fi
.sp
.TP
@@ -215,10 +215,10 @@ The following functions deal with determining package dependencies and conflicts
\fIslapt_get_pkg_dependencies\fP() fills a \fIslapt_vector_t\fP of dependencies for the specified package. These dependencies are pulled from the available package list and the installed package lists. Missing and conflict errors are placed in \fIslapt_vector_t\fP. \fIdeps\fP, \fIconflict_err\fP, and \fImissing_err\fP are initialized if NULL. \fIslapt_get_pkg_dependencies\fP() returns 0 on success, or -1 on error.
.sp
.nf
-.B "int slapt_get_pkg_dependencies(const slapt_rc_config *global_config,
+.B "int slapt_get_pkg_dependencies(const slapt_config_t *global_config,
.B " slapt_vector_t *avail_pkgs,
.B " slapt_vector_t *installed_pkgs,
-.B " slapt_pkg_info_t *pkg,
+.B " slapt_pkg_t *pkg,
.B " slapt_vector_t *deps,
.B " slapt_vector_t *conflict_err,
.B " slapt_vector_t *missing_err);"
@@ -231,7 +231,7 @@ The following functions deal with determining package dependencies and conflicts
.B "slapt_vector_t *"
.B "slapt_get_pkg_conflicts(slapt_vector_t *avail_pkgs,
.B " slapt_vector_t *installed_pkgs,
-.B " slapt_pkg_info_t *pkg);"
+.B " slapt_pkg_t *pkg);"
.sp
.fi
.TP
@@ -239,12 +239,12 @@ The following functions deal with determining package dependencies and conflicts
.sp
.nf
.B "slapt_vector_t *"
-.B "slapt_is_required_by(const slapt_rc_config *global_config,
+.B "slapt_is_required_by(const slapt_config_t *global_config,
.B " slapt_vector_t *avail,
.B " slapt_vector_t *installed_pkgs,
.B " slapt_vector_t *pkgs_to_install,
.B " slapt_vector_t *pkgs_to_remove,
-.B " slapt_pkg_info_t *pkg);"
+.B " slapt_pkg_t *pkg);"
.sp
.fi
.TP
@@ -252,7 +252,7 @@ The following functions deal with determining package dependencies and conflicts
.sp
.nf
.B "slapt_vector_t *"
-.B " slapt_get_obsolete_pkgs ( const slapt_rc_config *global_config,"
+.B " slapt_get_obsolete_pkgs ( const slapt_config_t *global_config,"
.B " slapt_vector_t *avail_pkgs,"
.B " slapt_vector_t *installed_pkgs);"
.B "
@@ -262,43 +262,43 @@ The following functions deal with determining package dependencies and conflicts
\fIslapt_is_excluded\fP() returns 1 if package is present in the exclude list, 0 if not.
.sp
.nf
-.B "int slapt_is_excluded(const slapt_rc_config *,slapt_pkg_info_t *);"
+.B "int slapt_is_excluded(const slapt_config_t *,slapt_pkg_t *);"
.fi
.sp
.TP
\fIslapt_get_pkg_changelog\fP() returns the package changelog entry, if any. Otherwise returns NULL. Assumes already chdir'd to the working directory.
.sp
.nf
-.B "char *slapt_get_pkg_changelog(const slapt_pkg_info_t *pkg);"
+.B "char *slapt_get_pkg_changelog(const slapt_pkg_t *pkg);"
.fi
.sp
.TP
-\fIslapt_get_pkg_filelist\fP() returns a string representing all of the files installed by the package. This list is read from the package log file.
+\fIslapt_get_pkg_filelist\fP() returns a string representing all of the files installed by the package. This list is read from the package log file.
.sp
.nf
-.B "char *slapt_get_pkg_filelist(const slapt_pkg_info_t *pkg);"
+.B "char *slapt_get_pkg_filelist(const slapt_pkg_t *pkg);"
.fi
.sp
.TP
\fIslapt_stringify_pkg\fP() returns a string representation of the package.
.sp
.nf
-.B "char *slapt_stringify_pkg(const slapt_pkg_info_t *pkg);"
+.B "char *slapt_stringify_pkg(const slapt_pkg_t *pkg);"
.fi
.sp
.TP
-\fIslapt_gen_package_log_dir_name\fP() returns a string location of the package log directory, accounting for the value of the ROOT environment variable, if set.
+\fIslapt_gen_package_log_dir_name\fP() returns a string location of the package log directory, accounting for the value of the ROOT environment variable, if set.
.sp
.nf
.B "char *slapt_gen_package_log_dir_name(void);"
.fi
.sp
.TP
-The \fIworking_dir\fP, defined within the \fIslapt_rc_config\fP object, caches the downloaded packages. At various times it becomes necessary to purge the package cache. \fIslapt_clean_pkg_dir\fP() unlinks all packages within the specified directory location. \fIslapt_purge_old_cached_pkgs\fP() unlinks only packages that are not present in the current sources and thus are no longer downloadable.
+The \fIworking_dir\fP, defined within the \fIslapt_config_t\fP object, caches the downloaded packages. At various times it becomes necessary to purge the package cache. \fIslapt_clean_pkg_dir\fP() unlinks all packages within the specified directory location. \fIslapt_purge_old_cached_pkgs\fP() unlinks only packages that are not present in the current sources and thus are no longer downloadable.
.sp
.nf
.B "void slapt_clean_pkg_dir(const char *dir_name);"
-.B "void slapt_purge_old_cached_pkgs(const slapt_rc_config *global_config,"
+.B "void slapt_purge_old_cached_pkgs(const slapt_config_t *global_config,"
.B " const char *dir_name,"
.B " slapt_vector_t *avail_pkgs);"
.fi
@@ -316,15 +316,15 @@ Downloading packages and the package data from various sources is handled with t
.sp
.nf
.B "int slapt_download_data(FILE *fh, const char *url, size_t bytes, long *filetime,"
-.B " const slapt_rc_config *global_config);"
-.B "int slapt_update_pkg_cache(const slapt_rc_config *global_config);"
-.B "const char *slapt_download_pkg(const slapt_rc_config *global_config,"
-.B " slapt_pkg_info_t *pkg);"
-.B "slapt_code_t slapt_verify_downloaded_pkg(const slapt_rc_config *global_config,"
-.B " slapt_pkg_info_t *pkg);"
+.B " const slapt_config_t *global_config);"
+.B "int slapt_update_pkg_cache(const slapt_config_t *global_config);"
+.B "const char *slapt_download_pkg(const slapt_config_t *global_config,"
+.B " slapt_pkg_t *pkg);"
+.B "slapt_code_t slapt_verify_downloaded_pkg(const slapt_config_t *global_config,"
+.B " slapt_pkg_t *pkg);"
.sp
.B "const char *slapt_get_mirror_data_from_source(FILE *fh,"
-.B " const slapt_rc_config *global_config,"
+.B " const slapt_config_t *global_config,"
.B " const char *base_url,"
.B " const char *filename);"
.B "char *slapt_head_request(const char *url);"
@@ -339,14 +339,14 @@ The following functions download the PACKAGES.TXT, the patches/PACKAGES.TXT, CHE
.sp
.nf
.B "slapt_vector_t *"
-.B "slapt_get_pkg_source_packages (const slapt_rc_config *global_config,"
+.B "slapt_get_pkg_source_packages (const slapt_config_t *global_config,"
.B " const char *url, bool *compressed);"
.B "slapt_vector_t *"
-.B "slapt_get_pkg_source_patches (const slapt_rc_config *global_config,"
+.B "slapt_get_pkg_source_patches (const slapt_config_t *global_config,"
.B " const char *url, bool *compressed);"
-.B "FILE *slapt_get_pkg_source_checksums (const slapt_rc_config *global_config,"
+.B "FILE *slapt_get_pkg_source_checksums (const slapt_config_t *global_config,"
.B " const char *url, bool *compressed);"
-.B "int slapt_get_pkg_source_changelog (const slapt_rc_config *global_config,"
+.B "int slapt_get_pkg_source_changelog (const slapt_config_t *global_config,"
.B " const char *url, bool *compressed);"
.fi
.sp
@@ -374,13 +374,13 @@ Adding, removing, and upgrading packages can be wrapped in a \fIslapt_transactio
};
.sp
typedef struct {
- union { slapt_pkg_info_t *i; slapt_pkg_upgrade_t *u; } pkg;
- uint32_t type; /* this is enum slapt_action */
+ union { slapt_pkg_t *i; slapt_pkg_upgrade_t *u; } pkg;
+ enum slapt_action type;
} slapt_queue_i;
.sp
typedef struct {
- slapt_pkg_info_t *installed;
- slapt_pkg_info_t *upgrade;
+ slapt_pkg_t *installed;
+ slapt_pkg_t *upgrade;
bool reinstall;
} slapt_pkg_upgrade_t;
.sp
@@ -397,45 +397,45 @@ Adding, removing, and upgrading packages can be wrapped in a \fIslapt_transactio
.sp
.B "slapt_transaction_t *slapt_init_transaction(void);"
.B "void slapt_free_transaction(slapt_transaction_t *);"
-.B "int slapt_handle_transaction(const slapt_rc_config *,slapt_transaction_t *);"
+.B "int slapt_handle_transaction(const slapt_config_t *,slapt_transaction_t *);"
.sp
.B "void slapt_add_install_to_transaction(slapt_transaction_t *,"
-.B " slapt_pkg_info_t *pkg);"
+.B " slapt_pkg_t *pkg);"
.sp
.B "void slapt_add_remove_to_transaction(slapt_transaction_t *,"
-.B " slapt_pkg_info_t *pkg);"
+.B " slapt_pkg_t *pkg);"
.sp
.B "void slapt_add_upgrade_to_transaction(slapt_transaction_t *,"
-.B " slapt_pkg_info_t *installed_pkg,"
-.B " slapt_pkg_info_t *upgrade_pkg);"
+.B " slapt_pkg_t *installed_pkg,"
+.B " slapt_pkg_t *upgrade_pkg);"
.sp
.B "void slapt_add_reinstall_to_transaction(slapt_transaction_t *,"
-.B " slapt_pkg_info_t *installed_pkg,"
-.B " slapt_pkg_info_t *upgrade_pkg);"
+.B " slapt_pkg_t *installed_pkg,"
+.B " slapt_pkg_t *upgrade_pkg);"
.sp
.B "void slapt_add_exclude_to_transaction(slapt_transaction_t *,"
-.B " slapt_pkg_info_t *pkg);"
+.B " slapt_pkg_t *pkg);"
.sp
.B "slapt_transaction_t *slapt_remove_from_transaction(slapt_transaction_t *tran,"
-.B " slapt_pkg_info_t *pkg);"
+.B " slapt_pkg_t *pkg);"
.sp
.B "int slapt_search_transaction(slapt_transaction_t *,char *pkg_name);"
.B "int slapt_search_transaction_by_pkg(slapt_transaction_t *tran,"
-.B " slapt_pkg_info_t *pkg);"
+.B " slapt_pkg_t *pkg);"
.sp
.B "int slapt_search_upgrade_transaction(slapt_transaction_t *tran,"
-.B " slapt_pkg_info_t *pkg);"
+.B " slapt_pkg_t *pkg);"
.sp
-.B "int slapt_add_deps_to_trans(const slapt_rc_config *global_config,"
+.B "int slapt_add_deps_to_trans(const slapt_config_t *global_config,"
.B " slapt_transaction_t *tran,"
.B " slapt_vector_t *avail_pkgs,"
.B " slapt_vector_t *installed_pkgs,"
-.B " slapt_pkg_info_t *pkg);"
+.B " slapt_pkg_t *pkg);"
.sp
-.B "slapt_pkg_info_t *slapt_is_conflicted(slapt_transaction_t *tran,"
+.B "slapt_pkg_t *slapt_is_conflicted(slapt_transaction_t *tran,"
.B " slapt_vector_t *avail_pkgs,"
.B " slapt_vector_t *installed_pkgs,"
-.B " slapt_pkg_info_t *pkg);"
+.B " slapt_pkg_t *pkg);"
.sp
.B "void slapt_generate_suggestions(slapt_transaction_t *tran);"
.fi
@@ -447,7 +447,7 @@ Functionality for GPG verification of package sources.
.TP
Retrieve the signature file for CHECKSUMS.md5 (or the signature for CHECKSUMS.md5.gz). Sets compressed depending on which was found.
.nf
-.B "FILE *slapt_get_pkg_source_checksums_signature (const slapt_rc_config *global_config,"
+.B "FILE *slapt_get_pkg_source_checksums_signature (const slapt_config_t *global_config,"
.B " const char *url,"
.B " bool *compressed);"
.fi
@@ -455,7 +455,7 @@ Retrieve the signature file for CHECKSUMS.md5 (or the signature for CHECKSUMS.md
.TP
Retrieve the GPG-KEY file from the package source, if available. Returns NULL if not found.
.nf
-.B "FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config,"
+.B "FILE *slapt_get_pkg_source_gpg_key(const slapt_config_t *global_config,"
.B " const char *url,"
.B " bool *compressed);"
.fi
@@ -485,16 +485,16 @@ Miscellaneous functionality within libslapt.
} slapt_regex_t;
.sp
.B "FILE *slapt_open_file(const char *file_name,const char *mode);"
-.B "slapt_regex_t *slapt_init_regex(const char *regex_string);"
-.B "void slapt_execute_regex(slapt_regex_t *regex_t,const char *string);"
-.B "void slapt_free_regex(slapt_regex_t *regex_t);"
+.B "slapt_regex_t *slapt_regex_t_init(const char *regex_string);"
+.B "void slapt_regex_t_execute(slapt_regex_t *regex_t,const char *string);"
+.B "void slapt_regex_t_free(slapt_regex_t *regex_t);"
.B "void slapt_create_dir_structure(const char *dir_name);"
.B "void slapt_gen_md5_sum_of_file(FILE *f,char *result_sum);"
.B "int slapt_ask_yes_no(const char *format, ...);"
.B "char *slapt_str_replace_chr(const char *string,const char find,"
.B " const char replace);"
-.B "__inline void *slapt_malloc(size_t s);"
-.B "__inline void *slapt_calloc(size_t n,size_t s);"
+.B "void *slapt_malloc(size_t s);"
+.B "void *slapt_calloc(size_t n,size_t s);"
.fi
.sp
.nf
diff --git a/src/action.c b/src/action.c
index 4786227..542a1e9 100644
--- a/src/action.c
+++ b/src/action.c
@@ -21,7 +21,7 @@
static int cmp_pkg_arch(const char *a, const char *b);
/* install pkg */
-void slapt_pkg_action_install(const slapt_rc_config *global_config, const slapt_vector_t *action_args)
+void slapt_pkg_action_install(const slapt_config_t *global_config, const slapt_vector_t *action_args)
{
slapt_transaction_t *tran = NULL;
slapt_vector_t *installed_pkgs = NULL;
@@ -39,23 +39,23 @@ void slapt_pkg_action_install(const slapt_rc_config *global_config, const slapt_
tran = slapt_init_transaction();
- if ((pkg_regex = slapt_init_regex(SLAPT_PKG_LOG_PATTERN)) == NULL) {
+ if ((pkg_regex = slapt_regex_t_init(SLAPT_PKG_LOG_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
slapt_vector_t_foreach (char *, arg, action_args) {
- slapt_pkg_info_t *pkg = NULL;
- slapt_pkg_info_t *installed_pkg = NULL;
+ slapt_pkg_t *pkg = NULL;
+ slapt_pkg_t *installed_pkg = NULL;
/* Use regex to see if they specified a particular version */
- slapt_execute_regex(pkg_regex, arg);
+ slapt_regex_t_execute(pkg_regex, arg);
/* If so, parse it out and try to get that version only */
if (pkg_regex->reg_return == 0) {
char *pkg_name, *pkg_version;
- pkg_name = slapt_regex_extract_match(pkg_regex, arg, 1);
- pkg_version = slapt_regex_extract_match(pkg_regex, arg, 2);
+ pkg_name = slapt_regex_t_extract_match(pkg_regex, arg, 1);
+ pkg_version = slapt_regex_t_extract_match(pkg_regex, arg, 2);
pkg = slapt_get_exact_pkg(avail_pkgs, pkg_name, pkg_version);
free(pkg_name);
@@ -85,10 +85,10 @@ void slapt_pkg_action_install(const slapt_rc_config *global_config, const slapt_
/* if there are conflicts, we schedule the conflicts for removal */
if (conflicts->size && !global_config->ignore_dep) {
- slapt_vector_t_foreach (slapt_pkg_info_t *, conflict, conflicts) {
+ slapt_vector_t_foreach (slapt_pkg_t *, conflict, conflicts) {
/* make sure to remove the conflict's dependencies as well */
slapt_vector_t *conflict_deps = slapt_is_required_by(global_config, avail_pkgs, installed_pkgs, tran->install_pkgs, tran->remove_pkgs, conflict);
- slapt_vector_t_foreach (slapt_pkg_info_t *, conflict_dep, conflict_deps) {
+ slapt_vector_t_foreach (slapt_pkg_t *, conflict_dep, conflict_deps) {
if (slapt_get_exact_pkg(installed_pkgs, conflict_dep->name, conflict_dep->version) != NULL) {
slapt_add_remove_to_transaction(tran, conflict_dep);
}
@@ -112,10 +112,10 @@ void slapt_pkg_action_install(const slapt_rc_config *global_config, const slapt_
if (slapt_add_deps_to_trans(global_config, tran, avail_pkgs, installed_pkgs, pkg) == 0) {
slapt_vector_t *conflicts = slapt_is_conflicted(tran, avail_pkgs, installed_pkgs, pkg);
if (conflicts->size && !global_config->ignore_dep) {
- slapt_vector_t_foreach (slapt_pkg_info_t *, conflict, conflicts) {
+ slapt_vector_t_foreach (slapt_pkg_t *, conflict, conflicts) {
/* make sure to remove the conflict's dependencies as well */
slapt_vector_t *conflict_deps = slapt_is_required_by(global_config, avail_pkgs, installed_pkgs, tran->install_pkgs, tran->remove_pkgs, conflict);
- slapt_vector_t_foreach (slapt_pkg_info_t *, conflict_dep, conflict_deps) {
+ slapt_vector_t_foreach (slapt_pkg_t *, conflict_dep, conflict_deps) {
if (slapt_get_exact_pkg(installed_pkgs, conflict_dep->name, conflict_dep->version) != NULL) {
slapt_add_remove_to_transaction(tran, conflict_dep);
}
@@ -147,7 +147,7 @@ void slapt_pkg_action_install(const slapt_rc_config *global_config, const slapt_
slapt_vector_t_free(installed_pkgs);
slapt_vector_t_free(avail_pkgs);
- slapt_free_regex(pkg_regex);
+ slapt_regex_t_free(pkg_regex);
if (slapt_handle_transaction(global_config, tran) != 0) {
exit(EXIT_FAILURE);
@@ -166,8 +166,8 @@ void slapt_pkg_action_list(const int show)
pkgs = slapt_get_available_pkgs();
installed_pkgs = slapt_get_installed_pkgs();
- if (show == LIST || show == AVAILABLE) {
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, pkgs) {
+ if (show == SLAPT_ACTION_LIST || show == SLAPT_ACTION_AVAILABLE) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, pkgs) {
bool installed = false;
char *short_description = slapt_gen_short_pkg_description(pkg);
@@ -185,11 +185,11 @@ void slapt_pkg_action_list(const int show)
free(short_description);
}
}
- if (show == LIST || show == INSTALLED) {
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, installed_pkgs) {
+ if (show == SLAPT_ACTION_LIST || show == SLAPT_ACTION_INSTALLED) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, installed_pkgs) {
char *short_description = NULL;
- if (show == LIST) {
+ if (show == SLAPT_ACTION_LIST) {
if (slapt_get_exact_pkg(pkgs, pkg->name, pkg->version) != NULL) {
continue;
}
@@ -211,7 +211,7 @@ void slapt_pkg_action_list(const int show)
}
/* remove/uninstall pkg */
-void slapt_pkg_action_remove(const slapt_rc_config *global_config, const slapt_vector_t *action_args)
+void slapt_pkg_action_remove(const slapt_config_t *global_config, const slapt_vector_t *action_args)
{
slapt_vector_t *installed_pkgs = NULL;
slapt_vector_t *avail_pkgs = NULL;
@@ -224,23 +224,23 @@ void slapt_pkg_action_remove(const slapt_rc_config *global_config, const slapt_v
printf(gettext("Done\n"));
tran = slapt_init_transaction();
- if ((pkg_regex = slapt_init_regex(SLAPT_PKG_LOG_PATTERN)) == NULL) {
+ if ((pkg_regex = slapt_regex_t_init(SLAPT_PKG_LOG_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
slapt_vector_t_foreach (char *, arg, action_args) {
slapt_vector_t *deps = NULL;
- slapt_pkg_info_t *pkg = NULL;
+ slapt_pkg_t *pkg = NULL;
/* Use regex to see if they specified a particular version */
- slapt_execute_regex(pkg_regex, arg);
+ slapt_regex_t_execute(pkg_regex, arg);
/* If so, parse it out and try to get that version only */
if (pkg_regex->reg_return == 0) {
char *pkg_name, *pkg_version;
- pkg_name = slapt_regex_extract_match(pkg_regex, arg, 1);
- pkg_version = slapt_regex_extract_match(pkg_regex, arg, 2);
+ pkg_name = slapt_regex_t_extract_match(pkg_regex, arg, 1);
+ pkg_version = slapt_regex_t_extract_match(pkg_regex, arg, 2);
pkg = slapt_get_exact_pkg(installed_pkgs, pkg_name, pkg_version);
free(pkg_name);
@@ -260,7 +260,7 @@ void slapt_pkg_action_remove(const slapt_rc_config *global_config, const slapt_v
deps = slapt_is_required_by(global_config, avail_pkgs, installed_pkgs, tran->install_pkgs, tran->remove_pkgs, pkg);
- slapt_vector_t_foreach (slapt_pkg_info_t *, dep, deps) {
+ slapt_vector_t_foreach (slapt_pkg_t *, dep, deps) {
if (slapt_get_exact_pkg(installed_pkgs, dep->name, dep->version) != NULL) {
slapt_add_remove_to_transaction(tran, dep);
}
@@ -274,7 +274,7 @@ void slapt_pkg_action_remove(const slapt_rc_config *global_config, const slapt_v
if (global_config->remove_obsolete) {
slapt_vector_t *obsolete = slapt_get_obsolete_pkgs(global_config, avail_pkgs, installed_pkgs);
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, obsolete) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, obsolete) {
if (slapt_is_excluded(global_config, pkg)) {
slapt_add_exclude_to_transaction(tran, pkg);
} else {
@@ -287,7 +287,7 @@ void slapt_pkg_action_remove(const slapt_rc_config *global_config, const slapt_v
slapt_vector_t_free(installed_pkgs);
slapt_vector_t_free(avail_pkgs);
- slapt_free_regex(pkg_regex);
+ slapt_regex_t_free(pkg_regex);
if (slapt_handle_transaction(global_config, tran) != 0) {
exit(EXIT_FAILURE);
@@ -310,7 +310,7 @@ void slapt_pkg_action_search(const char *pattern)
matches = slapt_search_pkg_list(pkgs, pattern);
i_matches = slapt_search_pkg_list(installed_pkgs, pattern);
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, matches) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, matches) {
char *short_description = slapt_gen_short_pkg_description(pkg);
printf("%s-%s [inst=%s]: %s\n",
@@ -323,7 +323,7 @@ void slapt_pkg_action_search(const char *pattern)
free(short_description);
}
- slapt_vector_t_foreach (slapt_pkg_info_t *, installed_pkg, i_matches) {
+ slapt_vector_t_foreach (slapt_pkg_t *, installed_pkg, i_matches) {
char *short_description = NULL;
if (slapt_get_exact_pkg(matches, installed_pkg->name, installed_pkg->version) != NULL) {
@@ -353,7 +353,7 @@ void slapt_pkg_action_show(const char *pkg_name)
slapt_vector_t *installed_pkgs = NULL;
slapt_regex_t *pkg_regex = NULL;
bool installed = false;
- slapt_pkg_info_t *pkg = NULL;
+ slapt_pkg_t *pkg = NULL;
avail_pkgs = slapt_get_available_pkgs();
installed_pkgs = slapt_get_installed_pkgs();
@@ -361,18 +361,18 @@ void slapt_pkg_action_show(const char *pkg_name)
if (avail_pkgs == NULL || installed_pkgs == NULL)
exit(EXIT_FAILURE);
- if ((pkg_regex = slapt_init_regex(SLAPT_PKG_LOG_PATTERN)) == NULL)
+ if ((pkg_regex = slapt_regex_t_init(SLAPT_PKG_LOG_PATTERN)) == NULL)
exit(EXIT_FAILURE);
/* Use regex to see if they specified a particular version */
- slapt_execute_regex(pkg_regex, pkg_name);
+ slapt_regex_t_execute(pkg_regex, pkg_name);
/* If so, parse it out and try to get that version only */
if (pkg_regex->reg_return == 0) {
char *p_name, *p_version;
- p_name = slapt_regex_extract_match(pkg_regex, pkg_name, 1);
- p_version = slapt_regex_extract_match(pkg_regex, pkg_name, 2);
+ p_name = slapt_regex_t_extract_match(pkg_regex, pkg_name, 1);
+ p_version = slapt_regex_t_extract_match(pkg_regex, pkg_name, 2);
pkg = slapt_get_exact_pkg(avail_pkgs, p_name, p_version);
@@ -384,7 +384,7 @@ void slapt_pkg_action_show(const char *pkg_name)
}
if (pkg == NULL) {
- slapt_pkg_info_t *installed_pkg = slapt_get_newest_pkg(installed_pkgs, pkg_name);
+ slapt_pkg_t *installed_pkg = slapt_get_newest_pkg(installed_pkgs, pkg_name);
pkg = slapt_get_newest_pkg(avail_pkgs, pkg_name);
if (pkg == NULL)
pkg = installed_pkg;
@@ -432,11 +432,11 @@ void slapt_pkg_action_show(const char *pkg_name)
slapt_vector_t_free(avail_pkgs);
slapt_vector_t_free(installed_pkgs);
- slapt_free_regex(pkg_regex);
+ slapt_regex_t_free(pkg_regex);
}
/* upgrade all installed pkgs with available updates */
-void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
+void slapt_pkg_action_upgrade_all(const slapt_config_t *global_config)
{
slapt_vector_t *installed_pkgs = NULL;
slapt_vector_t *avail_pkgs = NULL;
@@ -458,13 +458,13 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
if (global_config->dist_upgrade) {
char *essential[] = {"aaa_base", "pkgtools", "glibc-solibs", "glibc", "aaa_elflibs", "xz", "sed", "tar", "gzip", NULL};
int epi = 0;
- slapt_pkg_info_t *newest_slaptget = NULL;
+ slapt_pkg_t *newest_slaptget = NULL;
slapt_vector_t *matches = slapt_search_pkg_list(avail_pkgs, SLAPT_SLACK_BASE_SET_REGEX);
/* make sure the essential packages are installed/upgraded first */
while (essential[epi] != NULL) {
- slapt_pkg_info_t *inst_pkg = NULL;
- slapt_pkg_info_t *avail_pkg = NULL;
+ slapt_pkg_t *inst_pkg = NULL;
+ slapt_pkg_t *avail_pkg = NULL;
inst_pkg = slapt_get_newest_pkg(installed_pkgs, essential[epi]);
avail_pkg = slapt_get_newest_pkg(avail_pkgs, essential[epi]);
@@ -483,10 +483,10 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
}
/* loop through SLAPT_SLACK_BASE_SET_REGEX packages */
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, matches) {
- slapt_pkg_info_t *installed_pkg = NULL;
- slapt_pkg_info_t *newer_avail_pkg = NULL;
- slapt_pkg_info_t *slapt_upgrade_pkg = NULL;
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, matches) {
+ slapt_pkg_t *installed_pkg = NULL;
+ slapt_pkg_t *newer_avail_pkg = NULL;
+ slapt_pkg_t *slapt_upgrade_pkg = NULL;
installed_pkg = slapt_get_newest_pkg(installed_pkgs, pkg->name);
newer_avail_pkg = slapt_get_newest_pkg(avail_pkgs, pkg->name);
@@ -545,7 +545,7 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
if (global_config->remove_obsolete) {
slapt_vector_t *obsolete = slapt_get_obsolete_pkgs(global_config, avail_pkgs, installed_pkgs);
- slapt_vector_t_foreach (slapt_pkg_info_t *, obsolete_pkg, obsolete) {
+ slapt_vector_t_foreach (slapt_pkg_t *, obsolete_pkg, obsolete) {
if (slapt_is_excluded(global_config, obsolete_pkg)) {
slapt_add_exclude_to_transaction(tran, obsolete_pkg);
} else {
@@ -560,16 +560,16 @@ void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config)
/* insurance so that all of slapt-get's requirements are also installed */
newest_slaptget = slapt_get_newest_pkg(avail_pkgs, "slapt-get");
if (newest_slaptget != NULL) {
- slapt_pkg_info_t *installed_slaptget = slapt_get_newest_pkg(installed_pkgs, "slapt-get");
+ slapt_pkg_t *installed_slaptget = slapt_get_newest_pkg(installed_pkgs, "slapt-get");
slapt_add_deps_to_trans(global_config, tran, avail_pkgs, installed_pkgs, newest_slaptget);
if (installed_slaptget != NULL) /* should never be null */
slapt_add_reinstall_to_transaction(tran, installed_slaptget, newest_slaptget);
}
}
- slapt_vector_t_foreach (slapt_pkg_info_t *, installed_pkg, installed_pkgs) {
- slapt_pkg_info_t *update_pkg = NULL;
- slapt_pkg_info_t *newer_installed_pkg = NULL;
+ slapt_vector_t_foreach (slapt_pkg_t *, installed_pkg, installed_pkgs) {
+ slapt_pkg_t *update_pkg = NULL;
+ slapt_pkg_t *newer_installed_pkg = NULL;
/* we need to see if there is another installed package that is newer than this one */
if ((newer_installed_pkg = slapt_get_newest_pkg(installed_pkgs, installed_pkg->name)) != NULL) {
@@ -631,25 +631,25 @@ static int cmp_pkg_arch(const char *a, const char *b)
int r = 0;
slapt_regex_t *a_arch_regex = NULL, *b_arch_regex = NULL;
- if ((a_arch_regex = slapt_init_regex(SLAPT_PKG_VER)) == NULL) {
+ if ((a_arch_regex = slapt_regex_t_init(SLAPT_PKG_VER)) == NULL) {
exit(EXIT_FAILURE);
}
- if ((b_arch_regex = slapt_init_regex(SLAPT_PKG_VER)) == NULL) {
+ if ((b_arch_regex = slapt_regex_t_init(SLAPT_PKG_VER)) == NULL) {
exit(EXIT_FAILURE);
}
- slapt_execute_regex(a_arch_regex, a);
- slapt_execute_regex(b_arch_regex, b);
+ slapt_regex_t_execute(a_arch_regex, a);
+ slapt_regex_t_execute(b_arch_regex, b);
if (a_arch_regex->reg_return != 0 || b_arch_regex->reg_return != 0) {
- slapt_free_regex(a_arch_regex);
- slapt_free_regex(b_arch_regex);
+ slapt_regex_t_free(a_arch_regex);
+ slapt_regex_t_free(b_arch_regex);
return strcmp(a, b);
} else {
- char *a_arch = slapt_regex_extract_match(a_arch_regex, a, 2);
- char *b_arch = slapt_regex_extract_match(a_arch_regex, b, 2);
+ char *a_arch = slapt_regex_t_extract_match(a_arch_regex, a, 2);
+ char *b_arch = slapt_regex_t_extract_match(a_arch_regex, b, 2);
r = strcmp(a_arch, b_arch);
@@ -657,14 +657,14 @@ static int cmp_pkg_arch(const char *a, const char *b)
free(b_arch);
}
- slapt_free_regex(a_arch_regex);
- slapt_free_regex(b_arch_regex);
+ slapt_regex_t_free(a_arch_regex);
+ slapt_regex_t_free(b_arch_regex);
return r;
}
#ifdef SLAPT_HAS_GPGME
-void slapt_pkg_action_add_keys(const slapt_rc_config *global_config)
+void slapt_pkg_action_add_keys(const slapt_config_t *global_config)
{
int rc = 0;
bool compressed = false;
@@ -698,25 +698,25 @@ void slapt_pkg_action_filelist(const char *pkg_name)
{
slapt_regex_t *pkg_regex = NULL;
slapt_vector_t *installed_pkgs = NULL;
- slapt_pkg_info_t *pkg = NULL;
+ slapt_pkg_t *pkg = NULL;
char *filelist = NULL;
installed_pkgs = slapt_get_installed_pkgs();
if (installed_pkgs == NULL)
exit(EXIT_FAILURE);
- if ((pkg_regex = slapt_init_regex(SLAPT_PKG_LOG_PATTERN)) == NULL)
+ if ((pkg_regex = slapt_regex_t_init(SLAPT_PKG_LOG_PATTERN)) == NULL)
exit(EXIT_FAILURE);
/* Use regex to see if they specified a particular version */
- slapt_execute_regex(pkg_regex, pkg_name);
+ slapt_regex_t_execute(pkg_regex, pkg_name);
/* If so, parse it out and try to get that version only */
if (pkg_regex->reg_return == 0) {
char *p_name, *p_version;
- p_name = slapt_regex_extract_match(pkg_regex, pkg_name, 1);
- p_version = slapt_regex_extract_match(pkg_regex, pkg_name, 2);
+ p_name = slapt_regex_t_extract_match(pkg_regex, pkg_name, 1);
+ p_version = slapt_regex_t_extract_match(pkg_regex, pkg_name, 2);
pkg = slapt_get_exact_pkg(installed_pkgs, p_name, p_version);
@@ -737,6 +737,6 @@ void slapt_pkg_action_filelist(const char *pkg_name)
printf("%s\n", filelist);
free(filelist);
- slapt_free_regex(pkg_regex);
+ slapt_regex_t_free(pkg_regex);
slapt_vector_t_free(installed_pkgs);
}
diff --git a/src/action.h b/src/action.h
index 9e24e49..d67bfd4 100644
--- a/src/action.h
+++ b/src/action.h
@@ -16,15 +16,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-void slapt_pkg_action_install(const slapt_rc_config *global_config, const slapt_vector_t *action_args);
+void slapt_pkg_action_install(const slapt_config_t *global_config, const slapt_vector_t *action_args);
void slapt_pkg_action_list(const int show);
-void slapt_pkg_action_remove(const slapt_rc_config *global_config, const slapt_vector_t *action_args);
+void slapt_pkg_action_remove(const slapt_config_t *global_config, const slapt_vector_t *action_args);
void slapt_pkg_action_search(const char *pattern);
void slapt_pkg_action_show(const char *pkg_name);
-void slapt_pkg_action_upgrade_all(const slapt_rc_config *global_config);
+void slapt_pkg_action_upgrade_all(const slapt_config_t *global_config);
#ifdef SLAPT_HAS_GPGME
-void slapt_pkg_action_add_keys(const slapt_rc_config *global_config);
+void slapt_pkg_action_add_keys(const slapt_config_t *global_config);
#endif
void slapt_pkg_action_filelist(const char *pkg_name);
diff --git a/src/common.c b/src/common.c
index ceb5c17..9eb6dab 100644
--- a/src/common.c
+++ b/src/common.c
@@ -33,7 +33,7 @@ FILE *slapt_open_file(const char *file_name, const char *mode)
}
/* initialize regex structure and compile the regular expression */
-slapt_regex_t *slapt_init_regex(const char *regex_string)
+slapt_regex_t *slapt_regex_t_init(const char *regex_string)
{
slapt_regex_t *r;
@@ -64,12 +64,12 @@ slapt_regex_t *slapt_init_regex(const char *regex_string)
}
/* execute the regular expression and set the return code in the passed in structure */
-void slapt_execute_regex(slapt_regex_t *r, const char *string)
+void slapt_regex_t_execute(slapt_regex_t *r, const char *string)
{
r->reg_return = regexec(&r->regex, string, r->nmatch, r->pmatch, 0);
}
-char *slapt_regex_extract_match(const slapt_regex_t *r, const char *src, const int i)
+char *slapt_regex_t_extract_match(const slapt_regex_t *r, const char *src, const int i)
{
regmatch_t m = r->pmatch[i];
char *str = NULL;
@@ -86,7 +86,7 @@ char *slapt_regex_extract_match(const slapt_regex_t *r, const char *src, const i
return str;
}
-void slapt_free_regex(slapt_regex_t *r)
+void slapt_regex_t_free(slapt_regex_t *r)
{
regfree(&r->regex);
free(r);
diff --git a/src/common.h b/src/common.h
index 5080346..38f14fe 100644
--- a/src/common.h
+++ b/src/common.h
@@ -89,11 +89,11 @@ slapt_vector_t *slapt_vector_t_search(slapt_vector_t *, slapt_vector_t_cmp, void
for (uint32_t item##_counter = 0; (item##_counter < list->size) && (item = list->items[item##_counter]); item##_counter++)
FILE *slapt_open_file(const char *file_name, const char *mode);
-slapt_regex_t *slapt_init_regex(const char *regex_string);
-void slapt_execute_regex(slapt_regex_t *regex_t, const char *string);
+slapt_regex_t *slapt_regex_t_init(const char *regex_string);
+void slapt_regex_t_execute(slapt_regex_t *regex_t, const char *string);
/* extract the string from the match, starts with 1 (not 0) */
-char *slapt_regex_extract_match(const slapt_regex_t *r, const char *src, const int i);
-void slapt_free_regex(slapt_regex_t *regex_t);
+char *slapt_regex_t_extract_match(const slapt_regex_t *r, const char *src, const int i);
+void slapt_regex_t_free(slapt_regex_t *regex_t);
void slapt_create_dir_structure(const char *dir_name);
/* generate an md5sum of filehandle */
void slapt_gen_md5_sum_of_file(FILE *f, char *result_sum);
diff --git a/src/configuration.c b/src/configuration.c
index 738ed61..7b13435 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -20,9 +20,9 @@
/* parse the exclude list */
static slapt_vector_t *parse_exclude(char *line);
-slapt_rc_config *slapt_init_config(void)
+slapt_config_t *slapt_config_t_init(void)
{
- slapt_rc_config *global_config = slapt_malloc(sizeof *global_config);
+ slapt_config_t *global_config = slapt_malloc(sizeof *global_config);
global_config->download_only = false;
global_config->simulate = false;
@@ -43,7 +43,7 @@ slapt_rc_config *slapt_init_config(void)
global_config->progress_cb = NULL;
global_config->gpgme_allow_unauth = false; /* even without GPGME */
- global_config->sources = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_source);
+ global_config->sources = slapt_vector_t_init((slapt_vector_t_free_function)slapt_source_t_free);
global_config->exclude_list = slapt_vector_t_init(free);
global_config->retry = 1;
@@ -51,19 +51,19 @@ slapt_rc_config *slapt_init_config(void)
return global_config;
}
-slapt_rc_config *slapt_read_rc_config(const char *file_name)
+slapt_config_t *slapt_config_t_read(const char *file_name)
{
FILE *rc = NULL;
char *getline_buffer = NULL;
size_t gb_length = 0;
ssize_t g_size;
- slapt_rc_config *global_config = NULL;
+ slapt_config_t *global_config = NULL;
rc = slapt_open_file(file_name, "r");
if (rc == NULL)
return NULL;
- global_config = slapt_init_config();
+ global_config = slapt_config_t_init();
while ((g_size = getline(&getline_buffer, &gb_length, rc)) != EOF) {
char *token_ptr = NULL;
@@ -78,7 +78,7 @@ slapt_rc_config *slapt_read_rc_config(const char *file_name)
/* SOURCE URL */
if (strlen(token_ptr) > strlen(SLAPT_SOURCE_TOKEN)) {
- slapt_source_t *s = slapt_init_source(token_ptr + strlen(SLAPT_SOURCE_TOKEN));
+ slapt_source_t *s = slapt_source_t_init(token_ptr + strlen(SLAPT_SOURCE_TOKEN));
if (s != NULL) {
slapt_vector_t_add(global_config->sources, s);
if (s->priority != SLAPT_PRIORITY_DEFAULT) {
@@ -91,7 +91,7 @@ slapt_rc_config *slapt_read_rc_config(const char *file_name)
/* DISABLED SOURCE */
if (strlen(token_ptr) > strlen(SLAPT_DISABLED_SOURCE_TOKEN)) {
- slapt_source_t *s = slapt_init_source(token_ptr + strlen(SLAPT_DISABLED_SOURCE_TOKEN));
+ slapt_source_t *s = slapt_source_t_init(token_ptr + strlen(SLAPT_DISABLED_SOURCE_TOKEN));
if (s != NULL) {
s->disabled = true;
slapt_vector_t_add(global_config->sources, s);
@@ -130,7 +130,7 @@ slapt_rc_config *slapt_read_rc_config(const char *file_name)
return global_config;
}
-void slapt_working_dir_init(const slapt_rc_config *global_config)
+void slapt_working_dir_init(const slapt_config_t *global_config)
{
DIR *working_dir;
int mode = W_OK, r;
@@ -167,7 +167,7 @@ void slapt_working_dir_init(const slapt_rc_config *global_config)
return;
}
-void slapt_free_rc_config(slapt_rc_config *global_config)
+void slapt_config_t_free(slapt_config_t *global_config)
{
slapt_vector_t_free(global_config->exclude_list);
slapt_vector_t_free(global_config->sources);
@@ -182,7 +182,7 @@ static slapt_vector_t *parse_exclude(char *line)
return slapt_parse_delimited_list(line, ',');
}
-bool slapt_is_interactive(const slapt_rc_config *global_config)
+bool slapt_is_interactive(const slapt_config_t *global_config)
{
bool interactive = global_config->progress_cb == NULL ? true : false;
return interactive;
@@ -225,7 +225,7 @@ static void slapt_source_parse_attributes(slapt_source_t *s, const char *string)
}
}
-slapt_source_t *slapt_init_source(const char *s)
+slapt_source_t *slapt_source_t_init(const char *s)
{
slapt_source_t *src;
uint32_t source_len = 0;
@@ -244,17 +244,17 @@ slapt_source_t *slapt_init_source(const char *s)
source_len = strlen(source_string);
/* parse for :[attr] in the source url */
- if ((attribute_regex = slapt_init_regex(SLAPT_SOURCE_ATTRIBUTE_REGEX)) == NULL) {
+ if ((attribute_regex = slapt_regex_t_init(SLAPT_SOURCE_ATTRIBUTE_REGEX)) == NULL) {
exit(EXIT_FAILURE);
}
- slapt_execute_regex(attribute_regex, source_string);
+ slapt_regex_t_execute(attribute_regex, source_string);
if (attribute_regex->reg_return == 0) {
/* if we find an attribute string, extract it */
- attribute_string = slapt_regex_extract_match(attribute_regex, source_string, 1);
+ attribute_string = slapt_regex_t_extract_match(attribute_regex, source_string, 1);
attribute_len = strlen(attribute_string);
source_len -= attribute_len;
}
- slapt_free_regex(attribute_regex);
+ slapt_regex_t_free(attribute_regex);
/* now add a trailing / if not already there */
if (source_string[source_len - 1] == '/') {
@@ -290,13 +290,13 @@ slapt_source_t *slapt_init_source(const char *s)
return src;
}
-void slapt_free_source(slapt_source_t *src)
+void slapt_source_t_free(slapt_source_t *src)
{
free(src->url);
free(src);
}
-int slapt_write_rc_config(const slapt_rc_config *global_config, const char *location)
+int slapt_config_t_write(const slapt_config_t *global_config, const char *location)
{
uint32_t i = 0;
FILE *rc;
diff --git a/src/configuration.h b/src/configuration.h
index b8d4477..ec8719d 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -51,22 +51,22 @@ typedef struct {
uint32_t retry;
bool use_priority;
bool gpgme_allow_unauth;
-} slapt_rc_config;
+} slapt_config_t;
-/* initialize slapt_rc_config */
-slapt_rc_config *slapt_init_config(void);
+/* initialize slapt_config_t */
+slapt_config_t *slapt_config_t_init(void);
/* read the configuration from file_name. Returns (rc_config *) or NULL */
-slapt_rc_config *slapt_read_rc_config(const char *file_name);
+slapt_config_t *slapt_config_t_read(const char *file_name);
/* free rc_config structure */
-void slapt_free_rc_config(slapt_rc_config *global_config);
+void slapt_config_t_free(slapt_config_t *global_config);
/* check that working_dir exists or make it if permissions allow */
-void slapt_working_dir_init(const slapt_rc_config *global_config);
+void slapt_working_dir_init(const slapt_config_t *global_config);
/* create, destroy the source struct */
-slapt_source_t *slapt_init_source(const char *s);
-void slapt_free_source(slapt_source_t *src);
+slapt_source_t *slapt_source_t_init(const char *s);
+void slapt_source_t_free(slapt_source_t *src);
-bool slapt_is_interactive(const slapt_rc_config *);
+bool slapt_is_interactive(const slapt_config_t *);
-int slapt_write_rc_config(const slapt_rc_config *global_config, const char *location);
+int slapt_config_t_write(const slapt_config_t *global_config, const char *location);
diff --git a/src/main.c b/src/main.c
index 901c885..6e3f7fe 100644
--- a/src/main.c
+++ b/src/main.c
@@ -25,11 +25,11 @@ extern int optind, opterr, optopt;
int main(int argc, char *argv[])
{
- slapt_rc_config *global_config, *initial_config; /* our config struct */
+ slapt_config_t *global_config, *initial_config; /* our config struct */
slapt_vector_t *paa = NULL;
int c = 0;
- enum slapt_action do_action = 0;
+ enum slapt_action do_action = SLAPT_ACTION_USAGE;
int option_index = 0;
static struct option long_options[] = {
{"update", 0, 0, SLAPT_UPDATE_OPT},
@@ -100,7 +100,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- initial_config = slapt_init_config();
+ initial_config = slapt_config_t_init();
if (initial_config == NULL) {
exit(EXIT_FAILURE);
}
@@ -110,35 +110,35 @@ int main(int argc, char *argv[])
while ((c = getopt_long_only(argc, argv, "", long_options, &option_index)) != -1) {
switch (c) {
case SLAPT_UPDATE_OPT: /* update */
- do_action = UPDATE;
+ do_action = SLAPT_ACTION_UPDATE;
break;
case SLAPT_INSTALL_OPT: /* install */
- do_action = INSTALL;
+ do_action = SLAPT_ACTION_INSTALL;
break;
case SLAPT_REMOVE_OPT: /* remove */
- do_action = REMOVE;
+ do_action = SLAPT_ACTION_REMOVE;
break;
case SLAPT_SHOW_OPT: /* show */
- do_action = SHOW;
+ do_action = SLAPT_ACTION_SHOW;
initial_config->simulate = true; /* allow read access */
break;
case SLAPT_SEARCH_OPT: /* search */
- do_action = SEARCH;
+ do_action = SLAPT_ACTION_SEARCH;
initial_config->simulate = true; /* allow read access */
break;
case SLAPT_LIST_OPT: /* list */
- do_action = LIST;
+ do_action = SLAPT_ACTION_LIST;
initial_config->simulate = true; /* allow read access */
break;
case SLAPT_INSTALLED_OPT: /* installed */
- do_action = INSTALLED;
+ do_action = SLAPT_ACTION_INSTALLED;
initial_config->simulate = true; /* allow read access */
break;
case SLAPT_CLEAN_OPT: /* clean */
- do_action = CLEAN;
+ do_action = SLAPT_ACTION_CLEAN;
break;
case SLAPT_UPGRADE_OPT: /* upgrade */
- do_action = UPGRADE;
+ do_action = SLAPT_ACTION_UPGRADE;
break;
case SLAPT_DOWNLOAD_ONLY_OPT: /* download only flag */
initial_config->download_only = true;
@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
break;
case SLAPT_VERSION_OPT: /* version */
version_info();
- slapt_free_rc_config(initial_config);
+ slapt_config_t_free(initial_config);
curl_global_cleanup();
exit(EXIT_SUCCESS);
case SLAPT_NO_PROMPT_OPT: /* auto */
@@ -168,11 +168,11 @@ int main(int argc, char *argv[])
break;
case SLAPT_DIST_UPGRADE_OPT: /* dist-upgrade */
initial_config->dist_upgrade = true;
- do_action = UPGRADE;
+ do_action = SLAPT_ACTION_UPGRADE;
break;
case SLAPT_HELP_OPT: /* help */
usage();
- slapt_free_rc_config(initial_config);
+ slapt_config_t_free(initial_config);
curl_global_cleanup();
exit(EXIT_SUCCESS);
case SLAPT_IGNORE_DEP_OPT: /* ignore-dep */
@@ -197,33 +197,33 @@ int main(int argc, char *argv[])
initial_config->no_upgrade = true;
break;
case SLAPT_AUTOCLEAN_OPT: /* clean old old package versions */
- do_action = AUTOCLEAN;
+ do_action = SLAPT_ACTION_AUTOCLEAN;
break;
case SLAPT_OBSOLETE_OPT: /* remove obsolete packages */
initial_config->remove_obsolete = true;
break;
case SLAPT_AVAILABLE_OPT: /* show available packages */
- do_action = AVAILABLE;
+ do_action = SLAPT_ACTION_AVAILABLE;
initial_config->simulate = true; /* allow read access */
break;
case SLAPT_INSTALL_DISK_SET_OPT: /* install a disk set */
- do_action = INSTALL_DISK_SET;
+ do_action = SLAPT_ACTION_INSTALL_DISK_SET;
break;
#ifdef SLAPT_HAS_GPGME
case SLAPT_ADD_KEYS_OPT: /* retrieve GPG keys for sources */
- do_action = ADD_KEYS;
+ do_action = SLAPT_ACTION_ADD_KEYS;
break;
case SLAPT_ALLOW_UNAUTH: /* allow unauthenticated key */
initial_config->gpgme_allow_unauth = true;
break;
#endif
case SLAPT_FILELIST:
- do_action = FILELIST;
+ do_action = SLAPT_ACTION_FILELIST;
initial_config->simulate = true; /* allow read access */
break;
default:
usage();
- slapt_free_rc_config(initial_config);
+ slapt_config_t_free(initial_config);
curl_global_cleanup();
exit(EXIT_FAILURE);
}
@@ -231,9 +231,9 @@ int main(int argc, char *argv[])
/* load up the configuration file */
if (custom_rc_location == NULL) {
- global_config = slapt_read_rc_config(RC_LOCATION);
+ global_config = slapt_config_t_read(RC_LOCATION);
} else {
- global_config = slapt_read_rc_config(custom_rc_location);
+ global_config = slapt_config_t_read(custom_rc_location);
free(custom_rc_location);
}
@@ -259,45 +259,45 @@ int main(int argc, char *argv[])
global_config->simulate = initial_config->simulate;
global_config->gpgme_allow_unauth = initial_config->gpgme_allow_unauth;
- slapt_free_rc_config(initial_config);
+ slapt_config_t_free(initial_config);
/* Check optional arguments presence */
switch (do_action) {
/* can't simulate update, clean, autoclean, or add keys */
- case CLEAN:
- case AUTOCLEAN:
+ case SLAPT_ACTION_CLEAN:
+ case SLAPT_ACTION_AUTOCLEAN:
#ifdef SLAPT_HAS_GPGME
- case ADD_KEYS:
+ case SLAPT_ACTION_ADD_KEYS:
#endif
- case UPDATE:
+ case SLAPT_ACTION_UPDATE:
global_config->simulate = false;
break;
/* remove obsolete can take the place of arguments */
- case INSTALL:
- case INSTALL_DISK_SET:
- case REMOVE:
+ case SLAPT_ACTION_INSTALL:
+ case SLAPT_ACTION_INSTALL_DISK_SET:
+ case SLAPT_ACTION_REMOVE:
if (global_config->remove_obsolete)
break;
/* fall through */
/* show, search, filelist must have arguments */
- case SHOW:
- case SEARCH:
- case FILELIST:
+ case SLAPT_ACTION_SHOW:
+ case SLAPT_ACTION_SEARCH:
+ case SLAPT_ACTION_FILELIST:
if (optind >= argc)
- do_action = 0;
+ do_action = SLAPT_ACTION_USAGE;
break;
default:
if (optind < argc)
- do_action = USAGE;
+ do_action = SLAPT_ACTION_USAGE;
break;
}
- if (do_action == USAGE) {
+ if (do_action == SLAPT_ACTION_USAGE) {
usage();
- slapt_free_rc_config(global_config);
+ slapt_config_t_free(global_config);
curl_global_cleanup();
exit(EXIT_FAILURE);
}
@@ -310,14 +310,14 @@ int main(int argc, char *argv[])
}
switch (do_action) {
- case UPDATE:
+ case SLAPT_ACTION_UPDATE:
if (slapt_update_pkg_cache(global_config) == 1) {
- slapt_free_rc_config(global_config);
+ slapt_config_t_free(global_config);
curl_global_cleanup();
exit(EXIT_FAILURE);
}
break;
- case INSTALL:
+ case SLAPT_ACTION_INSTALL:
paa = slapt_vector_t_init(free);
while (optind < argc) {
slapt_vector_t_add(paa, strdup(argv[optind]));
@@ -326,7 +326,7 @@ int main(int argc, char *argv[])
slapt_pkg_action_install(global_config, paa);
slapt_vector_t_free(paa);
break;
- case INSTALL_DISK_SET: {
+ case SLAPT_ACTION_INSTALL_DISK_SET: {
paa = slapt_vector_t_init(NULL);
slapt_vector_t *avail_pkgs = slapt_get_available_pkgs();
@@ -336,7 +336,7 @@ int main(int argc, char *argv[])
slapt_vector_t *matches = slapt_search_pkg_list(avail_pkgs, search);
free(search);
- slapt_vector_t_foreach (slapt_pkg_info_t *, match, matches) {
+ slapt_vector_t_foreach (slapt_pkg_t *, match, matches) {
if (!slapt_is_excluded(global_config, match)) {
slapt_vector_t_add(paa, match->name);
}
@@ -351,7 +351,7 @@ int main(int argc, char *argv[])
slapt_vector_t_free(avail_pkgs);
} break;
- case REMOVE:
+ case SLAPT_ACTION_REMOVE:
paa = slapt_vector_t_init(free);
while (optind < argc) {
slapt_vector_t_add(paa, strdup(argv[optind]));
@@ -360,26 +360,26 @@ int main(int argc, char *argv[])
slapt_pkg_action_remove(global_config, paa);
slapt_vector_t_free(paa);
break;
- case SHOW:
+ case SLAPT_ACTION_SHOW:
while (optind < argc) {
slapt_pkg_action_show(argv[optind++]);
}
break;
- case SEARCH:
+ case SLAPT_ACTION_SEARCH:
while (optind < argc) {
slapt_pkg_action_search(argv[optind++]);
}
break;
- case UPGRADE:
+ case SLAPT_ACTION_UPGRADE:
slapt_pkg_action_upgrade_all(global_config);
break;
- case LIST:
- slapt_pkg_action_list(LIST);
+ case SLAPT_ACTION_LIST:
+ slapt_pkg_action_list(SLAPT_ACTION_LIST);
break;
- case INSTALLED:
- slapt_pkg_action_list(INSTALLED);
+ case SLAPT_ACTION_INSTALLED:
+ slapt_pkg_action_list(SLAPT_ACTION_INSTALLED);
break;
- case CLEAN:
+ case SLAPT_ACTION_CLEAN:
/* clean out local cache */
slapt_clean_pkg_dir(global_config->working_dir);
if ((chdir(global_config->working_dir)) == -1) {
@@ -387,29 +387,29 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
break;
- case AUTOCLEAN:
+ case SLAPT_ACTION_AUTOCLEAN:
slapt_purge_old_cached_pkgs(global_config, NULL, NULL);
break;
- case AVAILABLE:
- slapt_pkg_action_list(AVAILABLE);
+ case SLAPT_ACTION_AVAILABLE:
+ slapt_pkg_action_list(SLAPT_ACTION_AVAILABLE);
break;
#ifdef SLAPT_HAS_GPGME
- case ADD_KEYS:
+ case SLAPT_ACTION_ADD_KEYS:
slapt_pkg_action_add_keys(global_config);
break;
#endif
- case FILELIST:
+ case SLAPT_ACTION_FILELIST:
while (optind < argc) {
slapt_pkg_action_filelist(argv[optind++]);
}
break;
- case USAGE:
+ case SLAPT_ACTION_USAGE:
default:
printf("main.c(l.%d): This should never be reached\n", __LINE__);
exit(255);
}
- slapt_free_rc_config(global_config);
+ slapt_config_t_free(global_config);
curl_global_cleanup();
return EXIT_SUCCESS;
}
diff --git a/src/main.h b/src/main.h
index db91de4..6122729 100644
--- a/src/main.h
+++ b/src/main.h
@@ -53,27 +53,6 @@
#include "slaptgpgme.h"
#endif
-enum slapt_action {
- USAGE = 0,
- UPDATE,
- INSTALL,
- REMOVE,
- SHOW,
- SEARCH,
- UPGRADE,
- LIST,
- INSTALLED,
- CLEAN,
- SHOWVERSION,
- AUTOCLEAN,
- AVAILABLE,
-#ifdef SLAPT_HAS_GPGME
- ADD_KEYS,
-#endif
- INSTALL_DISK_SET,
- FILELIST
-};
-
#define SLAPT_UPDATE_OPT 'u'
#define SLAPT_UPGRADE_OPT 'g'
#define SLAPT_INSTALL_OPT 'i'
diff --git a/src/package.c b/src/package.c
index 295b7a2..60fdc7c 100644
--- a/src/package.c
+++ b/src/package.c
@@ -26,19 +26,19 @@ struct slapt_pkg_version_parts {
/* analyze the pkg version hunk by hunk */
static struct slapt_pkg_version_parts *break_down_pkg_version(const char *version);
/* parse the meta lines */
-static slapt_pkg_info_t *parse_meta_entry(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, char *dep_entry);
+static slapt_pkg_t *parse_meta_entry(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, char *dep_entry);
/* called by slapt_is_required_by */
static void required_by(slapt_vector_t *avail,
slapt_vector_t *installed_pkgs,
slapt_vector_t *pkgs_to_install,
slapt_vector_t *pkgs_to_remove,
- slapt_pkg_info_t *pkg,
+ slapt_pkg_t *pkg,
slapt_vector_t *required_by_list);
-static char *escape_package_name(slapt_pkg_info_t *pkg);
+static char *escape_package_name(slapt_pkg_t *pkg);
/* free pkg_version_parts struct */
-static void slapt_free_pkg_version_parts(struct slapt_pkg_version_parts *parts);
+static void slapt_pkg_t_free_version_parts(struct slapt_pkg_version_parts *parts);
/* find dependency from "or" requirement */
-static slapt_pkg_info_t *find_or_requirement(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, char *required_str);
+static slapt_pkg_t *find_or_requirement(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, char *required_str);
/* uncompress compressed package data */
static FILE *slapt_gunzip_file(const char *file_name, FILE *dest_file);
@@ -66,7 +66,7 @@ slapt_vector_t *slapt_get_available_pkgs(void)
/* this is pointless to do if we wrote the data sorted, but this
ensures upgrades from older, presorting slapt-gets still work
as expected. */
- qsort(list->items, list->size, sizeof(list->items[0]), slapt_pkg_info_t_qsort_cmp);
+ qsort(list->items, list->size, sizeof(list->items[0]), slapt_pkg_t_qsort_cmp);
list->sorted = true;
@@ -88,30 +88,30 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
char *getline_buffer = NULL;
char *char_pointer = NULL;
- list = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_pkg);
+ list = slapt_vector_t_init((slapt_vector_t_free_function)slapt_pkg_t_free);
/* compile our regexen */
- if ((name_regex = slapt_init_regex(SLAPT_PKG_NAME_PATTERN)) == NULL) {
+ if ((name_regex = slapt_regex_t_init(SLAPT_PKG_NAME_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
- if ((mirror_regex = slapt_init_regex(SLAPT_PKG_MIRROR_PATTERN)) == NULL) {
+ if ((mirror_regex = slapt_regex_t_init(SLAPT_PKG_MIRROR_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
- if ((priority_regex = slapt_init_regex(SLAPT_PKG_PRIORITY_PATTERN)) == NULL) {
+ if ((priority_regex = slapt_regex_t_init(SLAPT_PKG_PRIORITY_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
- if ((location_regex = slapt_init_regex(SLAPT_PKG_LOCATION_PATTERN)) == NULL) {
+ if ((location_regex = slapt_regex_t_init(SLAPT_PKG_LOCATION_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
- if ((size_c_regex = slapt_init_regex(SLAPT_PKG_SIZEC_PATTERN)) == NULL) {
+ if ((size_c_regex = slapt_regex_t_init(SLAPT_PKG_SIZEC_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
- if ((size_u_regex = slapt_init_regex(SLAPT_PKG_SIZEU_PATTERN)) == NULL) {
+ if ((size_u_regex = slapt_regex_t_init(SLAPT_PKG_SIZEU_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
while ((bytes_read = getline(&getline_buffer, &getline_len, pkg_list_fh)) != EOF) {
- slapt_pkg_info_t *tmp_pkg;
+ slapt_pkg_t *tmp_pkg;
getline_buffer[bytes_read - 1] = '\0';
@@ -119,7 +119,7 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
if (strstr(getline_buffer, "PACKAGE NAME") == NULL)
continue;
- slapt_execute_regex(name_regex, getline_buffer);
+ slapt_regex_t_execute(name_regex, getline_buffer);
/* skip this line if we didn't find a package name */
if (name_regex->reg_return != 0) {
@@ -128,22 +128,22 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
}
/* otherwise keep going and parse out the rest of the pkg data */
- tmp_pkg = slapt_init_pkg();
+ tmp_pkg = slapt_pkg_t_init();
/* pkg name base */
- tmp_pkg->name = slapt_regex_extract_match(name_regex, getline_buffer, 1);
+ tmp_pkg->name = slapt_regex_t_extract_match(name_regex, getline_buffer, 1);
/* pkg version */
- tmp_pkg->version = slapt_regex_extract_match(name_regex, getline_buffer, 2);
+ tmp_pkg->version = slapt_regex_t_extract_match(name_regex, getline_buffer, 2);
/* file extension */
- tmp_pkg->file_ext = slapt_regex_extract_match(name_regex, getline_buffer, 3);
+ tmp_pkg->file_ext = slapt_regex_t_extract_match(name_regex, getline_buffer, 3);
/* mirror */
f_pos = ftell(pkg_list_fh);
if (getline(&getline_buffer, &getline_len, pkg_list_fh) != EOF) {
- slapt_execute_regex(mirror_regex, getline_buffer);
+ slapt_regex_t_execute(mirror_regex, getline_buffer);
if (mirror_regex->reg_return == 0) {
- tmp_pkg->mirror = slapt_regex_extract_match(mirror_regex, getline_buffer, 1);
+ tmp_pkg->mirror = slapt_regex_t_extract_match(mirror_regex, getline_buffer, 1);
} else {
/* mirror isn't provided... rewind one line */
fseek(pkg_list_fh, (ftell(pkg_list_fh) - f_pos) * -1, SEEK_CUR);
@@ -153,10 +153,10 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
/* priority */
f_pos = ftell(pkg_list_fh);
if (getline(&getline_buffer, &getline_len, pkg_list_fh) != EOF) {
- slapt_execute_regex(priority_regex, getline_buffer);
+ slapt_regex_t_execute(priority_regex, getline_buffer);
if (priority_regex->reg_return == 0) {
- char *priority_string = slapt_regex_extract_match(priority_regex, getline_buffer, 1);
+ char *priority_string = slapt_regex_t_extract_match(priority_regex, getline_buffer, 1);
if (priority_string != NULL) {
tmp_pkg->priority = atoi(priority_string);
free(priority_string);
@@ -169,10 +169,10 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
/* location */
if ((getline(&getline_buffer, &getline_len, pkg_list_fh) != EOF)) {
- slapt_execute_regex(location_regex, getline_buffer);
+ slapt_regex_t_execute(location_regex, getline_buffer);
if (location_regex->reg_return == 0) {
- tmp_pkg->location = slapt_regex_extract_match(location_regex, getline_buffer, 1);
+ tmp_pkg->location = slapt_regex_t_extract_match(location_regex, getline_buffer, 1);
#if SLACKWARE_EXTRA_TESTING_PASTURE_WORKAROUND == 1
/* extra, testing, and pasture support
@@ -206,12 +206,12 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
} else {
fprintf(stderr, gettext("regexec failed to parse location\n"));
- slapt_free_pkg(tmp_pkg);
+ slapt_pkg_t_free(tmp_pkg);
continue;
}
} else {
fprintf(stderr, gettext("getline reached EOF attempting to read location\n"));
- slapt_free_pkg(tmp_pkg);
+ slapt_pkg_t_free(tmp_pkg);
continue;
}
@@ -219,20 +219,20 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
if ((getline(&getline_buffer, &getline_len, pkg_list_fh) != EOF)) {
char *size_c = NULL;
- slapt_execute_regex(size_c_regex, getline_buffer);
+ slapt_regex_t_execute(size_c_regex, getline_buffer);
if (size_c_regex->reg_return == 0) {
- size_c = slapt_regex_extract_match(size_c_regex, getline_buffer, 1);
+ size_c = slapt_regex_t_extract_match(size_c_regex, getline_buffer, 1);
tmp_pkg->size_c = strtol(size_c, (char **)NULL, 10);
free(size_c);
} else {
fprintf(stderr, gettext("regexec failed to parse size_c\n"));
- slapt_free_pkg(tmp_pkg);
+ slapt_pkg_t_free(tmp_pkg);
continue;
}
} else {
fprintf(stderr, gettext("getline reached EOF attempting to read size_c\n"));
- slapt_free_pkg(tmp_pkg);
+ slapt_pkg_t_free(tmp_pkg);
continue;
}
@@ -240,20 +240,20 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
if ((getline(&getline_buffer, &getline_len, pkg_list_fh) != EOF)) {
char *size_u = NULL;
- slapt_execute_regex(size_u_regex, getline_buffer);
+ slapt_regex_t_execute(size_u_regex, getline_buffer);
if (size_u_regex->reg_return == 0) {
- size_u = slapt_regex_extract_match(size_u_regex, getline_buffer, 1);
+ size_u = slapt_regex_t_extract_match(size_u_regex, getline_buffer, 1);
tmp_pkg->size_u = strtol(size_u, (char **)NULL, 10);
free(size_u);
} else {
fprintf(stderr, gettext("regexec failed to parse size_u\n"));
- slapt_free_pkg(tmp_pkg);
+ slapt_pkg_t_free(tmp_pkg);
continue;
}
} else {
fprintf(stderr, gettext("getline reached EOF attempting to read size_u\n"));
- slapt_free_pkg(tmp_pkg);
+ slapt_pkg_t_free(tmp_pkg);
continue;
}
@@ -323,7 +323,7 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
/* don't overflow the buffer */
if (strlen(md5sum) > SLAPT_MD5_STR_LEN) {
fprintf(stderr, gettext("md5 sum too long\n"));
- slapt_free_pkg(tmp_pkg);
+ slapt_pkg_t_free(tmp_pkg);
continue;
}
@@ -356,7 +356,7 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
}
} else {
fprintf(stderr, gettext("error attempting to read pkg description\n"));
- slapt_free_pkg(tmp_pkg);
+ slapt_pkg_t_free(tmp_pkg);
continue;
}
@@ -381,17 +381,17 @@ slapt_vector_t *slapt_parse_packages_txt(FILE *pkg_list_fh)
if (getline_buffer)
free(getline_buffer);
- slapt_free_regex(name_regex);
- slapt_free_regex(mirror_regex);
- slapt_free_regex(priority_regex);
- slapt_free_regex(location_regex);
- slapt_free_regex(size_c_regex);
- slapt_free_regex(size_u_regex);
+ slapt_regex_t_free(name_regex);
+ slapt_regex_t_free(mirror_regex);
+ slapt_regex_t_free(priority_regex);
+ slapt_regex_t_free(location_regex);
+ slapt_regex_t_free(size_c_regex);
+ slapt_regex_t_free(size_u_regex);
return list;
}
-char *slapt_gen_short_pkg_description(slapt_pkg_info_t *pkg)
+char *slapt_gen_short_pkg_description(slapt_pkg_t *pkg)
{
char *short_description = NULL;
size_t string_size = 0;
@@ -420,15 +420,15 @@ slapt_vector_t *slapt_get_installed_pkgs(void)
slapt_vector_t *list = NULL;
size_t pls = 1;
- list = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_pkg);
+ list = slapt_vector_t_init((slapt_vector_t_free_function)slapt_pkg_t_free);
- if ((ip_regex = slapt_init_regex(SLAPT_PKG_LOG_PATTERN)) == NULL) {
+ if ((ip_regex = slapt_regex_t_init(SLAPT_PKG_LOG_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
- if ((compressed_size_reg = slapt_init_regex(SLAPT_PKG_LOG_SIZEC_PATTERN)) == NULL) {
+ if ((compressed_size_reg = slapt_regex_t_init(SLAPT_PKG_LOG_SIZEC_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
- if ((uncompressed_size_reg = slapt_init_regex(SLAPT_PKG_LOG_SIZEU_PATTERN)) == NULL) {
+ if ((uncompressed_size_reg = slapt_regex_t_init(SLAPT_PKG_LOG_SIZEU_PATTERN)) == NULL) {
exit(EXIT_FAILURE);
}
@@ -443,22 +443,22 @@ slapt_vector_t *slapt_get_installed_pkgs(void)
}
while ((file = readdir(pkg_log_dir)) != NULL) {
- slapt_pkg_info_t *tmp_pkg = NULL;
+ slapt_pkg_t *tmp_pkg = NULL;
FILE *pkg_f = NULL;
char *pkg_f_name = NULL;
struct stat stat_buf;
char *pkg_data = NULL;
- slapt_execute_regex(ip_regex, file->d_name);
+ slapt_regex_t_execute(ip_regex, file->d_name);
/* skip if it doesn't match our regex */
if (ip_regex->reg_return != 0)
continue;
- tmp_pkg = slapt_init_pkg();
+ tmp_pkg = slapt_pkg_t_init();
- tmp_pkg->name = slapt_regex_extract_match(ip_regex, file->d_name, 1);
- tmp_pkg->version = slapt_regex_extract_match(ip_regex, file->d_name, 2);
+ tmp_pkg->name = slapt_regex_t_extract_match(ip_regex, file->d_name, 1);
+ tmp_pkg->version = slapt_regex_t_extract_match(ip_regex, file->d_name, 2);
tmp_pkg->file_ext = slapt_malloc(sizeof *tmp_pkg->file_ext * 1);
tmp_pkg->file_ext[0] = '\0';
@@ -486,7 +486,7 @@ slapt_vector_t *slapt_get_installed_pkgs(void)
/* don't mmap empty files */
if ((int)stat_buf.st_size < 1) {
- slapt_free_pkg(tmp_pkg);
+ slapt_pkg_t_free(tmp_pkg);
free(pkg_f_name);
fclose(pkg_f);
continue;
@@ -512,10 +512,10 @@ slapt_vector_t *slapt_get_installed_pkgs(void)
pkg_data[pls - 1] = '\0';
/* pull out compressed size */
- slapt_execute_regex(compressed_size_reg, pkg_data);
+ slapt_regex_t_execute(compressed_size_reg, pkg_data);
if (compressed_size_reg->reg_return == 0) {
- char *size_c = slapt_regex_extract_match(compressed_size_reg, pkg_data, 1);
- char *unit = slapt_regex_extract_match(compressed_size_reg, pkg_data, 2);
+ char *size_c = slapt_regex_t_extract_match(compressed_size_reg, pkg_data, 1);
+ char *unit = slapt_regex_t_extract_match(compressed_size_reg, pkg_data, 2);
double c = strtof(size_c, (char **)NULL);
if (strcmp(unit, "M") == 0)
c *= 1024;
@@ -525,10 +525,10 @@ slapt_vector_t *slapt_get_installed_pkgs(void)
}
/* pull out uncompressed size */
- slapt_execute_regex(uncompressed_size_reg, pkg_data);
+ slapt_regex_t_execute(uncompressed_size_reg, pkg_data);
if (uncompressed_size_reg->reg_return == 0) {
- char *size_u = slapt_regex_extract_match(uncompressed_size_reg, pkg_data, 1);
- char *unit = slapt_regex_extract_match(uncompressed_size_reg, pkg_data, 2);
+ char *size_u = slapt_regex_t_extract_match(uncompressed_size_reg, pkg_data, 1);
+ char *unit = slapt_regex_t_extract_match(uncompressed_size_reg, pkg_data, 2);
double u = strtof(size_u, (char **)NULL);
if (strcmp(unit, "M") == 0)
u *= 1024;
@@ -603,37 +603,37 @@ slapt_vector_t *slapt_get_installed_pkgs(void)
} /* end while */
closedir(pkg_log_dir);
- slapt_free_regex(ip_regex);
+ slapt_regex_t_free(ip_regex);
free(pkg_log_dirname);
- slapt_free_regex(compressed_size_reg);
- slapt_free_regex(uncompressed_size_reg);
+ slapt_regex_t_free(compressed_size_reg);
+ slapt_regex_t_free(uncompressed_size_reg);
- qsort(list->items, list->size, sizeof(list->items[0]), slapt_pkg_info_t_qsort_cmp);
+ qsort(list->items, list->size, sizeof(list->items[0]), slapt_pkg_t_qsort_cmp);
return list;
}
/*
static int by_name(const void *pkg, const void *name){
- slapt_pkg_info_t *p = *(slapt_pkg_info_t **)pkg;
+ slapt_pkg_t *p = *(slapt_pkg_t **)pkg;
char *cname = *(char **)name;
return strcmp(p->name, cname);
}
*/
static int by_details(const void *a, const void *b)
{
- return slapt_pkg_info_t_qsort_cmp(&a, &b);
+ return slapt_pkg_t_qsort_cmp(&a, &b);
}
/* lookup newest package from pkg_list */
-slapt_pkg_info_t *slapt_get_newest_pkg(slapt_vector_t *pkg_list, const char *pkg_name)
+slapt_pkg_t *slapt_get_newest_pkg(slapt_vector_t *pkg_list, const char *pkg_name)
{
- slapt_pkg_info_t *found = NULL;
- slapt_vector_t *matches = slapt_vector_t_search(pkg_list, by_details, &(slapt_pkg_info_t){.name = (char *)pkg_name});
+ slapt_pkg_t *found = NULL;
+ slapt_vector_t *matches = slapt_vector_t_search(pkg_list, by_details, &(slapt_pkg_t){.name = (char *)pkg_name});
if (!matches) {
return found;
}
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, matches) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, matches) {
if (strcmp(pkg->name, pkg_name) != 0)
continue;
if ((found == NULL) || (slapt_cmp_pkgs(found, pkg) < 0))
@@ -643,16 +643,16 @@ slapt_pkg_info_t *slapt_get_newest_pkg(slapt_vector_t *pkg_list, const char *pkg
return found;
}
-slapt_pkg_info_t *slapt_get_exact_pkg(slapt_vector_t *list, const char *name, const char *version)
+slapt_pkg_t *slapt_get_exact_pkg(slapt_vector_t *list, const char *name, const char *version)
{
- int idx = slapt_vector_t_index_of(list, by_details, &(slapt_pkg_info_t){.name = (char *)name, .version = (char *)version});
+ int idx = slapt_vector_t_index_of(list, by_details, &(slapt_pkg_t){.name = (char *)name, .version = (char *)version});
if (idx > -1) {
return list->items[idx];
}
return NULL;
}
-int slapt_install_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg)
+int slapt_install_pkg(const slapt_config_t *global_config, slapt_pkg_t *pkg)
{
char *pkg_file_name = NULL;
char *command = NULL;
@@ -679,7 +679,7 @@ int slapt_install_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pk
return cmd_return;
}
-int slapt_upgrade_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg)
+int slapt_upgrade_pkg(const slapt_config_t *global_config, slapt_pkg_t *pkg)
{
char *pkg_file_name = NULL;
char *command = NULL;
@@ -706,7 +706,7 @@ int slapt_upgrade_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pk
return cmd_return;
}
-int slapt_remove_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg)
+int slapt_remove_pkg(const slapt_config_t *global_config, slapt_pkg_t *pkg)
{
char *command = NULL;
int cmd_return = 0;
@@ -730,7 +730,7 @@ int slapt_remove_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg
return cmd_return;
}
-void slapt_free_pkg(slapt_pkg_info_t *pkg)
+void slapt_pkg_t_free(slapt_pkg_t *pkg)
{
if (pkg->required != NULL)
free(pkg->required);
@@ -762,7 +762,7 @@ void slapt_free_pkg(slapt_pkg_info_t *pkg)
free(pkg);
}
-bool slapt_is_excluded(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg)
+bool slapt_is_excluded(const slapt_config_t *global_config, slapt_pkg_t *pkg)
{
int name_reg_ret = -1, version_reg_ret = -1, location_reg_ret = -1;
@@ -781,20 +781,20 @@ bool slapt_is_excluded(const slapt_rc_config *global_config, slapt_pkg_info_t *p
return true;
/* this regex has to be init'd and free'd within the loop b/c the regex is pulled from the exclude list */
- if ((exclude_reg = slapt_init_regex(exclude)) == NULL) {
+ if ((exclude_reg = slapt_regex_t_init(exclude)) == NULL) {
continue;
}
- slapt_execute_regex(exclude_reg, pkg->name);
+ slapt_regex_t_execute(exclude_reg, pkg->name);
name_reg_ret = exclude_reg->reg_return;
- slapt_execute_regex(exclude_reg, pkg->version);
+ slapt_regex_t_execute(exclude_reg, pkg->version);
version_reg_ret = exclude_reg->reg_return;
- slapt_execute_regex(exclude_reg, pkg->location);
+ slapt_regex_t_execute(exclude_reg, pkg->location);
location_reg_ret = exclude_reg->reg_return;
- slapt_free_regex(exclude_reg);
+ slapt_regex_t_free(exclude_reg);
if (name_reg_ret == 0 || version_reg_ret == 0 || location_reg_ret == 0) {
return true;
@@ -811,7 +811,7 @@ void slapt_get_md5sums(slapt_vector_t *pkgs, FILE *checksum_file)
size_t getline_len = 0;
char *getline_buffer = NULL;
- if ((md5sum_regex = slapt_init_regex(SLAPT_MD5SUM_REGEX)) == NULL) {
+ if ((md5sum_regex = slapt_regex_t_init(SLAPT_MD5SUM_REGEX)) == NULL) {
exit(EXIT_FAILURE);
}
@@ -826,22 +826,22 @@ void slapt_get_md5sums(slapt_vector_t *pkgs, FILE *checksum_file)
if (strstr(getline_buffer, ".asc") != NULL)
continue;
- slapt_execute_regex(md5sum_regex, getline_buffer);
+ slapt_regex_t_execute(md5sum_regex, getline_buffer);
if (md5sum_regex->reg_return == 0) {
char *sum, *location, *name, *version;
/* md5 sum */
- sum = slapt_regex_extract_match(md5sum_regex, getline_buffer, 1);
+ sum = slapt_regex_t_extract_match(md5sum_regex, getline_buffer, 1);
/* location/directory */
- location = slapt_regex_extract_match(md5sum_regex, getline_buffer, 2);
+ location = slapt_regex_t_extract_match(md5sum_regex, getline_buffer, 2);
/* pkg name */
- name = slapt_regex_extract_match(md5sum_regex, getline_buffer, 3);
+ name = slapt_regex_t_extract_match(md5sum_regex, getline_buffer, 3);
/* pkg version */
- version = slapt_regex_extract_match(md5sum_regex, getline_buffer, 4);
+ version = slapt_regex_t_extract_match(md5sum_regex, getline_buffer, 4);
/* see if we can match up name, version, and location */
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, pkgs) {
if ((strcmp(pkg->name, name) == 0) && (slapt_cmp_pkg_versions(pkg->version, version) == 0) && (strcmp(pkg->location, location) == 0)) {
memcpy(pkg->md5, sum, SLAPT_MD5_STR_LEN);
break;
@@ -858,13 +858,13 @@ void slapt_get_md5sums(slapt_vector_t *pkgs, FILE *checksum_file)
if (getline_buffer)
free(getline_buffer);
- slapt_free_regex(md5sum_regex);
+ slapt_regex_t_free(md5sum_regex);
rewind(checksum_file);
return;
}
-static void slapt_free_pkg_version_parts(struct slapt_pkg_version_parts *parts)
+static void slapt_pkg_t_free_version_parts(struct slapt_pkg_version_parts *parts)
{
for (uint32_t i = 0; i < parts->count; i++) {
free(parts->parts[i]);
@@ -873,7 +873,7 @@ static void slapt_free_pkg_version_parts(struct slapt_pkg_version_parts *parts)
free(parts);
}
-int slapt_cmp_pkgs(slapt_pkg_info_t *a, slapt_pkg_info_t *b)
+int slapt_cmp_pkgs(slapt_pkg_t *a, slapt_pkg_t *b)
{
int greater = 1, lesser = -1, equal = 0;
@@ -910,26 +910,26 @@ int slapt_cmp_pkg_versions(const char *a, const char *b)
/* if the integer value of the version part is the same and the # of version parts is the same (fixes 3.8.1p1-i486-1 to 3.8p1-i486-1) */
if ((atoi(a_parts->parts[position]) == atoi(b_parts->parts[position])) && (a_parts->count == b_parts->count)) {
if (strverscmp(a_parts->parts[position], b_parts->parts[position]) < 0) {
- slapt_free_pkg_version_parts(a_parts);
- slapt_free_pkg_version_parts(b_parts);
+ slapt_pkg_t_free_version_parts(a_parts);
+ slapt_pkg_t_free_version_parts(b_parts);
return lesser;
}
if (strverscmp(a_parts->parts[position], b_parts->parts[position]) > 0) {
- slapt_free_pkg_version_parts(a_parts);
- slapt_free_pkg_version_parts(b_parts);
+ slapt_pkg_t_free_version_parts(a_parts);
+ slapt_pkg_t_free_version_parts(b_parts);
return greater;
}
}
if (atoi(a_parts->parts[position]) < atoi(b_parts->parts[position])) {
- slapt_free_pkg_version_parts(a_parts);
- slapt_free_pkg_version_parts(b_parts);
+ slapt_pkg_t_free_version_parts(a_parts);
+ slapt_pkg_t_free_version_parts(b_parts);
return lesser;
}
if (atoi(a_parts->parts[position]) > atoi(b_parts->parts[position])) {
- slapt_free_pkg_version_parts(a_parts);
- slapt_free_pkg_version_parts(b_parts);
+ slapt_pkg_t_free_version_parts(a_parts);
+ slapt_pkg_t_free_version_parts(b_parts);
return greater;
}
}
@@ -943,18 +943,18 @@ int slapt_cmp_pkg_versions(const char *a, const char *b)
*/
if (a_parts->count != b_parts->count) {
if (a_parts->count > b_parts->count) {
- slapt_free_pkg_version_parts(a_parts);
- slapt_free_pkg_version_parts(b_parts);
+ slapt_pkg_t_free_version_parts(a_parts);
+ slapt_pkg_t_free_version_parts(b_parts);
return greater;
} else {
- slapt_free_pkg_version_parts(a_parts);
- slapt_free_pkg_version_parts(b_parts);
+ slapt_pkg_t_free_version_parts(a_parts);
+ slapt_pkg_t_free_version_parts(b_parts);
return lesser;
}
}
- slapt_free_pkg_version_parts(a_parts);
- slapt_free_pkg_version_parts(b_parts);
+ slapt_pkg_t_free_version_parts(a_parts);
+ slapt_pkg_t_free_version_parts(b_parts);
/*
Now we check to see that the version follows the standard slackware
@@ -1077,7 +1077,7 @@ static struct slapt_pkg_version_parts *break_down_pkg_version(const char *versio
void slapt_write_pkg_data(const char *source_url, FILE *d_file, slapt_vector_t *pkgs)
{
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, pkgs) {
fprintf(d_file, "PACKAGE NAME: %s-%s%s\n", pkg->name, pkg->version, pkg->file_ext);
if (pkg->mirror != NULL && strlen(pkg->mirror) > 0) {
fprintf(d_file, "PACKAGE MIRROR: %s\n", pkg->mirror);
@@ -1121,28 +1121,28 @@ slapt_vector_t *slapt_search_pkg_list(slapt_vector_t *list, const char *pattern)
matches = slapt_vector_t_init(NULL);
- if ((search_regex = slapt_init_regex(pattern)) == NULL)
+ if ((search_regex = slapt_regex_t_init(pattern)) == NULL)
return matches;
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, list) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, list) {
if (strcmp(pkg->name, pattern) == 0) {
slapt_vector_t_add(matches, pkg);
continue;
}
- slapt_execute_regex(search_regex, pkg->name);
+ slapt_regex_t_execute(search_regex, pkg->name);
name_r = search_regex->reg_return;
- slapt_execute_regex(search_regex, pkg->version);
+ slapt_regex_t_execute(search_regex, pkg->version);
version_r = search_regex->reg_return;
if (pkg->description != NULL) {
- slapt_execute_regex(search_regex, pkg->description);
+ slapt_regex_t_execute(search_regex, pkg->description);
desc_r = search_regex->reg_return;
}
if (pkg->location != NULL) {
- slapt_execute_regex(search_regex, pkg->location);
+ slapt_regex_t_execute(search_regex, pkg->location);
loc_r = search_regex->reg_return;
}
@@ -1151,15 +1151,15 @@ slapt_vector_t *slapt_search_pkg_list(slapt_vector_t *list, const char *pattern)
slapt_vector_t_add(matches, pkg);
}
}
- slapt_free_regex(search_regex);
+ slapt_regex_t_free(search_regex);
return matches;
}
/* lookup dependencies for pkg */
-int slapt_get_pkg_dependencies(const slapt_rc_config *global_config,
+int slapt_get_pkg_dependencies(const slapt_config_t *global_config,
slapt_vector_t *avail_pkgs,
- slapt_vector_t *installed_pkgs, slapt_pkg_info_t *pkg,
+ slapt_vector_t *installed_pkgs, slapt_pkg_t *pkg,
slapt_vector_t *deps,
slapt_vector_t *conflict_err,
slapt_vector_t *missing_err)
@@ -1185,7 +1185,7 @@ int slapt_get_pkg_dependencies(const slapt_rc_config *global_config,
/* parse dep line */
dep_parts = slapt_parse_delimited_list(pkg->required, ',');
slapt_vector_t_foreach (char *, part, dep_parts) {
- slapt_pkg_info_t *tmp_pkg = NULL;
+ slapt_pkg_t *tmp_pkg = NULL;
if (strchr(part, '|') != NULL) {
tmp_pkg = find_or_requirement(avail_pkgs, installed_pkgs, part);
@@ -1238,7 +1238,7 @@ int slapt_get_pkg_dependencies(const slapt_rc_config *global_config,
}
/* lookup conflicts for package */
-slapt_vector_t *slapt_get_pkg_conflicts(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, slapt_pkg_info_t *pkg)
+slapt_vector_t *slapt_get_pkg_conflicts(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, slapt_pkg_t *pkg)
{
slapt_vector_t *conflicts = NULL;
int position = 0, len = 0;
@@ -1256,7 +1256,7 @@ slapt_vector_t *slapt_get_pkg_conflicts(slapt_vector_t *avail_pkgs, slapt_vector
/* parse conflict line */
len = strlen(pkg->conflicts);
while (position < len) {
- slapt_pkg_info_t *tmp_pkg = NULL;
+ slapt_pkg_t *tmp_pkg = NULL;
/* either the last or there was only one to begin with */
if (strstr(pkg->conflicts + position, ",") == NULL) {
@@ -1293,31 +1293,31 @@ slapt_vector_t *slapt_get_pkg_conflicts(slapt_vector_t *avail_pkgs, slapt_vector
return conflicts;
}
-static slapt_pkg_info_t *parse_meta_entry(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, char *dep_entry)
+static slapt_pkg_t *parse_meta_entry(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, char *dep_entry)
{
slapt_regex_t *parse_dep_regex = NULL;
char *tmp_pkg_name = NULL, *tmp_pkg_ver = NULL;
char tmp_pkg_cond[3];
- slapt_pkg_info_t *newest_avail_pkg;
- slapt_pkg_info_t *newest_installed_pkg;
+ slapt_pkg_t *newest_avail_pkg;
+ slapt_pkg_t *newest_installed_pkg;
int tmp_cond_len = 0;
- if ((parse_dep_regex = slapt_init_regex(SLAPT_REQUIRED_REGEX)) == NULL) {
+ if ((parse_dep_regex = slapt_regex_t_init(SLAPT_REQUIRED_REGEX)) == NULL) {
exit(EXIT_FAILURE);
}
/* regex to pull out pieces */
- slapt_execute_regex(parse_dep_regex, dep_entry);
+ slapt_regex_t_execute(parse_dep_regex, dep_entry);
/* if the regex failed, just skip out */
if (parse_dep_regex->reg_return != 0) {
- slapt_free_regex(parse_dep_regex);
+ slapt_regex_t_free(parse_dep_regex);
return NULL;
}
tmp_cond_len = parse_dep_regex->pmatch[2].rm_eo - parse_dep_regex->pmatch[2].rm_so;
- tmp_pkg_name = slapt_regex_extract_match(parse_dep_regex, dep_entry, 1);
+ tmp_pkg_name = slapt_regex_t_extract_match(parse_dep_regex, dep_entry, 1);
newest_avail_pkg = slapt_get_newest_pkg(avail_pkgs, tmp_pkg_name);
newest_installed_pkg = slapt_get_newest_pkg(installed_pkgs, tmp_pkg_name);
@@ -1325,12 +1325,12 @@ static slapt_pkg_info_t *parse_meta_entry(slapt_vector_t *avail_pkgs, slapt_vect
/* if there is no conditional and version, return newest */
if (tmp_cond_len == 0) {
if (newest_installed_pkg != NULL) {
- slapt_free_regex(parse_dep_regex);
+ slapt_regex_t_free(parse_dep_regex);
free(tmp_pkg_name);
return newest_installed_pkg;
}
if (newest_avail_pkg != NULL) {
- slapt_free_regex(parse_dep_regex);
+ slapt_regex_t_free(parse_dep_regex);
free(tmp_pkg_name);
return newest_avail_pkg;
}
@@ -1338,7 +1338,7 @@ static slapt_pkg_info_t *parse_meta_entry(slapt_vector_t *avail_pkgs, slapt_vect
if (tmp_cond_len > 3) {
fprintf(stderr, gettext("pkg conditional too long\n"));
- slapt_free_regex(parse_dep_regex);
+ slapt_regex_t_free(parse_dep_regex);
free(tmp_pkg_name);
return NULL;
}
@@ -1348,9 +1348,9 @@ static slapt_pkg_info_t *parse_meta_entry(slapt_vector_t *avail_pkgs, slapt_vect
tmp_pkg_cond[tmp_cond_len] = '\0';
}
- tmp_pkg_ver = slapt_regex_extract_match(parse_dep_regex, dep_entry, 3);
+ tmp_pkg_ver = slapt_regex_t_extract_match(parse_dep_regex, dep_entry, 3);
- slapt_free_regex(parse_dep_regex);
+ slapt_regex_t_free(parse_dep_regex);
/*
check the newest version of tmp_pkg_name (in newest_installed_pkg)
@@ -1383,7 +1383,7 @@ static slapt_pkg_info_t *parse_meta_entry(slapt_vector_t *avail_pkgs, slapt_vect
}
}
- slapt_vector_t_foreach (slapt_pkg_info_t *, installed_pkg, installed_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, installed_pkg, installed_pkgs) {
if (strcmp(tmp_pkg_name, installed_pkg->name) != 0)
continue;
@@ -1442,7 +1442,7 @@ static slapt_pkg_info_t *parse_meta_entry(slapt_vector_t *avail_pkgs, slapt_vect
}
/* loop through avail_pkgs */
- slapt_vector_t_foreach (slapt_pkg_info_t *, avail_pkg, avail_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, avail_pkg, avail_pkgs) {
if (strcmp(tmp_pkg_name, avail_pkg->name) != 0)
continue;
@@ -1478,12 +1478,12 @@ static slapt_pkg_info_t *parse_meta_entry(slapt_vector_t *avail_pkgs, slapt_vect
return NULL;
}
-slapt_vector_t *slapt_is_required_by(const slapt_rc_config *global_config,
+slapt_vector_t *slapt_is_required_by(const slapt_config_t *global_config,
slapt_vector_t *avail,
slapt_vector_t *installed_pkgs,
slapt_vector_t *pkgs_to_install,
slapt_vector_t *pkgs_to_remove,
- slapt_pkg_info_t *pkg)
+ slapt_pkg_t *pkg)
{
slapt_vector_t *required_by_list = slapt_vector_t_init(NULL);
@@ -1496,7 +1496,7 @@ slapt_vector_t *slapt_is_required_by(const slapt_rc_config *global_config,
return required_by_list;
}
-static char *escape_package_name(slapt_pkg_info_t *pkg)
+static char *escape_package_name(slapt_pkg_t *pkg)
{
uint32_t name_len = 0, escape_count = 0, i;
char *escaped_name = NULL, *escaped_ptr;
@@ -1529,7 +1529,7 @@ static void required_by(slapt_vector_t *avail,
slapt_vector_t *installed_pkgs,
slapt_vector_t *pkgs_to_install,
slapt_vector_t *pkgs_to_remove,
- slapt_pkg_info_t *pkg,
+ slapt_pkg_t *pkg,
slapt_vector_t *required_by_list)
{
slapt_regex_t *required_by_reg = NULL;
@@ -1545,14 +1545,14 @@ static void required_by(slapt_vector_t *avail,
}
reg[reg_str_len - 1] = '\0';
- if ((required_by_reg = slapt_init_regex(reg)) == NULL) {
+ if ((required_by_reg = slapt_regex_t_init(reg)) == NULL) {
exit(EXIT_FAILURE);
}
free(pkg_name);
free(reg);
- slapt_vector_t_foreach (slapt_pkg_info_t *, avail_pkg, avail) {
+ slapt_vector_t_foreach (slapt_pkg_t *, avail_pkg, avail) {
slapt_vector_t *dep_list = NULL;
if (strcmp(avail_pkg->required, "") == 0)
@@ -1564,7 +1564,7 @@ static void required_by(slapt_vector_t *avail,
if (strstr(avail_pkg->required, pkg->name) == NULL)
continue;
- slapt_execute_regex(required_by_reg, avail_pkg->required);
+ slapt_regex_t_execute(required_by_reg, avail_pkg->required);
if (required_by_reg->reg_return != 0)
continue;
@@ -1592,7 +1592,7 @@ static void required_by(slapt_vector_t *avail,
/* we need to find out if we have something else that satisfies the dependency */
satisfies = slapt_parse_delimited_list(part, '|');
slapt_vector_t_foreach (char *, satisfies_part, satisfies) {
- slapt_pkg_info_t *tmp_pkg = parse_meta_entry(avail, installed_pkgs, satisfies_part);
+ slapt_pkg_t *tmp_pkg = parse_meta_entry(avail, installed_pkgs, satisfies_part);
if (tmp_pkg == NULL)
continue;
@@ -1624,12 +1624,12 @@ static void required_by(slapt_vector_t *avail,
slapt_vector_t_free(dep_list);
}
- slapt_free_regex(required_by_reg);
+ slapt_regex_t_free(required_by_reg);
}
-slapt_pkg_info_t *slapt_get_pkg_by_details(slapt_vector_t *list, const char *name, const char *version, const char *location)
+slapt_pkg_t *slapt_get_pkg_by_details(slapt_vector_t *list, const char *name, const char *version, const char *location)
{
- int idx = slapt_vector_t_index_of(list, by_details, &(slapt_pkg_info_t){.name = (char *)name, .version = (char *)version, .location = (char *)location});
+ int idx = slapt_vector_t_index_of(list, by_details, &(slapt_pkg_t){.name = (char *)name, .version = (char *)version, .location = (char *)location});
if (idx > -1) {
return list->items[idx];
}
@@ -1637,10 +1637,10 @@ slapt_pkg_info_t *slapt_get_pkg_by_details(slapt_vector_t *list, const char *nam
}
/* update package data from mirror url */
-int slapt_update_pkg_cache(const slapt_rc_config *global_config)
+int slapt_update_pkg_cache(const slapt_config_t *global_config)
{
bool source_dl_failed = false;
- slapt_vector_t *new_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_pkg);
+ slapt_vector_t *new_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_pkg_t_free);
/* go through each package source and download the meta data */
slapt_vector_t_foreach (slapt_source_t *, source, global_config->sources) {
@@ -1730,7 +1730,7 @@ int slapt_update_pkg_cache(const slapt_rc_config *global_config)
slapt_get_md5sums(available_pkgs, tmp_checksum_f);
- slapt_vector_t_foreach (slapt_pkg_info_t *, p, available_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, p, available_pkgs) {
int mirror_len = -1;
/* honor the mirror if it was set in the PACKAGES.TXT */
@@ -1750,7 +1750,7 @@ int slapt_update_pkg_cache(const slapt_rc_config *global_config)
if (patch_pkgs) {
slapt_get_md5sums(patch_pkgs, tmp_checksum_f);
- slapt_vector_t_foreach (slapt_pkg_info_t *, patch_pkg, patch_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, patch_pkg, patch_pkgs) {
int mirror_len = -1;
/* honor the mirror if it was set in the PACKAGES.TXT */
@@ -1794,7 +1794,7 @@ int slapt_update_pkg_cache(const slapt_rc_config *global_config)
if ((pkg_list_fh = slapt_open_file(SLAPT_PKG_LIST_L, "w+")) == NULL)
exit(EXIT_FAILURE);
- qsort(new_pkgs->items, new_pkgs->size, sizeof(new_pkgs->items[0]), slapt_pkg_info_t_qsort_cmp);
+ qsort(new_pkgs->items, new_pkgs->size, sizeof(new_pkgs->items[0]), slapt_pkg_t_qsort_cmp);
slapt_write_pkg_data(NULL, pkg_list_fh, new_pkgs);
@@ -1828,9 +1828,9 @@ bool slapt_pkg_sign_is_unauthenticated(slapt_code_t code)
}
#endif
-slapt_pkg_info_t *slapt_init_pkg(void)
+slapt_pkg_t *slapt_pkg_t_init(void)
{
- slapt_pkg_info_t *pkg;
+ slapt_pkg_t *pkg;
pkg = slapt_malloc(sizeof *pkg);
@@ -1865,7 +1865,7 @@ slapt_pkg_info_t *slapt_init_pkg(void)
}
/* generate the package file name */
-char *slapt_gen_pkg_file_name(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg)
+char *slapt_gen_pkg_file_name(const slapt_config_t *global_config, slapt_pkg_t *pkg)
{
char *file_name = NULL;
@@ -1885,7 +1885,7 @@ char *slapt_gen_pkg_file_name(const slapt_rc_config *global_config, slapt_pkg_in
}
/* generate the download url for a package */
-char *slapt_gen_pkg_url(slapt_pkg_info_t *pkg)
+char *slapt_gen_pkg_url(slapt_pkg_t *pkg)
{
char *url = NULL;
char *file_name = NULL;
@@ -1907,7 +1907,7 @@ char *slapt_gen_pkg_url(slapt_pkg_info_t *pkg)
}
/* find out the pkg file size (post download) */
-size_t slapt_get_pkg_file_size(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg)
+size_t slapt_get_pkg_file_size(const slapt_config_t *global_config, slapt_pkg_t *pkg)
{
char *file_name = NULL;
struct stat file_stat;
@@ -1925,7 +1925,7 @@ size_t slapt_get_pkg_file_size(const slapt_rc_config *global_config, slapt_pkg_i
}
/* package is already downloaded and cached, md5sum if applicable is ok */
-slapt_code_t slapt_verify_downloaded_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg)
+slapt_code_t slapt_verify_downloaded_pkg(const slapt_config_t *global_config, slapt_pkg_t *pkg)
{
char *file_name = NULL;
FILE *fh_test = NULL;
@@ -1994,7 +1994,7 @@ char *slapt_gen_filename_from_url(const char *url, const char *file)
return cleaned;
}
-void slapt_purge_old_cached_pkgs(const slapt_rc_config *global_config, const char *dir_name, slapt_vector_t *avail_pkgs)
+void slapt_purge_old_cached_pkgs(const slapt_config_t *global_config, const char *dir_name, slapt_vector_t *avail_pkgs)
{
DIR *dir;
struct dirent *file;
@@ -2010,7 +2010,7 @@ void slapt_purge_old_cached_pkgs(const slapt_rc_config *global_config, const cha
if (dir_name == NULL)
dir_name = (char *)global_config->working_dir;
- if ((cached_pkgs_regex = slapt_init_regex(SLAPT_PKG_PARSE_REGEX)) == NULL) {
+ if ((cached_pkgs_regex = slapt_regex_t_init(SLAPT_PKG_PARSE_REGEX)) == NULL) {
exit(EXIT_FAILURE);
}
@@ -2052,15 +2052,15 @@ void slapt_purge_old_cached_pkgs(const slapt_rc_config *global_config, const cha
/* if its a package */
if (strstr(file->d_name, ".t") != NULL) {
- slapt_execute_regex(cached_pkgs_regex, file->d_name);
+ slapt_regex_t_execute(cached_pkgs_regex, file->d_name);
/* if our regex matches */
if (cached_pkgs_regex->reg_return == 0) {
char *tmp_pkg_name, *tmp_pkg_version;
- slapt_pkg_info_t *tmp_pkg;
+ slapt_pkg_t *tmp_pkg;
- tmp_pkg_name = slapt_regex_extract_match(cached_pkgs_regex, file->d_name, 1);
- tmp_pkg_version = slapt_regex_extract_match(cached_pkgs_regex, file->d_name, 2);
+ tmp_pkg_name = slapt_regex_t_extract_match(cached_pkgs_regex, file->d_name, 1);
+ tmp_pkg_version = slapt_regex_t_extract_match(cached_pkgs_regex, file->d_name, 2);
tmp_pkg = slapt_get_exact_pkg(avail_pkgs, tmp_pkg_name, tmp_pkg_version);
free(tmp_pkg_name);
@@ -2080,7 +2080,7 @@ void slapt_purge_old_cached_pkgs(const slapt_rc_config *global_config, const cha
}
closedir(dir);
- slapt_free_regex(cached_pkgs_regex);
+ slapt_regex_t_free(cached_pkgs_regex);
if (local_pkg_list == 1) {
slapt_vector_t_free(avail_pkgs);
}
@@ -2104,7 +2104,7 @@ void slapt_clean_pkg_dir(const char *dir_name)
return;
}
- if ((cached_pkgs_regex = slapt_init_regex(SLAPT_PKG_PARSE_REGEX)) == NULL) {
+ if ((cached_pkgs_regex = slapt_regex_t_init(SLAPT_PKG_PARSE_REGEX)) == NULL) {
exit(EXIT_FAILURE);
}
@@ -2126,7 +2126,7 @@ void slapt_clean_pkg_dir(const char *dir_name)
continue;
}
if (strstr(file->d_name, ".t") != NULL) {
- slapt_execute_regex(cached_pkgs_regex, file->d_name);
+ slapt_regex_t_execute(cached_pkgs_regex, file->d_name);
/* if our regex matches */
if (cached_pkgs_regex->reg_return == 0) {
@@ -2136,17 +2136,17 @@ void slapt_clean_pkg_dir(const char *dir_name)
}
closedir(dir);
- slapt_free_regex(cached_pkgs_regex);
+ slapt_regex_t_free(cached_pkgs_regex);
}
/* find dependency from "or" requirement */
-static slapt_pkg_info_t *find_or_requirement(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, char *required_str)
+static slapt_pkg_t *find_or_requirement(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, char *required_str)
{
- slapt_pkg_info_t *pkg = NULL;
+ slapt_pkg_t *pkg = NULL;
slapt_vector_t *alternates = slapt_parse_delimited_list(required_str, '|');
slapt_vector_t_foreach (char *, alternate, alternates) {
- slapt_pkg_info_t *tmp_pkg = parse_meta_entry(avail_pkgs, installed_pkgs, alternate);
+ slapt_pkg_t *tmp_pkg = parse_meta_entry(avail_pkgs, installed_pkgs, alternate);
if (tmp_pkg != NULL) {
/* installed packages are preferred */
@@ -2166,7 +2166,7 @@ static slapt_pkg_info_t *find_or_requirement(slapt_vector_t *avail_pkgs, slapt_v
return pkg;
}
-slapt_pkg_info_t *slapt_copy_pkg(slapt_pkg_info_t *dst, slapt_pkg_info_t *src)
+slapt_pkg_t *slapt_copy_pkg(slapt_pkg_t *dst, slapt_pkg_t *src)
{
if (dst == NULL) {
dst = slapt_malloc(sizeof *dst);
@@ -2241,7 +2241,7 @@ static FILE *slapt_gunzip_file(const char *file_name, FILE *dest_file)
return dest_file;
}
-slapt_vector_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_config, const char *url, bool *compressed)
+slapt_vector_t *slapt_get_pkg_source_packages(const slapt_config_t *global_config, const char *url, bool *compressed)
{
slapt_vector_t *available_pkgs = NULL;
char *pkg_head = NULL;
@@ -2432,7 +2432,7 @@ slapt_vector_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_conf
return available_pkgs;
}
-slapt_vector_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_config, const char *url, bool *compressed)
+slapt_vector_t *slapt_get_pkg_source_patches(const slapt_config_t *global_config, const char *url, bool *compressed)
{
slapt_vector_t *patch_pkgs = NULL;
char *patch_head = NULL;
@@ -2571,7 +2571,7 @@ slapt_vector_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_confi
return patch_pkgs;
}
-FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config, const char *url, bool *compressed)
+FILE *slapt_get_pkg_source_checksums(const slapt_config_t *global_config, const char *url, bool *compressed)
{
FILE *tmp_checksum_f = NULL;
char *checksum_head = NULL;
@@ -2700,7 +2700,7 @@ FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config, const
return tmp_checksum_f;
}
-bool slapt_get_pkg_source_changelog(const slapt_rc_config *global_config, const char *url, bool *compressed)
+bool slapt_get_pkg_source_changelog(const slapt_config_t *global_config, const char *url, bool *compressed)
{
char *changelog_head = NULL;
char *filename = NULL;
@@ -2801,7 +2801,7 @@ void slapt_clean_description(char *description, const char *name)
}
/* retrieve the packages changelog entry, if any. Returns NULL otherwise */
-char *slapt_get_pkg_changelog(const slapt_pkg_info_t *pkg)
+char *slapt_get_pkg_changelog(const slapt_pkg_t *pkg)
{
char *filename = slapt_gen_filename_from_url(pkg->mirror, SLAPT_CHANGELOG_FILE);
FILE *working_changelog_f = NULL;
@@ -2903,7 +2903,7 @@ char *slapt_get_pkg_changelog(const slapt_pkg_info_t *pkg)
return changelog;
}
-char *slapt_stringify_pkg(const slapt_pkg_info_t *pkg)
+char *slapt_stringify_pkg(const slapt_pkg_t *pkg)
{
char *pkg_str = NULL;
int pkg_str_len = 0;
@@ -2921,20 +2921,20 @@ char *slapt_stringify_pkg(const slapt_pkg_info_t *pkg)
}
slapt_vector_t *
-slapt_get_obsolete_pkgs(const slapt_rc_config *global_config, slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs)
+slapt_get_obsolete_pkgs(const slapt_config_t *global_config, slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs)
{
slapt_vector_t *obsolete = slapt_vector_t_init(NULL);
slapt_vector_t *to_install = slapt_vector_t_init(NULL);
slapt_vector_t *to_remove = slapt_vector_t_init(NULL);
- slapt_vector_t_foreach (slapt_pkg_info_t *, p, installed_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, p, installed_pkgs) {
/* if we can't find the installed package in our available pkg list, it must be obsolete */
if (slapt_get_newest_pkg(avail_pkgs, p->name) == NULL) {
/* any packages that require this package we are about to remove should be scheduled to remove as well */
slapt_vector_t *deps = slapt_is_required_by(global_config, avail_pkgs, installed_pkgs, to_install, to_remove, p);
- slapt_vector_t_foreach (slapt_pkg_info_t *, dep, deps) {
- slapt_pkg_info_t *installed_dep = slapt_get_exact_pkg(installed_pkgs, dep->name, dep->version);
+ slapt_vector_t_foreach (slapt_pkg_t *, dep, deps) {
+ slapt_pkg_t *installed_dep = slapt_get_exact_pkg(installed_pkgs, dep->name, dep->version);
/* if it is installed, we add it to the list */
if (installed_dep != NULL) {
@@ -2953,12 +2953,12 @@ slapt_get_obsolete_pkgs(const slapt_rc_config *global_config, slapt_vector_t *av
return obsolete;
}
-int slapt_pkg_info_t_qsort_cmp(const void *a, const void *b)
+int slapt_pkg_t_qsort_cmp(const void *a, const void *b)
{
int cmp = 0;
- slapt_pkg_info_t *pkg_a = *(slapt_pkg_info_t *const *)a;
- slapt_pkg_info_t *pkg_b = *(slapt_pkg_info_t *const *)b;
+ slapt_pkg_t *pkg_a = *(slapt_pkg_t *const *)a;
+ slapt_pkg_t *pkg_b = *(slapt_pkg_t *const *)b;
if (!pkg_a->name || !pkg_b->name)
return cmp;
@@ -2980,7 +2980,7 @@ int slapt_pkg_info_t_qsort_cmp(const void *a, const void *b)
}
}
-char *slapt_get_pkg_filelist(const slapt_pkg_info_t *pkg)
+char *slapt_get_pkg_filelist(const slapt_pkg_t *pkg)
{
FILE *pkg_f = NULL;
char *pkg_log_dirname = NULL;
@@ -3139,7 +3139,7 @@ char *slapt_gen_package_log_dir_name(void)
return pkg_log_dirname;
}
-slapt_pkg_upgrade_t *slapt_pkg_upgrade_t_init(slapt_pkg_info_t *i, slapt_pkg_info_t *u)
+slapt_pkg_upgrade_t *slapt_pkg_upgrade_t_init(slapt_pkg_t *i, slapt_pkg_t *u)
{
slapt_pkg_upgrade_t *upgrade = NULL;
upgrade = slapt_malloc(sizeof *upgrade);
@@ -3150,7 +3150,7 @@ slapt_pkg_upgrade_t *slapt_pkg_upgrade_t_init(slapt_pkg_info_t *i, slapt_pkg_inf
void slapt_pkg_upgrade_t_free(slapt_pkg_upgrade_t *upgrade)
{
- slapt_free_pkg(upgrade->installed);
- slapt_free_pkg(upgrade->upgrade);
+ slapt_pkg_t_free(upgrade->installed);
+ slapt_pkg_t_free(upgrade->upgrade);
free(upgrade);
}
diff --git a/src/package.h b/src/package.h
index e7191fe..03b807e 100644
--- a/src/package.h
+++ b/src/package.h
@@ -67,14 +67,14 @@ typedef struct {
uint32_t size_u;
uint32_t priority;
bool installed;
-} slapt_pkg_info_t;
+} slapt_pkg_t;
typedef struct {
- slapt_pkg_info_t *installed;
- slapt_pkg_info_t *upgrade;
+ slapt_pkg_t *installed;
+ slapt_pkg_t *upgrade;
} slapt_pkg_upgrade_t;
-slapt_pkg_upgrade_t *slapt_pkg_upgrade_t_init(slapt_pkg_info_t *, slapt_pkg_info_t *);
+slapt_pkg_upgrade_t *slapt_pkg_upgrade_t_init(slapt_pkg_t *, slapt_pkg_t *);
void slapt_pkg_upgrade_t_free(slapt_pkg_upgrade_t *);
typedef struct {
@@ -86,14 +86,14 @@ slapt_pkg_err_t *slapt_pkg_err_t_init(char *, char *);
void slapt_pkg_err_t_free(slapt_pkg_err_t *);
/* returns an empty package structure */
-slapt_pkg_info_t *slapt_init_pkg(void);
+slapt_pkg_t *slapt_pkg_t_init(void);
/* frees the package structure */
-void slapt_free_pkg(slapt_pkg_info_t *pkg);
+void slapt_pkg_t_free(slapt_pkg_t *pkg);
/*
update the local package cache. Must be chdir'd to working_dir.
*/
-int slapt_update_pkg_cache(const slapt_rc_config *global_config);
+int slapt_update_pkg_cache(const slapt_config_t *global_config);
/* write pkg data to disk */
void slapt_write_pkg_data(const char *source_url, FILE *d_file, slapt_vector_t *pkgs);
/* parse the PACKAGES.TXT file */
@@ -108,40 +108,40 @@ slapt_vector_t *slapt_get_available_pkgs(void);
slapt_vector_t *slapt_get_installed_pkgs(void);
/* retrieve the newest package from package list */
-slapt_pkg_info_t *slapt_get_newest_pkg(slapt_vector_t *, const char *);
+slapt_pkg_t *slapt_get_newest_pkg(slapt_vector_t *, const char *);
/* get the exact package */
-slapt_pkg_info_t *slapt_get_exact_pkg(slapt_vector_t *list, const char *name, const char *version);
+slapt_pkg_t *slapt_get_exact_pkg(slapt_vector_t *list, const char *name, const char *version);
/* lookup package by details */
-slapt_pkg_info_t *slapt_get_pkg_by_details(slapt_vector_t *list, const char *name, const char *version, const char *location);
+slapt_pkg_t *slapt_get_pkg_by_details(slapt_vector_t *list, const char *name, const char *version, const char *location);
/* search package list with pattern */
slapt_vector_t *slapt_search_pkg_list(slapt_vector_t *list, const char *pattern);
/* install package by calling installpkg, returns 0 on success, -1 on error */
-int slapt_install_pkg(const slapt_rc_config *, slapt_pkg_info_t *);
+int slapt_install_pkg(const slapt_config_t *, slapt_pkg_t *);
/* upgrade package by calling upgradepkg, returns 0 on success, -1 on error */
-int slapt_upgrade_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg);
+int slapt_upgrade_pkg(const slapt_config_t *global_config, slapt_pkg_t *pkg);
/* remove package by calling removepkg, returns 0 on success, -1 on error */
-int slapt_remove_pkg(const slapt_rc_config *, slapt_pkg_info_t *);
+int slapt_remove_pkg(const slapt_config_t *, slapt_pkg_t *);
/* get a list of obsolete packages */
-slapt_vector_t *slapt_get_obsolete_pkgs(const slapt_rc_config *global_config, slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs);
+slapt_vector_t *slapt_get_obsolete_pkgs(const slapt_config_t *global_config, slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs);
/* generate a short description, returns (char *) on success or NULL on error, caller responsible for freeing the returned data */
-char *slapt_gen_short_pkg_description(slapt_pkg_info_t *);
+char *slapt_gen_short_pkg_description(slapt_pkg_t *);
/* generate the filename from the url, caller responsible for freeing the returned data */
char *slapt_gen_filename_from_url(const char *url, const char *file);
/* generate the package file name, caller responsible for freeing the returned data */
-char *slapt_gen_pkg_file_name(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg);
+char *slapt_gen_pkg_file_name(const slapt_config_t *global_config, slapt_pkg_t *pkg);
/* generate the download url for a package, caller responsible for freeing the returned data */
-char *slapt_gen_pkg_url(slapt_pkg_info_t *pkg);
+char *slapt_gen_pkg_url(slapt_pkg_t *pkg);
/* exclude pkg based on pkg name, returns 1 if package is present in the exclude list, 0 if not present */
-bool slapt_is_excluded(const slapt_rc_config *, slapt_pkg_info_t *);
+bool slapt_is_excluded(const slapt_config_t *, slapt_pkg_t *);
/* package is already downloaded and cached, md5sum if applicable is ok, returns slapt_code_t. */
-slapt_code_t slapt_verify_downloaded_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg);
+slapt_code_t slapt_verify_downloaded_pkg(const slapt_config_t *global_config, slapt_pkg_t *pkg);
/* fill in the md5sum of the package */
void slapt_get_md5sums(slapt_vector_t *pkgs, FILE *checksum_file);
/* find out the pkg file size (post download) */
-size_t slapt_get_pkg_file_size(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg);
+size_t slapt_get_pkg_file_size(const slapt_config_t *global_config, slapt_pkg_t *pkg);
/* compare package versions,
returns just like strcmp,
@@ -150,29 +150,29 @@ size_t slapt_get_pkg_file_size(const slapt_rc_config *global_config, slapt_pkg_i
0 if a and b are equal
*/
int slapt_cmp_pkg_versions(const char *a, const char *b);
-int slapt_cmp_pkgs(slapt_pkg_info_t *a, slapt_pkg_info_t *b);
+int slapt_cmp_pkgs(slapt_pkg_t *a, slapt_pkg_t *b);
/*
resolve dependencies
returns 0 on success, -1 on error setting conflict_err and missing_err
(usually called with transaction->conflict_err and transaction->missing_err)
*/
-int slapt_get_pkg_dependencies(const slapt_rc_config *global_config,
+int slapt_get_pkg_dependencies(const slapt_config_t *global_config,
slapt_vector_t *avail_pkgs,
slapt_vector_t *installed_pkgs,
- slapt_pkg_info_t *pkg,
+ slapt_pkg_t *pkg,
slapt_vector_t *deps,
slapt_vector_t *conflict_err,
slapt_vector_t *missing_err);
/* return list of package conflicts */
-slapt_vector_t *slapt_get_pkg_conflicts(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, slapt_pkg_info_t *pkg);
+slapt_vector_t *slapt_get_pkg_conflicts(slapt_vector_t *avail_pkgs, slapt_vector_t *installed_pkgs, slapt_pkg_t *pkg);
/* return list of packages required by */
-slapt_vector_t *slapt_is_required_by(const slapt_rc_config *global_config,
+slapt_vector_t *slapt_is_required_by(const slapt_config_t *global_config,
slapt_vector_t *avail,
slapt_vector_t *installed_pkgs,
slapt_vector_t *pkgs_to_install,
slapt_vector_t *pkgs_to_remove,
- slapt_pkg_info_t *pkg);
+ slapt_pkg_t *pkg);
/* empty packages from cache dir */
void slapt_clean_pkg_dir(const char *dir_name);
@@ -180,34 +180,34 @@ void slapt_clean_pkg_dir(const char *dir_name);
clean out old outdated packages in the cache that are no longer available
in the current source lists (ie are not downloadable)
*/
-void slapt_purge_old_cached_pkgs(const slapt_rc_config *global_config, const char *dir_name, slapt_vector_t *avail_pkgs);
+void slapt_purge_old_cached_pkgs(const slapt_config_t *global_config, const char *dir_name, slapt_vector_t *avail_pkgs);
/* make a copy of a package (needs to be freed with free_pkg) */
-slapt_pkg_info_t *slapt_copy_pkg(slapt_pkg_info_t *dst, slapt_pkg_info_t *src);
+slapt_pkg_t *slapt_copy_pkg(slapt_pkg_t *dst, slapt_pkg_t *src);
/*
download the PACKAGES.TXT and CHECKSUMS.md5 files
compressed is set if the compressed version was downloaded.
*/
-slapt_vector_t *slapt_get_pkg_source_packages(const slapt_rc_config *global_config, const char *url, bool *compressed);
-slapt_vector_t *slapt_get_pkg_source_patches(const slapt_rc_config *global_config, const char *url, bool *compressed);
-FILE *slapt_get_pkg_source_checksums(const slapt_rc_config *global_config, const char *url, bool *compressed);
-bool slapt_get_pkg_source_changelog(const slapt_rc_config *global_config, const char *url, bool *compressed);
+slapt_vector_t *slapt_get_pkg_source_packages(const slapt_config_t *global_config, const char *url, bool *compressed);
+slapt_vector_t *slapt_get_pkg_source_patches(const slapt_config_t *global_config, const char *url, bool *compressed);
+FILE *slapt_get_pkg_source_checksums(const slapt_config_t *global_config, const char *url, bool *compressed);
+bool slapt_get_pkg_source_changelog(const slapt_config_t *global_config, const char *url, bool *compressed);
/* clean package name from package description */
void slapt_clean_description(char *description, const char *name);
/* retrieve the packages changelog entry, if any. Returns NULL otherwise, Must be chdir'd to working_dir. */
-char *slapt_get_pkg_changelog(const slapt_pkg_info_t *pkg);
+char *slapt_get_pkg_changelog(const slapt_pkg_t *pkg);
/* returns a string representation of the package */
-char *slapt_stringify_pkg(const slapt_pkg_info_t *pkg);
+char *slapt_stringify_pkg(const slapt_pkg_t *pkg);
/*
get the package filelist, returns (char *) on success or NULL on error
caller responsible for freeing the returned data
*/
-char *slapt_get_pkg_filelist(const slapt_pkg_info_t *pkg);
+char *slapt_get_pkg_filelist(const slapt_pkg_t *pkg);
/*
generate the directory name for the package log directory,
@@ -217,4 +217,4 @@ char *slapt_get_pkg_filelist(const slapt_pkg_info_t *pkg);
char *slapt_gen_package_log_dir_name(void);
/* used by qsort */
-int slapt_pkg_info_t_qsort_cmp(const void *a, const void *b);
+int slapt_pkg_t_qsort_cmp(const void *a, const void *b);
diff --git a/src/slaptcurl.c b/src/slaptcurl.c
index 935efd4..86d9ad9 100644
--- a/src/slaptcurl.c
+++ b/src/slaptcurl.c
@@ -24,7 +24,7 @@ struct head_data_t {
size_t size;
};
-int slapt_download_data(FILE *fh, const char *url, size_t bytes, long *filetime, const slapt_rc_config *global_config)
+int slapt_download_data(FILE *fh, const char *url, size_t bytes, long *filetime, const slapt_config_t *global_config)
{
CURL *ch = NULL;
CURLcode response;
@@ -156,7 +156,7 @@ char *slapt_head_request(const char *url)
return head_t.data;
}
-const char *slapt_get_mirror_data_from_source(FILE *fh, const slapt_rc_config *global_config, const char *base_url, const char *filename)
+const char *slapt_get_mirror_data_from_source(FILE *fh, const slapt_config_t *global_config, const char *base_url, const char *filename)
{
int return_code = 0;
char *url = NULL;
@@ -176,7 +176,7 @@ const char *slapt_get_mirror_data_from_source(FILE *fh, const slapt_rc_config *g
return return_code != 0 ? curl_easy_strerror(return_code) : NULL;
}
-const char *slapt_download_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg, const char *note)
+const char *slapt_download_pkg(const slapt_config_t *global_config, slapt_pkg_t *pkg, const char *note)
{
FILE *fh = NULL;
char *file_name = NULL;
diff --git a/src/slaptcurl.h b/src/slaptcurl.h
index bc05c58..5c456d4 100644
--- a/src/slaptcurl.h
+++ b/src/slaptcurl.h
@@ -19,16 +19,16 @@
#define SLAPT_NO_SSL_VERIFYPEER "SLAPT_NO_SSL_VERIFYPEER"
/* download data to file, resuming from bytes and preserving filetime. returns curl code */
-int slapt_download_data(FILE *fh, const char *url, size_t bytes, long *filetime, const slapt_rc_config *global_config);
+int slapt_download_data(FILE *fh, const char *url, size_t bytes, long *filetime, const slapt_config_t *global_config);
/* retrieves the head data for the url, returns (char *) or NULL on error */
char *slapt_head_request(const char *url);
/* this fills FILE with data from url, used for PACKAGES.TXT and CHECKSUMS Returns error on failure. */
-const char *slapt_get_mirror_data_from_source(FILE *fh, const slapt_rc_config *global_config, const char *base_url, const char *filename);
+const char *slapt_get_mirror_data_from_source(FILE *fh, const slapt_config_t *global_config, const char *base_url, const char *filename);
/* download pkg, calls download_data. returns error on failure. */
-const char *slapt_download_pkg(const slapt_rc_config *global_config, slapt_pkg_info_t *pkg, const char *note);
+const char *slapt_download_pkg(const slapt_config_t *global_config, slapt_pkg_t *pkg, const char *note);
/* this is the default progress callback if global_config->progress_cb == NULL */
int slapt_progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
diff --git a/src/slaptgpgme.c b/src/slaptgpgme.c
index 4f5ac09..e5381a2 100644
--- a/src/slaptgpgme.c
+++ b/src/slaptgpgme.c
@@ -49,7 +49,7 @@ static void _slapt_free_gpgme_ctx(gpgme_ctx_t *ctx)
free(ctx);
}
-FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_config, const char *url, bool *compressed)
+FILE *slapt_get_pkg_source_checksums_signature(const slapt_config_t *global_config, const char *url, bool *compressed)
{
FILE *tmp_checksum_f = NULL;
char *checksum_head = NULL;
@@ -127,7 +127,7 @@ FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_con
return tmp_checksum_f;
}
-FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config, const char *url, bool *compressed)
+FILE *slapt_get_pkg_source_gpg_key(const slapt_config_t *global_config, const char *url, bool *compressed)
{
FILE *tmp_key_f = NULL;
char *key_head = NULL;
diff --git a/src/slaptgpgme.h b/src/slaptgpgme.h
index 072f25b..689b35f 100644
--- a/src/slaptgpgme.h
+++ b/src/slaptgpgme.h
@@ -27,9 +27,9 @@
#define SLAPT_CHECKSUM_ASC_FILE_GZ "CHECKSUMS.md5.gz.asc"
/* retrieve the signature of the CHECKSUMS.md5 file */
-FILE *slapt_get_pkg_source_checksums_signature(const slapt_rc_config *global_config, const char *url, bool *compressed);
+FILE *slapt_get_pkg_source_checksums_signature(const slapt_config_t *global_config, const char *url, bool *compressed);
/* retrieve the package sources GPG-KEY */
-FILE *slapt_get_pkg_source_gpg_key(const slapt_rc_config *global_config, const char *url, bool *compressed);
+FILE *slapt_get_pkg_source_gpg_key(const slapt_config_t *global_config, const char *url, bool *compressed);
/* Add the GPG-KEY to the local keyring */
slapt_code_t slapt_add_pkg_source_gpg_key(FILE *key);
/* Verify the signature is valid for the checksum file */
diff --git a/src/transaction.c b/src/transaction.c
index a937523..1ade7bd 100644
--- a/src/transaction.c
+++ b/src/transaction.c
@@ -20,17 +20,17 @@
#define SLAPT_PKG_DL_NOTE_LEN 16
-static void add_suggestion(slapt_transaction_t *tran, slapt_pkg_info_t *pkg);
+static void add_suggestion(slapt_transaction_t *tran, slapt_pkg_t *pkg);
slapt_transaction_t *slapt_init_transaction(void)
{
slapt_transaction_t *tran = slapt_malloc(sizeof *tran);
- tran->install_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_pkg);
+ tran->install_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_pkg_t_free);
- tran->remove_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_pkg);
+ tran->remove_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_pkg_t_free);
- tran->exclude_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_free_pkg);
+ tran->exclude_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_pkg_t_free);
tran->upgrade_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_pkg_upgrade_t_free);
tran->reinstall_pkgs = slapt_vector_t_init((slapt_vector_t_free_function)slapt_pkg_upgrade_t_free);
@@ -45,7 +45,7 @@ slapt_transaction_t *slapt_init_transaction(void)
return tran;
}
-slapt_queue_i *slapt_queue_i_init(slapt_pkg_info_t *i, slapt_pkg_upgrade_t *u)
+slapt_queue_i *slapt_queue_i_init(slapt_pkg_t *i, slapt_pkg_upgrade_t *u)
{
slapt_queue_i *qi = NULL;
qi = slapt_malloc(sizeof *qi);
@@ -54,10 +54,10 @@ slapt_queue_i *slapt_queue_i_init(slapt_pkg_info_t *i, slapt_pkg_upgrade_t *u)
}
if (i) {
qi->pkg.i = i;
- qi->type = INSTALL;
+ qi->type = SLAPT_ACTION_INSTALL;
} else if (u) {
qi->pkg.u = u;
- qi->type = UPGRADE;
+ qi->type = SLAPT_ACTION_UPGRADE;
}
return qi;
}
@@ -67,7 +67,7 @@ void slapt_queue_i_free(slapt_queue_i *qi)
free(qi);
}
-int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transaction_t *tran)
+int slapt_handle_transaction(const slapt_config_t *global_config, slapt_transaction_t *tran)
{
uint32_t pkg_dl_count = 0, dl_counter = 0, len = 0;
double download_size = 0;
@@ -96,7 +96,7 @@ int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transac
printf(" ");
len = 0;
- slapt_vector_t_foreach (slapt_pkg_info_t *, e, tran->exclude_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, e, tran->exclude_pkgs) {
if (len + strlen(e->name) + 1 < MAX_LINE_LEN) {
printf("%s ", e->name);
len += strlen(e->name) + 1;
@@ -138,7 +138,7 @@ int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transac
printf(" ");
len = 0;
- slapt_vector_t_foreach (slapt_pkg_info_t *, p, tran->install_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, p, tran->install_pkgs) {
size_t existing_file_size = 0;
if (len + strlen(p->name) + 1 < MAX_LINE_LEN) {
@@ -167,7 +167,7 @@ int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transac
printf(" ");
len = 0;
- slapt_vector_t_foreach (slapt_pkg_info_t *, r, tran->remove_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, r, tran->remove_pkgs) {
if (len + strlen(r->name) + 1 < MAX_LINE_LEN) {
printf("%s ", r->name);
len += strlen(r->name) + 1;
@@ -189,8 +189,8 @@ int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transac
len = 0;
slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade, tran->upgrade_pkgs) {
- slapt_pkg_info_t *u = upgrade->upgrade;
- slapt_pkg_info_t *p = upgrade->installed;
+ slapt_pkg_t *u = upgrade->upgrade;
+ slapt_pkg_t *p = upgrade->installed;
int line_len = len + strlen(u->name) + 1;
size_t existing_file_size = slapt_get_pkg_file_size(global_config, u) / 1024;
@@ -217,8 +217,8 @@ int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transac
len = 0;
slapt_vector_t_foreach (slapt_pkg_upgrade_t *, reinstall_upgrade, tran->reinstall_pkgs) {
- slapt_pkg_info_t *u = reinstall_upgrade->upgrade;
- slapt_pkg_info_t *p = reinstall_upgrade->installed;
+ slapt_pkg_t *u = reinstall_upgrade->upgrade;
+ slapt_pkg_t *p = reinstall_upgrade->installed;
int line_len = len + strlen(u->name) + 1;
size_t existing_file_size = slapt_get_pkg_file_size(global_config, u) / 1024;
@@ -316,21 +316,21 @@ int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transac
}
if (global_config->print_uris) {
- slapt_vector_t_foreach (slapt_pkg_info_t *, info, tran->install_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, info, tran->install_pkgs) {
const char *location = info->location + strspn(info->location, "./");
printf("%s%s/%s-%s%s\n",
info->mirror, location, info->name,
info->version, info->file_ext);
}
slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade, tran->upgrade_pkgs) {
- const slapt_pkg_info_t *upgrade_info = upgrade->upgrade;
+ const slapt_pkg_t *upgrade_info = upgrade->upgrade;
const char *location = upgrade_info->location + strspn(upgrade_info->location, "./");
printf("%s%s/%s-%s%s\n",
upgrade_info->mirror, location, upgrade_info->name,
upgrade_info->version, upgrade_info->file_ext);
}
slapt_vector_t_foreach (slapt_pkg_upgrade_t *, reinstall, tran->reinstall_pkgs) {
- const slapt_pkg_info_t *upgrade_info = reinstall->upgrade;
+ const slapt_pkg_t *upgrade_info = reinstall->upgrade;
const char *location = upgrade_info->location + strspn(upgrade_info->location, "./");
printf("%s%s/%s-%s%s\n",
upgrade_info->mirror, location, upgrade_info->name,
@@ -341,16 +341,16 @@ int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transac
/* if simulate is requested, just show what could happen and return */
if (global_config->simulate) {
- slapt_vector_t_foreach (slapt_pkg_info_t *, r, tran->remove_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, r, tran->remove_pkgs) {
printf(gettext("%s-%s is to be removed\n"), r->name, r->version);
}
slapt_vector_t_foreach (slapt_queue_i *, q, tran->queue) {
- if (q->type == INSTALL) {
+ if (q->type == SLAPT_ACTION_INSTALL) {
printf(gettext("%s-%s is to be installed\n"),
q->pkg.i->name,
q->pkg.i->version);
- } else if (q->type == UPGRADE) {
+ } else if (q->type == SLAPT_ACTION_UPGRADE) {
printf(gettext("%s-%s is to be upgraded to version %s\n"),
q->pkg.u->upgrade->name,
q->pkg.u->installed->version,
@@ -367,7 +367,7 @@ int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transac
pkg_dl_count = tran->install_pkgs->size + tran->upgrade_pkgs->size + tran->reinstall_pkgs->size;
/* download pkgs */
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, tran->install_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, tran->install_pkgs) {
bool failed = true;
++dl_counter;
@@ -432,19 +432,19 @@ int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transac
/* run transaction, remove, install, and upgrade */
if (global_config->download_only == false) {
- slapt_vector_t_foreach (slapt_pkg_info_t *, remove_pkg, tran->remove_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, remove_pkg, tran->remove_pkgs) {
if (slapt_remove_pkg(global_config, remove_pkg) == -1) {
exit(EXIT_FAILURE);
}
}
slapt_vector_t_foreach (slapt_queue_i *, q, tran->queue) {
- if (q->type == INSTALL) {
+ if (q->type == SLAPT_ACTION_INSTALL) {
printf(gettext("Preparing to install %s-%s\n"), q->pkg.i->name, q->pkg.i->version);
if (slapt_install_pkg(global_config, q->pkg.i) == -1) {
exit(EXIT_FAILURE);
}
- } else if (q->type == UPGRADE) {
+ } else if (q->type == SLAPT_ACTION_UPGRADE) {
printf(gettext("Preparing to replace %s-%s with %s-%s\n"),
q->pkg.u->upgrade->name,
q->pkg.u->installed->version,
@@ -462,58 +462,58 @@ int slapt_handle_transaction(const slapt_rc_config *global_config, slapt_transac
return 0;
}
-void slapt_add_install_to_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
+void slapt_add_install_to_transaction(slapt_transaction_t *tran, slapt_pkg_t *pkg)
{
/* don't add if already present in the transaction */
if (slapt_search_transaction_by_pkg(tran, pkg))
return;
- slapt_pkg_info_t *i = slapt_copy_pkg(NULL, pkg);
+ slapt_pkg_t *i = slapt_copy_pkg(NULL, pkg);
slapt_vector_t_add(tran->install_pkgs, i);
slapt_vector_t_add(tran->queue, slapt_queue_i_init(tran->install_pkgs->items[tran->install_pkgs->size - 1], NULL));
}
-void slapt_add_remove_to_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
+void slapt_add_remove_to_transaction(slapt_transaction_t *tran, slapt_pkg_t *pkg)
{
/* don't add if already present in the transaction */
if (slapt_search_transaction_by_pkg(tran, pkg))
return;
- slapt_pkg_info_t *r = slapt_copy_pkg(NULL, pkg);
+ slapt_pkg_t *r = slapt_copy_pkg(NULL, pkg);
slapt_vector_t_add(tran->remove_pkgs, r);
}
-void slapt_add_exclude_to_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
+void slapt_add_exclude_to_transaction(slapt_transaction_t *tran, slapt_pkg_t *pkg)
{
/* don't add if already present in the transaction */
if (slapt_search_transaction_by_pkg(tran, pkg))
return;
- slapt_pkg_info_t *e = slapt_copy_pkg(NULL, pkg);
+ slapt_pkg_t *e = slapt_copy_pkg(NULL, pkg);
slapt_vector_t_add(tran->exclude_pkgs, e);
}
-void slapt_add_reinstall_to_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *installed_pkg, slapt_pkg_info_t *slapt_upgrade_pkg)
+void slapt_add_reinstall_to_transaction(slapt_transaction_t *tran, slapt_pkg_t *installed_pkg, slapt_pkg_t *slapt_upgrade_pkg)
{
/* don't add if already present in the transaction */
if (slapt_search_transaction_by_pkg(tran, slapt_upgrade_pkg))
return;
- slapt_pkg_info_t *i = slapt_copy_pkg(NULL, installed_pkg);
- slapt_pkg_info_t *u = slapt_copy_pkg(NULL, slapt_upgrade_pkg);
+ slapt_pkg_t *i = slapt_copy_pkg(NULL, installed_pkg);
+ slapt_pkg_t *u = slapt_copy_pkg(NULL, slapt_upgrade_pkg);
slapt_vector_t_add(tran->reinstall_pkgs, slapt_pkg_upgrade_t_init(i, u));
slapt_vector_t_add(tran->queue, slapt_queue_i_init(NULL, tran->reinstall_pkgs->items[tran->reinstall_pkgs->size - 1]));
}
-void slapt_add_upgrade_to_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *installed_pkg, slapt_pkg_info_t *slapt_upgrade_pkg)
+void slapt_add_upgrade_to_transaction(slapt_transaction_t *tran, slapt_pkg_t *installed_pkg, slapt_pkg_t *slapt_upgrade_pkg)
{
/* don't add if already present in the transaction */
if (slapt_search_transaction_by_pkg(tran, slapt_upgrade_pkg))
return;
- slapt_pkg_info_t *i = slapt_copy_pkg(NULL, installed_pkg);
- slapt_pkg_info_t *u = slapt_copy_pkg(NULL, slapt_upgrade_pkg);
+ slapt_pkg_t *i = slapt_copy_pkg(NULL, installed_pkg);
+ slapt_pkg_t *u = slapt_copy_pkg(NULL, slapt_upgrade_pkg);
slapt_vector_t_add(tran->upgrade_pkgs, slapt_pkg_upgrade_t_init(i, u));
slapt_vector_t_add(tran->queue, slapt_queue_i_init(NULL, tran->upgrade_pkgs->items[tran->upgrade_pkgs->size - 1]));
@@ -521,7 +521,7 @@ void slapt_add_upgrade_to_transaction(slapt_transaction_t *tran, slapt_pkg_info_
bool slapt_search_transaction(slapt_transaction_t *tran, char *pkg_name)
{
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, tran->install_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, tran->install_pkgs) {
if (strcmp(pkg_name, pkg->name) == 0)
return true;
}
@@ -536,12 +536,12 @@ bool slapt_search_transaction(slapt_transaction_t *tran, char *pkg_name)
return true;
}
- slapt_vector_t_foreach (slapt_pkg_info_t *, remove_pkg, tran->remove_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, remove_pkg, tran->remove_pkgs) {
if (strcmp(pkg_name, remove_pkg->name) == 0)
return true;
}
- slapt_vector_t_foreach (slapt_pkg_info_t *, exclude_pkg, tran->exclude_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, exclude_pkg, tran->exclude_pkgs) {
if (strcmp(pkg_name, exclude_pkg->name) == 0)
return true;
}
@@ -549,7 +549,7 @@ bool slapt_search_transaction(slapt_transaction_t *tran, char *pkg_name)
return false;
}
-bool slapt_search_upgrade_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
+bool slapt_search_upgrade_transaction(slapt_transaction_t *tran, slapt_pkg_t *pkg)
{
slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade, tran->upgrade_pkgs) {
if (strcmp(pkg->name, upgrade->upgrade->name) == 0)
@@ -574,7 +574,7 @@ void slapt_free_transaction(slapt_transaction_t *tran)
free(tran);
}
-slapt_transaction_t *slapt_remove_from_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
+slapt_transaction_t *slapt_remove_from_transaction(slapt_transaction_t *tran, slapt_pkg_t *pkg)
{
slapt_transaction_t *new_tran = NULL;
@@ -589,7 +589,7 @@ slapt_transaction_t *slapt_remove_from_transaction(slapt_transaction_t *tran, sl
new_tran->exclude_pkgs = slapt_malloc(sizeof *new_tran->exclude_pkgs);
new_tran = slapt_init_transaction();
- slapt_vector_t_foreach (slapt_pkg_info_t *, installed_pkg, tran->install_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, installed_pkg, tran->install_pkgs) {
if (strcmp(pkg->name, installed_pkg->name) == 0 &&
strcmp(pkg->version, installed_pkg->version) == 0 &&
strcmp(pkg->location, installed_pkg->location) == 0) {
@@ -599,7 +599,7 @@ slapt_transaction_t *slapt_remove_from_transaction(slapt_transaction_t *tran, sl
slapt_add_install_to_transaction(new_tran, installed_pkg);
}
- slapt_vector_t_foreach (slapt_pkg_info_t *, remove_pkg, tran->remove_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, remove_pkg, tran->remove_pkgs) {
if (strcmp(pkg->name, remove_pkg->name) == 0 &&
strcmp(pkg->version, remove_pkg->version) == 0 &&
strcmp(pkg->location, remove_pkg->location) == 0) {
@@ -610,8 +610,8 @@ slapt_transaction_t *slapt_remove_from_transaction(slapt_transaction_t *tran, sl
}
slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade, tran->upgrade_pkgs) {
- slapt_pkg_info_t *u = upgrade->upgrade;
- slapt_pkg_info_t *p = upgrade->installed;
+ slapt_pkg_t *u = upgrade->upgrade;
+ slapt_pkg_t *p = upgrade->installed;
if (strcmp(pkg->name, u->name) == 0 &&
strcmp(pkg->version, u->version) == 0 &&
@@ -622,7 +622,7 @@ slapt_transaction_t *slapt_remove_from_transaction(slapt_transaction_t *tran, sl
slapt_add_upgrade_to_transaction(new_tran, p, u);
}
- slapt_vector_t_foreach (slapt_pkg_info_t *, exclude_pkg, tran->exclude_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, exclude_pkg, tran->exclude_pkgs) {
if (strcmp(pkg->name, exclude_pkg->name) == 0 &&
strcmp(pkg->version, exclude_pkg->version) == 0 &&
strcmp(pkg->location, exclude_pkg->location) == 0) {
@@ -637,11 +637,11 @@ slapt_transaction_t *slapt_remove_from_transaction(slapt_transaction_t *tran, sl
/* parse the dependencies for a package, and add them to the transaction as */
/* needed check to see if a package is conflicted */
-int slapt_add_deps_to_trans(const slapt_rc_config *global_config,
+int slapt_add_deps_to_trans(const slapt_config_t *global_config,
slapt_transaction_t *tran,
slapt_vector_t *avail_pkgs,
slapt_vector_t *installed_pkgs,
- slapt_pkg_info_t *pkg)
+ slapt_pkg_t *pkg)
{
int dep_return = -1;
@@ -663,13 +663,13 @@ int slapt_add_deps_to_trans(const slapt_rc_config *global_config,
}
/* loop through the deps */
- slapt_vector_t_foreach (slapt_pkg_info_t *, dep, deps) {
- slapt_pkg_info_t *dep_installed = NULL;
+ slapt_vector_t_foreach (slapt_pkg_t *, dep, deps) {
+ slapt_pkg_t *dep_installed = NULL;
/* the dep wouldn't get this far if it where excluded, so we don't check for that here */
slapt_vector_t *conflicts = slapt_is_conflicted(tran, avail_pkgs, installed_pkgs, dep);
- slapt_vector_t_foreach (slapt_pkg_info_t *, conflict, conflicts) {
+ slapt_vector_t_foreach (slapt_pkg_t *, conflict, conflicts) {
slapt_add_remove_to_transaction(tran, conflict);
}
@@ -694,14 +694,14 @@ int slapt_add_deps_to_trans(const slapt_rc_config *global_config,
slapt_vector_t *slapt_is_conflicted(slapt_transaction_t *tran,
slapt_vector_t *avail_pkgs,
slapt_vector_t *installed_pkgs,
- slapt_pkg_info_t *pkg)
+ slapt_pkg_t *pkg)
{
slapt_vector_t *conflicts = NULL;
slapt_vector_t *conflicts_in_transaction = slapt_vector_t_init(NULL);
/* if conflicts exist, check to see if they are installed or in the current transaction */
conflicts = slapt_get_pkg_conflicts(avail_pkgs, installed_pkgs, pkg);
- slapt_vector_t_foreach (slapt_pkg_info_t *, conflict, conflicts) {
+ slapt_vector_t_foreach (slapt_pkg_t *, conflict, conflicts) {
if (slapt_search_upgrade_transaction(tran, conflict) == 1 || slapt_get_newest_pkg(tran->install_pkgs, conflict->name) != NULL) {
printf(gettext("%s, which is to be installed, conflicts with %s\n"), conflict->name, pkg->name);
@@ -719,7 +719,7 @@ slapt_vector_t *slapt_is_conflicted(slapt_transaction_t *tran,
return conflicts_in_transaction;
}
-static void add_suggestion(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
+static void add_suggestion(slapt_transaction_t *tran, slapt_pkg_t *pkg)
{
slapt_vector_t *suggests = NULL;
@@ -740,31 +740,31 @@ static void add_suggestion(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
slapt_vector_t_free(suggests);
}
-bool slapt_search_transaction_by_pkg(slapt_transaction_t *tran, slapt_pkg_info_t *pkg)
+bool slapt_search_transaction_by_pkg(slapt_transaction_t *tran, slapt_pkg_t *pkg)
{
- slapt_vector_t_foreach (slapt_pkg_info_t *, install_pkg, tran->install_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, install_pkg, tran->install_pkgs) {
if ((strcmp(pkg->name, install_pkg->name) == 0) && (strcmp(pkg->version, install_pkg->version) == 0))
return true;
}
slapt_vector_t_foreach (slapt_pkg_upgrade_t *, upgrade, tran->upgrade_pkgs) {
- slapt_pkg_info_t *p = upgrade->upgrade;
+ slapt_pkg_t *p = upgrade->upgrade;
if ((strcmp(pkg->name, p->name) == 0) && (strcmp(pkg->version, p->version) == 0))
return true;
}
slapt_vector_t_foreach (slapt_pkg_upgrade_t *, reinstall, tran->reinstall_pkgs) {
- slapt_pkg_info_t *p = reinstall->upgrade;
+ slapt_pkg_t *p = reinstall->upgrade;
if ((strcmp(pkg->name, p->name) == 0) && (strcmp(pkg->version, p->version) == 0))
return true;
}
- slapt_vector_t_foreach (slapt_pkg_info_t *, remove_pkg, tran->remove_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, remove_pkg, tran->remove_pkgs) {
if ((strcmp(pkg->name, remove_pkg->name) == 0) && (strcmp(pkg->version, remove_pkg->version) == 0))
return true;
}
- slapt_vector_t_foreach (slapt_pkg_info_t *, exclude_pkg, tran->exclude_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, exclude_pkg, tran->exclude_pkgs) {
if ((strcmp(pkg->name, exclude_pkg->name) == 0) && (strcmp(pkg->version, exclude_pkg->version) == 0))
return true;
}
@@ -774,7 +774,7 @@ bool slapt_search_transaction_by_pkg(slapt_transaction_t *tran, slapt_pkg_info_t
void slapt_generate_suggestions(slapt_transaction_t *tran)
{
- slapt_vector_t_foreach (slapt_pkg_info_t *, pkg, tran->install_pkgs) {
+ slapt_vector_t_foreach (slapt_pkg_t *, pkg, tran->install_pkgs) {
add_suggestion(tran, pkg);
}
}
diff --git a/src/transaction.h b/src/transaction.h
index bf81deb..48c7b4b 100644
--- a/src/transaction.h
+++ b/src/transaction.h
@@ -22,14 +22,36 @@
*/
#define MAX_LINE_LEN 80
+enum slapt_action {
+ SLAPT_ACTION_USAGE = 0,
+ SLAPT_ACTION_UPDATE,
+ SLAPT_ACTION_INSTALL,
+ SLAPT_ACTION_REMOVE,
+ SLAPT_ACTION_SHOW,
+ SLAPT_ACTION_SEARCH,
+ SLAPT_ACTION_UPGRADE,
+ SLAPT_ACTION_LIST,
+ SLAPT_ACTION_INSTALLED,
+ SLAPT_ACTION_CLEAN,
+ SLAPT_ACTION_SHOWVERSION,
+ SLAPT_ACTION_AUTOCLEAN,
+ SLAPT_ACTION_AVAILABLE,
+ SLAPT_ACTION_INSTALL_DISK_SET,
+ SLAPT_ACTION_FILELIST,
+#ifdef SLAPT_HAS_GPGME
+ SLAPT_ACTION_ADD_KEYS,
+#endif
+ SLAPT_ACTION_END
+};
+
typedef struct {
union {
- slapt_pkg_info_t *i;
+ slapt_pkg_t *i;
slapt_pkg_upgrade_t *u;
} pkg;
- uint32_t type; /* this is enum slapt_action defined in main.h */
+ enum slapt_action type;
} slapt_queue_i;
-slapt_queue_i *slapt_queue_i_init(slapt_pkg_info_t *, slapt_pkg_upgrade_t *);
+slapt_queue_i *slapt_queue_i_init(slapt_pkg_t *, slapt_pkg_upgrade_t *);
void slapt_queue_i_free(slapt_queue_i *);
typedef struct {
@@ -47,39 +69,39 @@ typedef struct {
/* fill in transaction structure with defaults */
slapt_transaction_t *slapt_init_transaction(void);
/* download and install/remove/upgrade packages as defined in the transaction, returns 0 on success */
-int slapt_handle_transaction(const slapt_rc_config *, slapt_transaction_t *);
+int slapt_handle_transaction(const slapt_config_t *, slapt_transaction_t *);
/* add package for installation to transaction */
-void slapt_add_install_to_transaction(slapt_transaction_t *, slapt_pkg_info_t *pkg);
+void slapt_add_install_to_transaction(slapt_transaction_t *, slapt_pkg_t *pkg);
/* add package for removal to transaction */
-void slapt_add_remove_to_transaction(slapt_transaction_t *, slapt_pkg_info_t *pkg);
+void slapt_add_remove_to_transaction(slapt_transaction_t *, slapt_pkg_t *pkg);
/* add package to upgrade to transaction */
-void slapt_add_upgrade_to_transaction(slapt_transaction_t *, slapt_pkg_info_t *installed_pkg, slapt_pkg_info_t *upgrade_pkg);
+void slapt_add_upgrade_to_transaction(slapt_transaction_t *, slapt_pkg_t *installed_pkg, slapt_pkg_t *upgrade_pkg);
/* add package to reinstall to transaction */
-void slapt_add_reinstall_to_transaction(slapt_transaction_t *, slapt_pkg_info_t *installed_pkg, slapt_pkg_info_t *upgrade_pkg);
+void slapt_add_reinstall_to_transaction(slapt_transaction_t *, slapt_pkg_t *installed_pkg, slapt_pkg_t *upgrade_pkg);
/* add package to exclude to transaction */
-void slapt_add_exclude_to_transaction(slapt_transaction_t *, slapt_pkg_info_t *pkg);
+void slapt_add_exclude_to_transaction(slapt_transaction_t *, slapt_pkg_t *pkg);
/* remove package from transaction, returns modified transaction */
-slapt_transaction_t *slapt_remove_from_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *pkg);
+slapt_transaction_t *slapt_remove_from_transaction(slapt_transaction_t *tran, slapt_pkg_t *pkg);
/* search transaction by package name. returns true if found, false otherwise */
bool slapt_search_transaction(slapt_transaction_t *, char *pkg_name);
/* search transaction by package attributes, returns true if found, false otherwise */
-bool slapt_search_transaction_by_pkg(slapt_transaction_t *tran, slapt_pkg_info_t *pkg);
+bool slapt_search_transaction_by_pkg(slapt_transaction_t *tran, slapt_pkg_t *pkg);
/* searches the upgrade list of the transaction for the present of the package, returns true if found, false if not found */
-bool slapt_search_upgrade_transaction(slapt_transaction_t *tran, slapt_pkg_info_t *pkg);
+bool slapt_search_upgrade_transaction(slapt_transaction_t *tran, slapt_pkg_t *pkg);
/* add dependencies for package to transaction, returns -1 on error, 0 otherwise */
-int slapt_add_deps_to_trans(const slapt_rc_config *global_config,
+int slapt_add_deps_to_trans(const slapt_config_t *global_config,
slapt_transaction_t *tran,
slapt_vector_t *avail_pkgs,
- slapt_vector_t *installed_pkgs, slapt_pkg_info_t *pkg);
+ slapt_vector_t *installed_pkgs, slapt_pkg_t *pkg);
/* check to see if a package has a conflict already present in the transaction, returns conflicted package or NULL if none */
slapt_vector_t *slapt_is_conflicted(slapt_transaction_t *tran,
slapt_vector_t *avail_pkgs,
slapt_vector_t *installed_pkgs,
- slapt_pkg_info_t *pkg);
+ slapt_pkg_t *pkg);
/* generate a list of suggestions based on the current packages in the transaction */
void slapt_generate_suggestions(slapt_transaction_t *tran);
diff --git a/t/test.c b/t/test.c
index c889e40..65e3f54 100644
--- a/t/test.c
+++ b/t/test.c
@@ -5,7 +5,7 @@
#include "test_packages.h"
#include "test_transaction.h"
-slapt_pkg_info_t pkg = {
+slapt_pkg_t pkg = {
"8598a2a6d683d098b09cdc938de1e3c7",
"gslapt",
"0.3.15-i386-1",
diff --git a/t/test_common.c b/t/test_common.c
index d90aa05..8955edb 100644
--- a/t/test_common.c
+++ b/t/test_common.c
@@ -14,19 +14,19 @@ END_TEST
START_TEST(test_regex)
{
- slapt_regex_t *regex = slapt_init_regex("^[a-z]+$");
- slapt_regex_t *invalid_regex = slapt_init_regex("^[-");
+ slapt_regex_t *regex = slapt_regex_t_init("^[a-z]+$");
+ slapt_regex_t *invalid_regex = slapt_regex_t_init("^[-");
fail_if(regex == NULL);
fail_unless(invalid_regex == NULL);
- slapt_execute_regex(regex, "abc");
+ slapt_regex_t_execute(regex, "abc");
fail_if(regex->reg_return == REG_NOMATCH);
- slapt_execute_regex(regex, "123");
+ slapt_regex_t_execute(regex, "123");
fail_unless(regex->reg_return == REG_NOMATCH);
- slapt_free_regex(regex);
+ slapt_regex_t_free(regex);
}
END_TEST
diff --git a/t/test_configuration.c b/t/test_configuration.c
index 4e3283a..e232b35 100644
--- a/t/test_configuration.c
+++ b/t/test_configuration.c
@@ -2,14 +2,14 @@
START_TEST(test_struct_config)
{
- slapt_rc_config *rc = NULL;
+ slapt_config_t *rc = NULL;
- rc = slapt_init_config();
+ rc = slapt_config_t_init();
fail_if(rc == NULL);
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
rc = NULL;
- rc = slapt_read_rc_config("./data/rc1");
+ rc = slapt_config_t_read("./data/rc1");
fail_if(rc == NULL);
{
slapt_vector_t *s = rc->sources;
@@ -18,7 +18,7 @@ START_TEST(test_struct_config)
fail_if(s->size < 1);
fail_if(e->size != 5);
}
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
rc = NULL;
}
END_TEST
@@ -26,10 +26,10 @@ END_TEST
START_TEST(test_working_dir)
{
DIR *d = NULL;
- slapt_rc_config *rc = slapt_read_rc_config("data/rc1");
+ slapt_config_t *rc = slapt_config_t_read("data/rc1");
/* check that working_dir exists or make it if permissions allow */
- /* void slapt_working_dir_init(const slapt_rc_config *global_config); */
+ /* void slapt_working_dir_init(const slapt_config_t *global_config); */
slapt_working_dir_init(rc);
@@ -42,14 +42,14 @@ END_TEST
START_TEST(test_source_trimming)
{
- slapt_source_t *src1 = slapt_init_source("http://www.test.org/dist ");
- slapt_source_t *src2 = slapt_init_source("http://www.test.org/dist:PREFERRED ");
+ slapt_source_t *src1 = slapt_source_t_init("http://www.test.org/dist ");
+ slapt_source_t *src2 = slapt_source_t_init("http://www.test.org/dist:PREFERRED ");
fail_if(strcmp(src1->url, "http://www.test.org/dist/") != 0);
fail_if(strcmp(src2->url, "http://www.test.org/dist/") != 0);
- slapt_free_source(src1);
- slapt_free_source(src2);
+ slapt_source_t_free(src1);
+ slapt_source_t_free(src2);
}
END_TEST
diff --git a/t/test_curl.c b/t/test_curl.c
index 4b71064..f258d65 100644
--- a/t/test_curl.c
+++ b/t/test_curl.c
@@ -1,5 +1,5 @@
#include "test_curl.h"
-extern slapt_pkg_info_t pkg;
+extern slapt_pkg_t pkg;
extern int _progress_cb(void *clientp, double dltotal, double dlnow,
double ultotal, double ulnow);
@@ -8,7 +8,7 @@ START_TEST(test_slapt_get_mirror_data_from_source)
{
FILE *f = NULL;
const char *err = NULL;
- slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
+ slapt_config_t *rc = slapt_config_t_read("./data/rc1");
slapt_source_t *src = rc->sources->items[0];
const char *url = src->url;
char *packages = "PACKAGES.TXT";
@@ -42,21 +42,21 @@ START_TEST(test_slapt_get_mirror_data_from_source)
unlink("data/CHECKSUMS.md5");
unlink("data/CHECKSUMS.md5.gz");
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
}
END_TEST
START_TEST(test_slapt_download_pkg)
{
const char *err = NULL;
- slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
+ slapt_config_t *rc = slapt_config_t_read("./data/rc1");
rc->progress_cb = _progress_cb; /* silence */
slapt_working_dir_init(rc);
err = slapt_download_pkg(rc, &pkg, NULL);
fail_if(err);
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
}
END_TEST
diff --git a/t/test_packages.c b/t/test_packages.c
index 7fd6b78..1903c1b 100644
--- a/t/test_packages.c
+++ b/t/test_packages.c
@@ -1,12 +1,12 @@
#include "test_packages.h"
-extern slapt_pkg_info_t pkg;
+extern slapt_pkg_t pkg;
extern int _progress_cb(void *clientp, double dltotal, double dlnow,
double ultotal, double ulnow);
START_TEST(test_struct_pkg)
{
- slapt_pkg_info_t *cpy = slapt_init_pkg();
+ slapt_pkg_t *cpy = slapt_pkg_t_init();
fail_if(cpy == NULL);
cpy = slapt_copy_pkg(cpy, &pkg);
@@ -24,7 +24,7 @@ START_TEST(test_struct_pkg)
free(cpy_str);
}
- slapt_free_pkg(cpy);
+ slapt_pkg_t_free(cpy);
}
END_TEST
@@ -32,7 +32,7 @@ START_TEST(test_pkg_info)
{
size_t i = -1;
char *string = NULL;
- slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
+ slapt_config_t *rc = slapt_config_t_read("./data/rc1");
string = slapt_gen_short_pkg_description(&pkg);
fail_if(string == NULL);
@@ -75,21 +75,21 @@ START_TEST(test_pkg_info)
string = NULL;
/* retrieve the packages changelog entry, if any. Returns NULL otherwise */
- /* char *slapt_get_pkg_changelog(const slapt_pkg_info_t *pkg); */
+ /* char *slapt_get_pkg_changelog(const slapt_pkg_t *pkg); */
/* get the package filelist, returns (char *) on success or NULL on error */
- /* char *slapt_get_pkg_filelist(const slapt_pkg_info_t *pkg); */
+ /* char *slapt_get_pkg_filelist(const slapt_pkg_t *pkg); */
fail_unless(pkg.priority == SLAPT_PRIORITY_DEFAULT);
fail_unless(strcmp(slapt_priority_to_str(pkg.priority), gettext("Default")) == 0);
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
}
END_TEST
START_TEST(test_pkg_search)
{
- slapt_pkg_info_t *p = NULL;
+ slapt_pkg_t *p = NULL;
slapt_vector_t *l = NULL;
slapt_vector_t *list = slapt_vector_t_init(NULL);
slapt_vector_t_add(list, &pkg);
@@ -113,7 +113,7 @@ END_TEST
START_TEST(test_pkgtool)
{
- slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
+ slapt_config_t *rc = slapt_config_t_read("./data/rc1");
/* disabled... */
/*
int r = -1;
@@ -122,7 +122,7 @@ START_TEST(test_pkgtool)
r = slapt_remove_pkg(rc, &pkg);
*/
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
}
END_TEST
@@ -146,7 +146,7 @@ http://software.jaos.org/pipermail/slapt-get-devel/2008-November/000762.html
*/
START_TEST(test_pkg_version)
{
- slapt_pkg_info_t mirror_pkg1 = {
+ slapt_pkg_t mirror_pkg1 = {
"8598a2a6d683d098b09cdc938de1e3c7",
"gslapt",
"0.3.15-i386-1",
@@ -161,7 +161,7 @@ START_TEST(test_pkg_version)
440,
SLAPT_PRIORITY_PREFERRED,
false};
- slapt_pkg_info_t mirror_pkg2 = {
+ slapt_pkg_t mirror_pkg2 = {
"8598a2a6d683d098b09cdc938de1e3c7",
"gslapt",
"0.3.15-i386-2",
@@ -176,7 +176,7 @@ START_TEST(test_pkg_version)
440,
SLAPT_PRIORITY_DEFAULT,
false};
- slapt_pkg_info_t installed_pkg = {
+ slapt_pkg_t installed_pkg = {
"8598a2a6d683d098b09cdc938de1e3c7",
"gslapt",
"0.3.15-i386-1",
@@ -255,14 +255,14 @@ START_TEST(test_dependency)
{
uint32_t i = 0;
FILE *fh = NULL;
- slapt_pkg_info_t *p = NULL;
+ slapt_pkg_t *p = NULL;
slapt_vector_t *required_by = slapt_vector_t_init(NULL);
slapt_vector_t *pkgs_to_install = slapt_vector_t_init(NULL);
slapt_vector_t *pkgs_to_remove = slapt_vector_t_init(NULL);
slapt_vector_t *conflicts = NULL, *deps = slapt_vector_t_init(NULL);
slapt_vector_t *conflict = slapt_vector_t_init((slapt_vector_t_free_function)slapt_pkg_err_t_free),
*missing = slapt_vector_t_init((slapt_vector_t_free_function)slapt_pkg_err_t_free);
- slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
+ slapt_config_t *rc = slapt_config_t_read("./data/rc1");
fh = fopen("data/avail_deps", "r");
fail_unless(fh != NULL);
@@ -294,7 +294,7 @@ START_TEST(test_dependency)
conflicts = slapt_get_pkg_conflicts(avail, installed, p);
fail_unless(conflicts != NULL);
fail_unless(conflicts->size == 1);
- fail_unless(strcmp(((slapt_pkg_info_t *)conflicts->items[0])->name, "ibus") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)conflicts->items[0])->name, "ibus") == 0);
slapt_vector_t_free(conflicts);
/*
@@ -305,11 +305,11 @@ START_TEST(test_dependency)
fail_unless(p != NULL);
required_by = slapt_is_required_by(rc, avail, installed, pkgs_to_install, pkgs_to_remove, p);
fail_unless(required_by->size == 5);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[0]))->name, "slapt-src") == 0);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[1]))->name, "gslapt") == 0);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[2]))->name, "foo") == 0);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[3]))->name, "boz") == 0);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[4]))->name, "bar") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[0]))->name, "slapt-src") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[1]))->name, "gslapt") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[2]))->name, "foo") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[3]))->name, "boz") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[4]))->name, "bar") == 0);
slapt_vector_t_free(required_by);
/* glib reverse dep test */
@@ -317,8 +317,8 @@ START_TEST(test_dependency)
fail_unless(p != NULL);
required_by = slapt_is_required_by(rc, avail, installed, pkgs_to_install, pkgs_to_remove, p);
fail_unless(required_by->size == 2);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[0]))->name, "xmms") == 0);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[1]))->name, "gtk+") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[0]))->name, "xmms") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[1]))->name, "gtk+") == 0);
slapt_vector_t_free(required_by);
/* glib2 reverse dep test */
@@ -326,23 +326,23 @@ START_TEST(test_dependency)
fail_unless(p != NULL);
required_by = slapt_is_required_by(rc, avail, installed, pkgs_to_install, pkgs_to_remove, p);
fail_unless(required_by->size == 4);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[0]))->name, "ConsoleKit") == 0);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[1]))->name, "dbus-glib") == 0);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[2]))->name, "gslapt") == 0);
- fail_unless(strcmp(((slapt_pkg_info_t *)(required_by->items[3]))->name, "scim") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[0]))->name, "ConsoleKit") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[1]))->name, "dbus-glib") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[2]))->name, "gslapt") == 0);
+ fail_unless(strcmp(((slapt_pkg_t *)(required_by->items[3]))->name, "scim") == 0);
slapt_vector_t_free(required_by);
slapt_vector_t_free(installed);
slapt_vector_t_free(pkgs_to_install);
slapt_vector_t_free(pkgs_to_remove);
slapt_vector_t_free(avail);
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
}
END_TEST
START_TEST(test_cache)
{
- slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
+ slapt_config_t *rc = slapt_config_t_read("./data/rc1");
slapt_clean_pkg_dir(rc->working_dir);
@@ -351,14 +351,14 @@ START_TEST(test_cache)
slapt_purge_old_cached_pkgs(rc, NULL, list);
*/
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
}
END_TEST
START_TEST(test_network)
{
char *cwd = get_current_dir_name();
- slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
+ slapt_config_t *rc = slapt_config_t_read("./data/rc1");
rc->progress_cb = _progress_cb; /* silence */
/* must chdir to working dir */
@@ -370,20 +370,20 @@ START_TEST(test_network)
*/
/* download the PACKAGES.TXT and CHECKSUMS.md5 files
- slapt_vector_t *slapt_get_pkg_source_packages (const slapt_rc_config *global_config,
+ slapt_vector_t *slapt_get_pkg_source_packages (const slapt_config_t *global_config,
const char *url);
- slapt_vector_t *slapt_get_pkg_source_patches (const slapt_rc_config *global_config,
+ slapt_vector_t *slapt_get_pkg_source_patches (const slapt_config_t *global_config,
const char *url);
- FILE *slapt_get_pkg_source_checksums (const slapt_rc_config *global_config,
+ FILE *slapt_get_pkg_source_checksums (const slapt_config_t *global_config,
const char *url);
- int slapt_get_pkg_source_changelog (const slapt_rc_config *global_config,
+ int slapt_get_pkg_source_changelog (const slapt_config_t *global_config,
const char *url);
*/
fail_unless(slapt_update_pkg_cache(rc) == 0);
fail_unless(chdir(cwd) == 0);
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
free(cwd);
}
END_TEST
diff --git a/t/test_transaction.c b/t/test_transaction.c
index 2f11a27..6363e65 100644
--- a/t/test_transaction.c
+++ b/t/test_transaction.c
@@ -1,5 +1,5 @@
#include "test_transaction.h"
-extern slapt_pkg_info_t pkg;
+extern slapt_pkg_t pkg;
START_TEST(test_transaction)
{
@@ -31,22 +31,22 @@ END_TEST
START_TEST(test_handle_transaction)
{
slapt_transaction_t *t = slapt_init_transaction();
- slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
+ slapt_config_t *rc = slapt_config_t_read("./data/rc1");
/*
download and install/remove/upgrade packages as defined in the transaction
returns 0 on success
- int slapt_handle_transaction(const slapt_rc_config *,slapt_transaction_t *);
+ int slapt_handle_transaction(const slapt_config_t *,slapt_transaction_t *);
*/
slapt_free_transaction(t);
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
}
END_TEST
START_TEST(test_transaction_dependencies)
{
- slapt_rc_config *rc = slapt_read_rc_config("./data/rc1");
+ slapt_config_t *rc = slapt_config_t_read("./data/rc1");
FILE *fh = fopen("data/avail_deps", "r");
fail_unless(fh != NULL);
@@ -62,19 +62,19 @@ START_TEST(test_transaction_dependencies)
/*
add dependencies for package to transaction, returns -1 on error, 0 otherwise
- int slapt_add_deps_to_trans(const slapt_rc_config *global_config,
+ int slapt_add_deps_to_trans(const slapt_config_t *global_config,
slapt_transaction_t *tran,
struct slapt_pkg_list *avail_pkgs,
- struct slapt_pkg_list *installed_pkgs, slapt_pkg_info_t *pkg);
+ struct slapt_pkg_list *installed_pkgs, slapt_pkg_t *pkg);
*/
/*
check to see if a package has a conflict already present in the transaction
returns conflicted package or NULL if none
- slapt_pkg_info_t *slapt_is_conflicted(slapt_transaction_t *tran,
+ slapt_pkg_t *slapt_is_conflicted(slapt_transaction_t *tran,
struct slapt_pkg_list *avail_pkgs,
struct slapt_pkg_list *installed_pkgs,
- slapt_pkg_info_t *pkg);
+ slapt_pkg_t *pkg);
*/
/*
@@ -82,8 +82,8 @@ START_TEST(test_transaction_dependencies)
in the transaction
void slapt_generate_suggestions(slapt_transaction_t *tran);
*/
- slapt_pkg_info_t *p = slapt_get_newest_pkg(avail, "scim");
- slapt_pkg_info_t *installed_p = slapt_get_newest_pkg(installed, "scim");
+ slapt_pkg_t *p = slapt_get_newest_pkg(avail, "scim");
+ slapt_pkg_t *installed_p = slapt_get_newest_pkg(installed, "scim");
(void)installed_p;
slapt_vector_t *conflicts = slapt_is_conflicted(t, avail, installed, p);
@@ -98,7 +98,7 @@ START_TEST(test_transaction_dependencies)
slapt_generate_suggestions(t);
slapt_free_transaction(t);
- slapt_free_rc_config(rc);
+ slapt_config_t_free(rc);
}
END_TEST