summaryrefslogtreecommitdiffstats
path: root/libopkg
diff options
context:
space:
mode:
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-11-25 20:42:53 (EST)
committer graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-11-25 20:42:53 (EST)
commitd2fc8c73ad1cff0e8b57330caa3c997a17059f2b (patch)
treeda202a65f58455cbb2a2a9c484627502c5a61d9b /libopkg
parent9ba412631e57deb365d5e7fb8b8c2fbf9bfe27b0 (diff)
Remove str_util.{c,h}
git-svn-id: http://opkg.googlecode.com/svn/trunk@383 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg')
-rw-r--r--libopkg/Makefile.am2
-rw-r--r--libopkg/opkg_cmd.c1
-rw-r--r--libopkg/opkg_conf.c1
-rw-r--r--libopkg/opkg_download.c7
-rw-r--r--libopkg/opkg_install.c1
-rw-r--r--libopkg/opkg_remove.c1
-rw-r--r--libopkg/pkg.c1
-rw-r--r--libopkg/pkg_dest.c5
-rw-r--r--libopkg/str_util.c58
-rw-r--r--libopkg/str_util.h26
-rw-r--r--libopkg/user.c7
11 files changed, 14 insertions, 96 deletions
diff --git a/libopkg/Makefile.am b/libopkg/Makefile.am
index 067d867..c7a0a9e 100644
--- a/libopkg/Makefile.am
+++ b/libopkg/Makefile.am
@@ -27,7 +27,7 @@ opkg_list_sources = conffile.c conffile.h conffile_list.c conffile_list.h \
str_list.c str_list.h void_list.c void_list.h \
active_list.c active.list.h list.h
opkg_util_sources = file_util.c file_util.h opkg_message.h opkg_message.c md5.c md5.h \
- sprintf_alloc.c sprintf_alloc.h str_util.c str_util.h \
+ sprintf_alloc.c sprintf_alloc.h \
xregex.c xregex.h xsystem.c xsystem.h
if HAVE_PATHFINDER
opkg_util_sources += opkg_pathfinder.c opkg_pathfinder.h
diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c
index fe35ea0..0fb3c85 100644
--- a/libopkg/opkg_cmd.c
+++ b/libopkg/opkg_cmd.c
@@ -30,7 +30,6 @@
#include "sprintf_alloc.h"
#include "pkg.h"
#include "file_util.h"
-#include "str_util.h"
#include "libbb/libbb.h"
#include "opkg_utils.h"
#include "opkg_defines.h"
diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c
index 193ae5c..df5b7b4 100644
--- a/libopkg/opkg_conf.c
+++ b/libopkg/opkg_conf.c
@@ -24,7 +24,6 @@
#include "args.h"
#include "opkg_message.h"
#include "file_util.h"
-#include "str_util.h"
#include "opkg_defines.h"
#include "libbb/libbb.h"
diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c
index 4789249..49a48a0 100644
--- a/libopkg/opkg_download.c
+++ b/libopkg/opkg_download.c
@@ -46,7 +46,6 @@
#include "sprintf_alloc.h"
#include "xsystem.h"
#include "file_util.h"
-#include "str_util.h"
#include "opkg_defines.h"
#include "libbb/libbb.h"
@@ -71,6 +70,12 @@ static CURL *curl = NULL;
static CURL *opkg_curl_init(opkg_conf_t *conf, curl_progress_func cb, void *data);
#endif
+static int
+str_starts_with(const char *str, const char *prefix)
+{
+ return (strncmp(str, prefix, strlen(prefix)) == 0);
+}
+
int opkg_download(opkg_conf_t *conf, const char *src,
const char *dest_file_name, curl_progress_func cb, void *data)
{
diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c
index e848d99..8817591 100644
--- a/libopkg/opkg_install.c
+++ b/libopkg/opkg_install.c
@@ -38,7 +38,6 @@
#include "sprintf_alloc.h"
#include "file_util.h"
-#include "str_util.h"
#include "xsystem.h"
#include "user.h"
#include "libbb/libbb.h"
diff --git a/libopkg/opkg_remove.c b/libopkg/opkg_remove.c
index a4819de..f744585 100644
--- a/libopkg/opkg_remove.c
+++ b/libopkg/opkg_remove.c
@@ -26,7 +26,6 @@
#include "file_util.h"
#include "sprintf_alloc.h"
-#include "str_util.h"
#include "libbb/libbb.h"
/*
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index 58e92a0..be25c5c 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -32,7 +32,6 @@
#include "libbb/libbb.h"
#include "sprintf_alloc.h"
#include "file_util.h"
-#include "str_util.h"
#include "xsystem.h"
#include "opkg_conf.h"
diff --git a/libopkg/pkg_dest.c b/libopkg/pkg_dest.c
index 083f97c..adc5e1f 100644
--- a/libopkg/pkg_dest.c
+++ b/libopkg/pkg_dest.c
@@ -19,7 +19,6 @@
#include "pkg_dest.h"
#include "file_util.h"
-#include "str_util.h"
#include "sprintf_alloc.h"
#include "opkg_conf.h"
#include "opkg_cmd.h"
@@ -31,7 +30,7 @@ int pkg_dest_init(pkg_dest_t *dest, const char *name, const char *root_dir,const
dest->name = xstrdup(name);
/* Guarantee that dest->root_dir ends with a '/' */
- if (str_ends_with(root_dir, "/")) {
+ if (root_dir[strlen(root_dir) -1] == '/') {
dest->root_dir = xstrdup(root_dir);
} else {
sprintf_alloc(&dest->root_dir, "%s/", root_dir);
@@ -42,7 +41,7 @@ int pkg_dest_init(pkg_dest_t *dest, const char *name, const char *root_dir,const
dest->root_dir, OPKG_STATE_DIR_PREFIX);
file_mkdir_hier(dest->opkg_dir, 0755);
- if (str_starts_with (lists_dir, "/"))
+ if (lists_dir[0] == '/')
sprintf_alloc(&dest->lists_dir, "%s", lists_dir);
else
sprintf_alloc(&dest->lists_dir, "/%s", lists_dir);
diff --git a/libopkg/str_util.c b/libopkg/str_util.c
deleted file mode 100644
index 58fdb9c..0000000
--- a/libopkg/str_util.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* str_utils.c - the opkg package management system
-
- Carl D. Worth
-
- Copyright (C) 2001 University of Southern California
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2, or (at
- your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-*/
-
-#include "includes.h"
-
-int str_starts_with(const char *str, const char *prefix)
-{
- return (strncmp(str, prefix, strlen(prefix)) == 0);
-}
-
-int str_ends_with(const char *str, const char *suffix)
-{
- int suffix_len;
- int str_len;
-
- str_len = strlen(str);
- suffix_len = strlen(suffix);
-
- if (str_len < suffix_len) {
- return 0;
- }
-
- return (strcmp(str + str_len - suffix_len, suffix) == 0);
-}
-
-int str_tolower(char *str)
-{
- while (*str) {
- *str = tolower(*str);
- str++;
- }
-
- return 0;
-}
-
-int str_toupper(char *str)
-{
- while (*str) {
- *str = toupper(*str);
- str++;
- }
-
- return 0;
-}
diff --git a/libopkg/str_util.h b/libopkg/str_util.h
deleted file mode 100644
index 02861e6..0000000
--- a/libopkg/str_util.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* str_utils.h - the opkg package management system
-
- Carl D. Worth
-
- Copyright (C) 2001 University of Southern California
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2, or (at
- your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-*/
-
-#ifndef STR_UTILS_H
-#define STR_UTILS_H
-
-int str_starts_with(const char *str, const char *prefix);
-int str_ends_with(const char *str, const char *suffix);
-int str_tolower(char *str);
-int str_toupper(char *str);
-
-#endif
diff --git a/libopkg/user.c b/libopkg/user.c
index e04f04d..ee54eb6 100644
--- a/libopkg/user.c
+++ b/libopkg/user.c
@@ -18,11 +18,13 @@
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
+#include <ctype.h>
+
#include "file_util.h"
-#include "str_util.h"
char *get_user_response(const char *format, ...)
{
+ int i;
va_list ap;
char *response;
@@ -37,7 +39,8 @@ char *get_user_response(const char *format, ...)
if (response == NULL)
return NULL;
- str_tolower(response);
+ for (i=0; response[i]; i++)
+ response[i] = tolower(response[i]);
return response;
}