diff options
author | David Cantrell <dcantrell@redhat.com> | 2010-03-22 10:13:23 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2010-03-24 09:01:24 -1000 |
commit | c86042b7e6b470c979a9c0923ed7d6f2df3e038b (patch) | |
tree | 2289c58f3c5ad948a7550b80e351288e70f177b4 /isys | |
parent | 5dc7c4cb82b05d37869eceff0d960176a8d12e84 (diff) | |
download | anaconda-c86042b7e6b470c979a9c0923ed7d6f2df3e038b.tar.gz anaconda-c86042b7e6b470c979a9c0923ed7d6f2df3e038b.tar.xz anaconda-c86042b7e6b470c979a9c0923ed7d6f2df3e038b.zip |
Remove isys/str.c, replace calls with glib.h or string.h calls.
str.c was from a time when loader was still a statically linked binary.
Times have changed. Removed str.c and replaced calls with either
string.h or glib.h functions.
For g_ascii_strup() and g_ascii_strdown(), those functions dup the
passed in string, change it, and return that.
Diffstat (limited to 'isys')
-rw-r--r-- | isys/Makefile.am | 2 | ||||
-rw-r--r-- | isys/iface.c | 5 | ||||
-rw-r--r-- | isys/str.c | 125 | ||||
-rw-r--r-- | isys/str.h | 29 |
4 files changed, 4 insertions, 157 deletions
diff --git a/isys/Makefile.am b/isys/Makefile.am index f6a3247e7..f40a88434 100644 --- a/isys/Makefile.am +++ b/isys/Makefile.am @@ -19,7 +19,7 @@ ISYS_SRCS = devices.c imount.c cpio.c uncpio.c lang.c \ isofs.c linkdetect.c vio.c ethtool.c eddsupport.c iface.c \ - str.c auditd.c log.c + auditd.c log.c dist_noinst_HEADERS = *.h diff --git a/isys/iface.c b/isys/iface.c index c1251be1a..58972869d 100644 --- a/isys/iface.c +++ b/isys/iface.c @@ -52,7 +52,6 @@ #include "isys.h" #include "iface.h" -#include "str.h" /* Internal-only function prototypes. */ static struct nl_handle *_iface_get_handle(void); @@ -303,7 +302,9 @@ char *iface_mac2str(char *ifname) { } if ((buf = nl_addr2str(addr, buf, buflen)) != NULL) { - buf = str2upper(buf); + char *oldbuf = buf; + buf = g_ascii_strup(buf, -1); + free(oldbuf); } mac2str_error4: diff --git a/isys/str.c b/isys/str.c deleted file mode 100644 index cf0547391..000000000 --- a/isys/str.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * str.c - String helper functions that don't need string.h or ctype.h - * - * Copyright (C) 2006 Red Hat, Inc. All rights reserved. - * - * 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 of the License, 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * Author(s): David Cantrell <dcantrell@redhat.com> - */ - -#include <stdio.h> -#include <stdlib.h> - -#include "str.h" - -/** - * Called by str2upper() or str2lower() to do the actual work. - * - * @param str String to convert. - * @param lower Lower bound for the character range (e.g., a - z). - * @param upper Upper bound for the character range (e.g., a - z). - * @param shift Shift value (32 for lowercase, -32 for uppercase). - * @return Pointer to str. - */ -char *str2case(char *str, char lower, char upper, int shift) { - char *tmp; - - if (str == NULL) - return NULL; - - /* man ascii(7) */ - tmp = str; - while (*tmp != '\0') { - if (*tmp >= lower && *tmp <= upper) - *tmp += shift; - - tmp++; - } - - return str; -} - -/** - * Convert given string to uppercase. Modifies the argument in the caller's - * stack. If you must ask simply "why?" for this function, it's so we don't - * need toupper() and the same for loop all over the place. - * - * LIMITATIONS: Only deals with ASCII character set. - * - * @param str String to convert to uppercase. - * @return Pointer to str. - */ -char *str2upper(char *str) { - return str2case(str, 'a', 'z', -32); -} - -/** - * Convert given string to lowercase. Modifies the argument in the caller's - * stack. If you must ask simply "why?" for this function, it's so we don't - * need tolower() and the same for loop all over the place. - * - * LIMITATIONS: Only deals with ASCII character set. - * - * @param str String to convert to lowercase. - * @return Pointer to str. - */ -char *str2lower(char *str) { - return str2case(str, 'A', 'Z', 32); -} - -/** - * Pretty much an exact copy of index(3) from the C library. - * @param str String to scan. - * @param ch Character to scan for. - * @return Position of ch in str, NULL if not found. - */ -char *strindex(char *str, int ch) { - if (str == NULL) - return NULL; - - do { - if (*str == ch) - return str; - else - str++; - } while (*str != '\0'); - - return NULL; -} - -/** - * Return number of occurrences of a character in a string. - * @param str String to scan. - * @param ch Character to scan for. - * @return Number of occurrences of ch in str. - */ -int strcount(char *str, int ch) { - int retval = 0; - char *tmp = str; - - if (tmp == NULL) - return retval; - - do { - if ((tmp = strindex(tmp, ch)) != NULL) { - tmp++; - retval++; - } - } while (tmp != NULL); - - return retval; -} - -/* vim:set shiftwidth=4 softtabstop=4: */ diff --git a/isys/str.h b/isys/str.h deleted file mode 100644 index d29602153..000000000 --- a/isys/str.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * str.c - String helper functions, the header file - * - * Copyright (C) 2006 Red Hat, Inc. All rights reserved. - * - * 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 of the License, 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * Author(s): David Cantrell <dcantrell@redhat.com> - */ - -/* Function prototypes */ -char *str2case(char *str, char lower, char upper, int shift); -char *str2upper(char *str); -char *str2lower(char *str); -int strcount(char *str, int ch); -char *strindex(char *str, int ch); - -/* vim:set shiftwidth=4 softtabstop=4: */ |