#include "config.h"
#include "args.h"
#include "sprintf_alloc.h"
+#include "libbb/libbb.h"
static void print_version(void);
args->query_all = 1;
break;
case 'd':
- args->dest = strdup (optarg);
+ args->dest = xstrdup(optarg);
break;
case 'f':
free(args->conf_file);
- args->conf_file = strdup(optarg);
+ args->conf_file = xstrdup(optarg);
break;
case 'o':
- args->offline_root = strdup (optarg);
+ args->offline_root = xstrdup(optarg);
break;
case 'p':
- args->offline_root_path = strdup (optarg);
+ args->offline_root_path = xstrdup(optarg);
break;
case 'n':
args->noaction = 1;
break;
case 't':
- args->tmp_dir = strdup(optarg);
+ args->tmp_dir = xstrdup(optarg);
break;
case 'v':
print_version();
break;
case ARGS_OPT_CACHE:
free(args->cache);
- args->cache = strdup(optarg);
+ args->cache = xstrdup(optarg);
break;
case ARGS_OPT_FORCE_DEFAULTS:
args->force_defaults = 1;
#include <string.h>
#include "hash_table.h"
#include "opkg_message.h"
+#include "libbb/libbb.h"
static int hash_index(hash_table_t *hash, const char *pkg_name);
}
}
hash->n_elements++;
- hash_entry->key = strdup(key);
+ hash_entry->key = xstrdup(key);
hash_entry->data = value;
return 0;
new = opkg_package_new ();
-#define sstrdup(x) (x) ? strdup (x) : NULL;
-
- new->name = sstrdup (old->name);
+ new->name = xstrdup(old->name);
new->version = pkg_version_str_alloc (old);
- new->architecture = sstrdup (old->architecture);
+ new->architecture = xstrdup(old->architecture);
if (old->src)
- new->repository = sstrdup (old->src->name);
- new->description = sstrdup (old->description);
- new->tags = sstrdup (old->tags);
- new->url = sstrdup (old->url);
-
-#undef sstrdup
+ new->repository = xstrdup(old->src->name);
+ new->description = xstrdup(old->description);
+ new->tags = xstrdup(old->tags);
+ new->url = xstrdup(old->url);
new->size = (old->size) ? atoi (old->size) : 0;
new->installed = (old->state_status == SS_INSTALLED);
if (c->offline_root)
{
if (a->offline_root) free (a->offline_root);
- a->offline_root = strdup (c->offline_root);
+ a->offline_root = xstrdup(c->offline_root);
}
if (c->offline_root_pre_script_cmd)
{
if (a->offline_root_pre_script_cmd) free (a->offline_root_pre_script_cmd);
- a->offline_root_pre_script_cmd = strdup (c->offline_root_pre_script_cmd);
+ a->offline_root_pre_script_cmd = xstrdup(c->offline_root_pre_script_cmd);
}
if (c->offline_root_post_script_cmd)
{
if (a->offline_root_post_script_cmd) free (a->offline_root_post_script_cmd);
- a->offline_root_post_script_cmd = strdup (c->offline_root_post_script_cmd);
+ a->offline_root_post_script_cmd = xstrdup(c->offline_root_post_script_cmd);
}
if (c->cache) {
if (a->cache)
free (a->cache);
- a->cache = strdup(c->cache);
+ a->cache = xstrdup(c->cache);
}
/* throw away old opkg_conf and start again */
return;
case OPKG_OPT_TYPE_STRING:
- *((char **)value) = strdup (options[i].value);
+ *((char **)value) = xstrdup(options[i].value);
return;
}
return;
case OPKG_OPT_TYPE_STRING:
- *((char **)options[i].value) = strdup (value);
+ *((char **)options[i].value) = xstrdup(value);
return;
}
}
}
- tmp = strdup ("/tmp/opkg.XXXXXX");
+ tmp = xstrdup("/tmp/opkg.XXXXXX");
if (mkdtemp (tmp) == NULL)
{
(index(strstr(((pkg_src_t *)iter->data)->value, "://") + 3, '/') - ((pkg_src_t *)iter->data)->value)*sizeof(char));
else
- stmp = strdup(((pkg_src_t *)iter->data)->value);
+ stmp = xstrdup(((pkg_src_t *)iter->data)->value);
for (iter1 = str_list_first(src); iter1; iter1 = str_list_next(src, iter1))
{
failures = 0;
- tmp = strdup ("/tmp/opkg.XXXXXX");
+ tmp = xstrdup("/tmp/opkg.XXXXXX");
if (mkdtemp (tmp) == NULL) {
perror ("mkdtemp");
static opkg_intercept_t opkg_prep_intercepts(opkg_conf_t *conf)
{
opkg_intercept_t ctx;
- char *oldpath;
char *newpath;
int gen;
ctx = calloc (1, sizeof (*ctx));
- oldpath = getenv ("PATH");
- if (oldpath) {
- ctx->oldpath = strdup (oldpath);
- } else {
- ctx->oldpath = 0;
- }
-
+ ctx->oldpath = xstrdup(getenv("PATH"));
sprintf_alloc (&newpath, "%s/opkg/intercept:%s", DATADIR, ctx->oldpath);
setenv ("PATH", newpath, 1);
#include "file_util.h"
#include "str_util.h"
#include "xsystem.h"
-#include <glob.h>
#include "opkg_defines.h"
+#include "libbb/libbb.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
+#include <glob.h>
extern char *conf_file_dir;
if (*conf_str) {
free(*conf_str);
}
- *conf_str = strdup(arg_str);
+ *conf_str = xstrdup(arg_str);
}
}
pending_dir = calloc(1, strlen(lists_dir)+strlen("/pending")+5);
snprintf(pending_dir,strlen(lists_dir)+strlen("/pending") ,"%s%s",lists_dir,"/pending");
- conf->lists_dir = strdup(lists_dir);
- conf->pending_dir = strdup(pending_dir);
+ conf->lists_dir = xstrdup(lists_dir);
+ conf->pending_dir = xstrdup(pending_dir);
if (args->offline_root)
sprintf_alloc(&etc_opkg_conf_pattern, "%s/etc/opkg/*.conf", args->offline_root);
if (conf->offline_root) {
sprintf_alloc(&root_dir, "%s%s", conf->offline_root, nv_pair->value);
} else {
- root_dir = strdup(nv_pair->value);
+ root_dir = xstrdup(nv_pair->value);
}
dest = pkg_dest_list_append(&conf->pkg_dest_list, nv_pair->name, root_dir, lists_dir);
free(root_dir);
opkg_message(conf, OPKG_INFO, "supported arch %s priority (%s)\n", name, value);
if (!value) {
opkg_message(conf, OPKG_NOTICE, "defaulting architecture %s priority to 10\n", name);
- value = strdup("10");
+ value = xstrdup("10");
}
nv_pair_list_append(&conf->arch_list, name, value);
} else {
}
case OPKG_OPT_TYPE_STRING:
if (value) {
- *((char **)options[i].value) = strdup(value);
+ *((char **)options[i].value) = xstrdup(value);
return 0;
} else {
printf("%s: Option %s need an argument\n",
#include "file_util.h"
#include "str_util.h"
#include "opkg_defines.h"
+#include "libbb/libbb.h"
#if defined(HAVE_OPENSSL) || defined(HAVE_SSLCURL)
static void openssl_init(void);
{
int err = 0;
- char *src_basec = strdup(src);
+ char *src_basec = xstrdup(src);
char *src_base = basename(src_basec);
char *tmp_file_location;
static int opkg_download_cache(opkg_conf_t *conf, const char *src,
const char *dest_file_name, curl_progress_func cb, void *data)
{
- char *cache_name = strdup(src);
+ char *cache_name = xstrdup(src);
char *cache_location, *p;
int err = 0;
if (str_starts_with(url, "http://")
|| str_starts_with(url, "ftp://")) {
char *tmp_file;
- char *file_basec = strdup(url);
+ char *file_basec = xstrdup(url);
char *file_base = basename(file_basec);
sprintf_alloc(&tmp_file, "%s/%s", conf->tmp_dir, file_base);
return 0;
}
if (namep) {
- *namep = strdup(pkg->name);
+ *namep = xstrdup(pkg->name);
}
return 0;
}
#include "str_util.h"
#include "xsystem.h"
#include "user.h"
+#include "libbb/libbb.h"
static int verify_pkg_installable(opkg_conf_t *conf, pkg_t *pkg);
static int unpack_pkg_control_files(opkg_conf_t *conf, pkg_t *pkg);
sprintf_alloc(&preinst_args, "install %s", pkg_version);
free(pkg_version);
} else {
- preinst_args = strdup("install");
+ preinst_args = xstrdup("install");
}
err = pkg_run_script(conf, pkg, "preinst", preinst_args);
#include "opkg_utils.h"
#include "pkg.h"
#include "pkg_hash.h"
+#include "libbb/libbb.h"
void print_pkg_status(pkg_t * pkg, FILE * file);
if((scout = strchr(buf, '\n')))
*scout = '\0';
- raw[count++] = strdup(buf);
+ raw[count++] = xstrdup(buf);
}
raw = realloc(raw, (count + 1) * sizeof(char *));
return;
}
- e->errmsg = strdup(msg);
- if (e->errmsg == NULL) {
- fprintf(stderr, "%s: strdup: %s\n",
- __FUNCTION__, strerror(errno));
- free(e);
- return;
- }
-
+ e->errmsg = xstrdup(msg);
e->next = NULL;
if (error_list_head) {
err = pkg_init(pkg);
if (err) { return err; }
- pkg->local_filename = strdup(filename);
+ pkg->local_filename = xstrdup(filename);
control_file = tmpfile();
err = pkg_extract_control_file_to_stream(pkg, control_file);
if (pkg->epoch) {
sprintf_alloc(&epoch_str, "%d:", pkg->epoch);
} else {
- epoch_str = strdup("");
+ epoch_str = xstrdup("");
}
if (pkg->revision && strlen(pkg->revision)) {
sprintf_alloc(&revision_str, "-%s", pkg->revision);
} else {
- revision_str = strdup("");
+ revision_str = xstrdup("");
}
for (i=0; i < ARRAY_SIZE(pkg_state_want_map); i++) {
if (pkg_state_want_map[i].value == sw) {
- return strdup(pkg_state_want_map[i].str);
+ return xstrdup(pkg_state_want_map[i].str);
}
}
fprintf(stderr, "%s: ERROR: Illegal value for state_want: %d\n",
__FUNCTION__, sw);
- return strdup("<STATE_WANT_UNKNOWN>");
+ return xstrdup("<STATE_WANT_UNKNOWN>");
}
pkg_state_want_t pkg_state_want_from_str(char *str)
sf &= SF_NONVOLATILE_FLAGS;
if (sf == 0) {
- return strdup("ok");
+ return xstrdup("ok");
} else {
for (i=0; i < ARRAY_SIZE(pkg_state_flag_map); i++) {
for (i=0; i < ARRAY_SIZE(pkg_state_status_map); i++) {
if (pkg_state_status_map[i].value == ss) {
- return strdup(pkg_state_status_map[i].str);
+ return xstrdup(pkg_state_status_map[i].str);
}
}
fprintf(stderr, "%s: ERROR: Illegal value for state_status: %d\n",
__FUNCTION__, ss);
- return strdup("<STATE_STATUS_UNKNOWN>");
+ return xstrdup("<STATE_STATUS_UNKNOWN>");
}
pkg_state_status_t pkg_state_status_from_str(const char *str)
#include "opkg_message.h"
#include "pkg_parse.h"
#include "hash_table.h"
+#include "libbb/libbb.h"
static int parseDepends(compound_depend_t *compound_depend, hash_table_t * hash, char * depend_str);
static depend_t * depend_init(void);
fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
return NULL;
}
- resized[count - 1] = strdup(depend_str);
+ resized[count - 1] = xstrdup(depend_str);
resized[count] = NULL;
return resized;
#include "opkg_conf.h"
#include "opkg_cmd.h"
#include "opkg_defines.h"
+#include "libbb/libbb.h"
int pkg_dest_init(pkg_dest_t *dest, const char *name, const char *root_dir,const char * lists_dir)
{
- dest->name = strdup(name);
+ dest->name = xstrdup(name);
/* Guarantee that dest->root_dir ends with a '/' */
if (str_ends_with(root_dir, "/")) {
- dest->root_dir = strdup(root_dir);
+ dest->root_dir = xstrdup(root_dir);
} else {
sprintf_alloc(&dest->root_dir, "%s/", root_dir);
}
#include "pkg_hash.h"
#include "pkg_parse.h"
#include "opkg_utils.h"
+#include "libbb/libbb.h"
static abstract_pkg_t * add_new_abstract_pkg_by_name(hash_table_t * hash, const char * pkg_name);
}
}
- return strdup(def_arch);
+ return xstrdup(def_arch);
}
int pkg_hash_add_from_file(opkg_conf_t *conf, const char *file_name,
ab_pkg = abstract_pkg_new();
if (ab_pkg == NULL) { return NULL; }
- ab_pkg->name = strdup(pkg_name);
+ ab_pkg->name = xstrdup(pkg_name);
hash_table_insert(hash, pkg_name, ab_pkg);
return ab_pkg;
#include "pkg.h"
#include "opkg_utils.h"
#include "pkg_parse.h"
+#include "libbb/libbb.h"
int isGenericFieldType(char * type, char * line)
{
{
pkg->provides_count = 1;
pkg->provides_str = calloc (1, sizeof (char*));
- pkg->provides_str[0] = strdup ("opkg_internal_use_only");
+ pkg->provides_str[0] = xstrdup("opkg_internal_use_only");
}
if (pkg->name) {
*/
#include "includes.h"
-
#include "str_list.h"
+#include "libbb/libbb.h"
int str_list_elt_init(str_list_elt_t *elt, char *data)
{
int str_list_append(str_list_t *list, char *data)
{
- return void_list_append((void_list_t *) list, strdup(data));
+ return void_list_append((void_list_t *) list, xstrdup(data));
}
int str_list_push(str_list_t *list, char *data)
{
- return void_list_push((void_list_t *) list, strdup(data));
+ return void_list_push((void_list_t *) list, xstrdup(data));
}
str_list_elt_t *str_list_pop(str_list_t *list)