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
#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"
#include "args.h"
#include "opkg_message.h"
#include "file_util.h"
-#include "str_util.h"
#include "opkg_defines.h"
#include "libbb/libbb.h"
#include "sprintf_alloc.h"
#include "xsystem.h"
#include "file_util.h"
-#include "str_util.h"
#include "opkg_defines.h"
#include "libbb/libbb.h"
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)
{
#include "sprintf_alloc.h"
#include "file_util.h"
-#include "str_util.h"
#include "xsystem.h"
#include "user.h"
#include "libbb/libbb.h"
#include "file_util.h"
#include "sprintf_alloc.h"
-#include "str_util.h"
#include "libbb/libbb.h"
/*
#include "libbb/libbb.h"
#include "sprintf_alloc.h"
#include "file_util.h"
-#include "str_util.h"
#include "xsystem.h"
#include "opkg_conf.h"
#include "pkg_dest.h"
#include "file_util.h"
-#include "str_util.h"
#include "sprintf_alloc.h"
#include "opkg_conf.h"
#include "opkg_cmd.h"
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);
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);
+++ /dev/null
-/* 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;
-}
+++ /dev/null
-/* 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
#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;
if (response == NULL)
return NULL;
- str_tolower(response);
+ for (i=0; response[i]; i++)
+ response[i] = tolower(response[i]);
return response;
}