#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
-#include <getopt.h>
#include <time.h>
#include <ctype.h>
#include <unistd.h>
#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");
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') {
*
* Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
*
- * 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>
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)
* 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 */
}
/* 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;
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)
/* 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;
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) {
* 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
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
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++] :
*
* by Sterling Huxley <sterling@europa.com>
*
- * 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>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
-#include <getopt.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
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);
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.
* 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);
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;
}