Rob Sullivan sent in some cleanups, which I beat on slightly.
This commit was genuinely broken at the time (not related to our build system): scripts/config/mkconfigs.c (2005-08-01 - 2006-10-05 arasi) uretilen bbconfigopts.h icine .config satirlarini kacissiz, ham newline'larla gömüyordu - gecerli C degildi, busybox'un kendi bb_mkdep araci bile parse edemiyordu (7d219aab7 ile duzeltildi, mkconfigs shell scripte cevrildi)
No binary (build failed)
—
(log yok)
| @@ -4,7 +4,6 @@ | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <fcntl.h> | |
| - | #include <getopt.h> |
| #include <time.h> | |
| #include <ctype.h> | |
| #include <unistd.h> | |
| @@ -76,40 +75,20 @@ int makedevs_main(int argc, char **argv) | |
| #elif defined CONFIG_FEATURE_MAKEDEVS_TABLE | |
| - | /* |
| - | * This program is free software; you can redistribute it and/or modify |
| - | * it under the terms of the GNU General Public License version 2 as |
| - | * published by the Free Software Foundation. |
| - | * |
| - | * 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 Library General Public License for more details. |
| - | * |
| - | * You should have received a copy of the GNU General Public License |
| - | * along with this program; if not, write to the Free Software |
| - | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| - | * |
| - | */ |
| + | /* Licensed under the GPL v2 or later, see the file LICENSE in this tarball. */ |
| extern int makedevs_main(int argc, char **argv) | |
| { | |
| - | int opt; |
| FILE *table = stdin; | |
| char *rootdir = NULL; | |
| char *line = NULL; | |
| int linenum = 0; | |
| int ret = EXIT_SUCCESS; | |
| - | while ((opt = getopt(argc, argv, "d:")) != -1) { |
| - | switch(opt) { |
| - | case 'd': |
| - | table = bb_xfopen((line=optarg), "r"); |
| - | break; |
| - | default: |
| - | bb_show_usage(); |
| - | } |
| - | } |
| + | unsigned long flags; |
| + | flags = bb_getopt_ulflags(argc, argv, "d:", &line); |
| + | if (line) |
| + | table = bb_xfopen(line, "r"); |
| if (optind >= argc || (rootdir=argv[optind])==NULL) { | |
| bb_error_msg_and_die("root directory not specified"); | |
| @@ -159,16 +138,9 @@ extern int makedevs_main(int argc, char **argv) | |
| if (name[0] == '#') { | |
| continue; | |
| } | |
| - | if (group) { |
| - | gid = get_ug_id(group, bb_xgetgrnam); |
| - | } else { |
| - | gid = getgid(); |
| - | } |
| - | if (user) { |
| - | uid = get_ug_id(user, bb_xgetpwnam); |
| - | } else { |
| - | uid = getuid(); |
| - | } |
| + | |
| + | gid = group ? get_ug_id(group, bb_xgetgrnam) : getgid(); |
| + | uid = user ? get_ug_id(user, bb_xgetpwnam) : getuid(); |
| full_name = concat_path_file(rootdir, name); | |
| if (type == 'd') { | |
| @@ -4,20 +4,7 @@ | |
| * | |
| * Copyright (C) 2003 Paul Mundt <[email protected]> | |
| * | |
| - | * 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, write to the Free Software |
| - | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| - | * |
| + | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
| */ | |
| #include <stdio.h> | |
| @@ -40,19 +27,14 @@ static void watchdog_shutdown(int unused) | |
| exit(0); | |
| } | |
| - | extern int watchdog_main(int argc, char **argv) |
| + | int watchdog_main(int argc, char **argv) |
| { | |
| - | int opt; |
| - | |
| - | while ((opt = getopt(argc, argv, "t:")) > 0) { |
| - | switch (opt) { |
| - | case 't': |
| - | timer_duration = bb_xgetlarg(optarg, 10, 0, INT_MAX); |
| - | break; |
| - | default: |
| - | bb_show_usage(); |
| - | } |
| - | } |
| + | |
| + | char *t_arg; |
| + | unsigned long flags; |
| + | flags = bb_getopt_ulflags(argc, argv, "t:", &t_arg); |
| + | if (flags & 1) |
| + | timer_duration = bb_xgetlarg(t_arg, 10, 0, INT_MAX); |
| /* We're only interested in the watchdog device .. */ | |
| if (optind < argc - 1 || argc == 1) | |
| @@ -12,19 +12,7 @@ | |
| * Lines in the interfaces file cannot wrap. | |
| * To adhere to the FHS, the default state file is /var/run/ifstate. | |
| * | |
| - | * 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, write to the Free Software |
| - | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| + | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
| */ | |
| /* TODO: standardise execute() return codes to return 0 for success and 1 for failure */ | |
| @@ -819,7 +807,7 @@ static struct interfaces_file_t *read_interfaces(const char *filename) | |
| } | |
| /* Add the interface to the list */ | |
| - | defn->autointerfaces = llist_add_to_end(defn->autointerfaces, strdup(firstword)); |
| + | defn->autointerfaces = llist_add_to_end(defn->autointerfaces, bb_xstrdup(firstword)); |
| debug_noise("\nauto %s\n", firstword); | |
| } | |
| currently_processing = NONE; | |
| @@ -1254,7 +1242,7 @@ extern int ifupdown_main(int argc, char **argv) | |
| const llist_t *list = state_list; | |
| while (list) { | |
| new_item = xmalloc(sizeof(llist_t)); | |
| - | new_item->data = strdup(list->data); |
| + | new_item->data = bb_xstrdup(list->data); |
| new_item->link = NULL; | |
| list = target_list; | |
| if (list == NULL) | |
| @@ -1273,7 +1261,7 @@ extern int ifupdown_main(int argc, char **argv) | |
| /* iface_down */ | |
| const llist_t *list = state_list; | |
| while (list) { | |
| - | target_list = llist_add_to_end(target_list, strdup(list->data)); |
| + | target_list = llist_add_to_end(target_list, bb_xstrdup(list->data)); |
| list = list->link; | |
| } | |
| target_list = defn->autointerfaces; | |
| @@ -1294,15 +1282,15 @@ extern int ifupdown_main(int argc, char **argv) | |
| int okay = 0; | |
| int cmds_ret; | |
| - | iface = strdup(target_list->data); |
| + | iface = bb_xstrdup(target_list->data); |
| target_list = target_list->link; | |
| pch = strchr(iface, '='); | |
| if (pch) { | |
| *pch = '\0'; | |
| - | liface = strdup(pch + 1); |
| + | liface = bb_xstrdup(pch + 1); |
| } else { | |
| - | liface = strdup(iface); |
| + | liface = bb_xstrdup(iface); |
| } | |
| if (!force) { | |
| @@ -8,19 +8,7 @@ | |
| * Created: Thu Apr 7 13:29:41 1994 too | |
| * Last modified: Fri Jun 9 14:34:24 2000 too | |
| * | |
| - | * 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, write to the Free Software |
| - | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| + | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
| * | |
| * HISTORY | |
| * Revision 3.1 1994/04/17 11:31:54 too | |
| @@ -636,10 +624,6 @@ extern int telnet_main(int argc, char** argv) | |
| int maxfd; | |
| #endif | |
| - | #ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN |
| - | int opt; |
| - | #endif |
| - | |
| #ifdef CONFIG_FEATURE_AUTOWIDTH | |
| get_terminal_width_height(0, &win_width, &win_height); | |
| #endif | |
| @@ -661,20 +645,10 @@ extern int telnet_main(int argc, char** argv) | |
| bb_show_usage(); | |
| #ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN | |
| - | autologin = NULL; |
| - | while ((opt = getopt(argc, argv, "al:")) != EOF) { |
| - | switch (opt) { |
| - | case 'l': |
| - | autologin = optarg; |
| - | break; |
| - | case 'a': |
| - | autologin = getenv("USER"); |
| - | break; |
| - | case '?': |
| - | bb_show_usage(); |
| - | break; |
| - | } |
| - | } |
| + | unsigned long flags = bb_getopt_ulflags(argc, argv, "al:", &autologin); |
| + | if (flags & 1) |
| + | autologin = getenv("USER"); |
| + | |
| if (optind < argc) { | |
| bb_lookup_host(&s_in, argv[optind++]); | |
| s_in.sin_port = bb_lookup_port((optind < argc) ? argv[optind++] : | |
| @@ -5,20 +5,7 @@ | |
| * | |
| * by Sterling Huxley <[email protected]> | |
| * | |
| - | * 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, write to the Free Software |
| - | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| - | * |
| + | * Licensed under GPL v2 or later, see file License for details. |
| */ | |
| #include <sys/time.h> | |
| @@ -27,7 +14,6 @@ | |
| #include <netinet/in.h> | |
| #include <netdb.h> | |
| #include <stdio.h> | |
| - | #include <getopt.h> |
| #include <string.h> | |
| #include <time.h> | |
| #include <stdlib.h> | |
| @@ -46,14 +32,14 @@ static void socket_timeout(int sig) | |
| static time_t askremotedate(const char *host) | |
| { | |
| - | unsigned long int nett, localt; |
| + | unsigned long nett; |
| struct sockaddr_in s_in; | |
| int fd; | |
| bb_lookup_host(&s_in, host); | |
| s_in.sin_port = bb_lookup_port("time", "tcp", 37); | |
| - | /* Add a timeout for dead or non accessable servers */ |
| + | /* Add a timeout for dead or inaccessible servers */ |
| alarm(10); | |
| signal(SIGALRM, socket_timeout); | |
| @@ -61,7 +47,6 @@ static time_t askremotedate(const char *host) | |
| if (safe_read(fd, (void *)&nett, 4) != 4) /* read time from server */ | |
| bb_error_msg_and_die("%s did not send the complete time", host); | |
| - | |
| close(fd); | |
| /* convert from network byte order to local byte order. | |
| @@ -70,40 +55,22 @@ static time_t askremotedate(const char *host) | |
| * the RFC 868 time 2,208,988,800 corresponds to 00:00 1 Jan 1970 GMT | |
| * Subtract the RFC 868 time to get Linux epoch | |
| */ | |
| - | localt= ntohl(nett) - RFC_868_BIAS; |
| - | |
| - | return(localt); |
| + | |
| + | return(ntohl(nett) - RFC_868_BIAS); |
| } | |
| int rdate_main(int argc, char **argv) | |
| { | |
| time_t remote_time; | |
| - | int opt; |
| - | int setdate = 1; |
| - | int printdate = 1; |
| - | |
| - | /* Interpret command line args */ |
| - | while ((opt = getopt(argc, argv, "sp")) > 0) { |
| - | switch (opt) { |
| - | case 's': |
| - | printdate = 0; |
| - | setdate = 1; |
| - | break; |
| - | case 'p': |
| - | printdate = 1; |
| - | setdate = 0; |
| - | break; |
| - | default: |
| - | bb_show_usage(); |
| - | } |
| - | } |
| - | |
| - | if (optind == argc) |
| + | |
| + | unsigned long flags = bb_getopt_ulflags(argc, argv, "sp"); |
| + | |
| + | if (!flags || argc == optind) |
| bb_show_usage(); | |
| - | |
| + | |
| remote_time = askremotedate(argv[optind]); | |
| - | if (setdate) { |
| + | if (flags & 1) { |
| time_t current_time; | |
| time(¤t_time); | |
| @@ -112,10 +79,10 @@ int rdate_main(int argc, char **argv) | |
| else | |
| if (stime(&remote_time) < 0) | |
| bb_perror_msg_and_die("Could not set time of day"); | |
| - | } |
| - | |
| - | if (printdate) |
| - | printf("%s", ctime(&remote_time)); |
| + | |
| + | /* No need to check for the -p flag as it's the only option left */ |
| + | |
| + | } else printf("%s", ctime(&remote_time)); |
| return EXIT_SUCCESS; | |
| } | |