Deleted Added
full compact
shutdown.c (201180) shutdown.c (216823)
1/*
2 * Copyright (c) 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 25 unchanged lines hidden (view full) ---

34 The Regents of the University of California. All rights reserved.\n";
35#endif /* not lint */
36
37#ifndef lint
38static char sccsid[] = "@(#)shutdown.c 8.4 (Berkeley) 4/28/95";
39#endif /* not lint */
40#endif
41#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 25 unchanged lines hidden (view full) ---

34 The Regents of the University of California. All rights reserved.\n";
35#endif /* not lint */
36
37#ifndef lint
38static char sccsid[] = "@(#)shutdown.c 8.4 (Berkeley) 4/28/95";
39#endif /* not lint */
40#endif
41#include <sys/cdefs.h>
42__FBSDID("$FreeBSD: head/sbin/shutdown/shutdown.c 201180 2009-12-29 08:49:43Z ed $");
42__FBSDID("$FreeBSD: head/sbin/shutdown/shutdown.c 216823 2010-12-30 18:06:31Z pjd $");
43
44#include <sys/param.h>
45#include <sys/time.h>
46#include <sys/resource.h>
47#include <sys/syslog.h>
48
49#include <ctype.h>
50#include <err.h>

--- 59 unchanged lines hidden (view full) ---

110 char *p, *endp;
111 struct passwd *pw;
112 int arglen, ch, len, readstdin;
113
114#ifndef DEBUG
115 if (geteuid())
116 errx(1, "NOT super-user");
117#endif
43
44#include <sys/param.h>
45#include <sys/time.h>
46#include <sys/resource.h>
47#include <sys/syslog.h>
48
49#include <ctype.h>
50#include <err.h>

--- 59 unchanged lines hidden (view full) ---

110 char *p, *endp;
111 struct passwd *pw;
112 int arglen, ch, len, readstdin;
113
114#ifndef DEBUG
115 if (geteuid())
116 errx(1, "NOT super-user");
117#endif
118
118 nosync = NULL;
119 readstdin = 0;
119 nosync = NULL;
120 readstdin = 0;
121
122 /*
123 * Test for the special case where the utility is called as
124 * "poweroff", for which it runs 'shutdown -p now'.
125 */
126 if ((p = rindex(argv[0], '/')) == NULL)
127 p = argv[0];
128 else
129 ++p;
130 if (strcmp(p, "poweroff") == 0) {
131 if (getopt(argc, argv, "") != -1)
132 usage((char *)NULL);
133 argc -= optind;
134 argv += optind;
135 if (argc != 0)
136 usage((char *)NULL);
137 dopower = 1;
138 offset = 0;
139 (void)time(&shuttime);
140 goto poweroff;
141 }
142
120 while ((ch = getopt(argc, argv, "-hknopr")) != -1)
121 switch (ch) {
122 case '-':
123 readstdin = 1;
124 break;
125 case 'h':
126 dohalt = 1;
127 break;

--- 28 unchanged lines hidden (view full) ---

156 if (oflag && !(dohalt || dopower || doreboot))
157 usage("-o requires -h, -p or -r");
158
159 if (nosync != NULL && !oflag)
160 usage("-n requires -o");
161
162 getoffset(*argv++);
163
143 while ((ch = getopt(argc, argv, "-hknopr")) != -1)
144 switch (ch) {
145 case '-':
146 readstdin = 1;
147 break;
148 case 'h':
149 dohalt = 1;
150 break;

--- 28 unchanged lines hidden (view full) ---

179 if (oflag && !(dohalt || dopower || doreboot))
180 usage("-o requires -h, -p or -r");
181
182 if (nosync != NULL && !oflag)
183 usage("-n requires -o");
184
185 getoffset(*argv++);
186
187poweroff:
164 if (*argv) {
165 for (p = mbuf, len = sizeof(mbuf); *argv; ++argv) {
166 arglen = strlen(*argv);
167 if ((len -= arglen) <= 2)
168 break;
169 if (p != mbuf)
170 *p++ = ' ';
171 memmove(p, *argv, arglen);

--- 333 unchanged lines hidden (view full) ---

505}
506
507static void
508usage(const char *cp)
509{
510 if (cp != NULL)
511 warnx("%s", cp);
512 (void)fprintf(stderr,
188 if (*argv) {
189 for (p = mbuf, len = sizeof(mbuf); *argv; ++argv) {
190 arglen = strlen(*argv);
191 if ((len -= arglen) <= 2)
192 break;
193 if (p != mbuf)
194 *p++ = ' ';
195 memmove(p, *argv, arglen);

--- 333 unchanged lines hidden (view full) ---

529}
530
531static void
532usage(const char *cp)
533{
534 if (cp != NULL)
535 warnx("%s", cp);
536 (void)fprintf(stderr,
513 "usage: shutdown [-] [-h | -p | -r | -k] [-o [-n]]"
514 " time [warning-message ...]\n");
537 "usage: shutdown [-] [-h | -p | -r | -k] [-o [-n]] time [warning-message ...]\n"
538 " poweroff\n");
515 exit(1);
516}
539 exit(1);
540}