leave.c (948a3f54a76846f76f78b9c712254e5b22df9fe2) leave.c (e1b4d8d0746069292d84708b0e11b17a7e1ef5e0)
1/*
2 * Copyright (c) 1980, 1988, 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

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

76 int plusnow, t_12_hour;
77 char buf[50];
78
79 if (setlocale(LC_TIME, "") == NULL)
80 warn("setlocale");
81
82 if (argc < 2) {
83#define MSG1 "When do you have to leave? "
1/*
2 * Copyright (c) 1980, 1988, 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

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

76 int plusnow, t_12_hour;
77 char buf[50];
78
79 if (setlocale(LC_TIME, "") == NULL)
80 warn("setlocale");
81
82 if (argc < 2) {
83#define MSG1 "When do you have to leave? "
84 (void)write(1, MSG1, sizeof(MSG1) - 1);
84 (void)write(STDOUT_FILENO, MSG1, sizeof(MSG1) - 1);
85 cp = fgets(buf, sizeof(buf), stdin);
86 if (cp == NULL || *cp == '\n')
87 exit(0);
88 } else if (argc > 2)
89 usage();
90 else
91 cp = argv[1];
92

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

161 /*
162 * if write fails, we've lost the terminal through someone else
163 * causing a vhangup by logging in.
164 */
165#define FIVEMIN (5 * 60)
166#define MSG2 "\07\07You have to leave in 5 minutes.\n"
167 if (secs >= FIVEMIN) {
168 sleep(secs - FIVEMIN);
85 cp = fgets(buf, sizeof(buf), stdin);
86 if (cp == NULL || *cp == '\n')
87 exit(0);
88 } else if (argc > 2)
89 usage();
90 else
91 cp = argv[1];
92

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

161 /*
162 * if write fails, we've lost the terminal through someone else
163 * causing a vhangup by logging in.
164 */
165#define FIVEMIN (5 * 60)
166#define MSG2 "\07\07You have to leave in 5 minutes.\n"
167 if (secs >= FIVEMIN) {
168 sleep(secs - FIVEMIN);
169 if (write(1, MSG2, sizeof(MSG2) - 1) != sizeof(MSG2) - 1)
169 if (write(STDOUT_FILENO, MSG2, sizeof(MSG2) - 1) != sizeof(MSG2) - 1)
170 exit(0);
171 secs = FIVEMIN;
172 }
173
174#define ONEMIN (60)
175#define MSG3 "\07\07Just one more minute!\n"
176 if (secs >= ONEMIN) {
177 sleep(secs - ONEMIN);
170 exit(0);
171 secs = FIVEMIN;
172 }
173
174#define ONEMIN (60)
175#define MSG3 "\07\07Just one more minute!\n"
176 if (secs >= ONEMIN) {
177 sleep(secs - ONEMIN);
178 if (write(1, MSG3, sizeof(MSG3) - 1) != sizeof(MSG3) - 1)
178 if (write(STDOUT_FILENO, MSG3, sizeof(MSG3) - 1) != sizeof(MSG3) - 1)
179 exit(0);
180 }
181
182#define MSG4 "\07\07Time to leave!\n"
183 for (bother = 10; bother--;) {
184 sleep((u_int)ONEMIN);
179 exit(0);
180 }
181
182#define MSG4 "\07\07Time to leave!\n"
183 for (bother = 10; bother--;) {
184 sleep((u_int)ONEMIN);
185 if (write(1, MSG4, sizeof(MSG4) - 1) != sizeof(MSG4) - 1)
185 if (write(STDOUT_FILENO, MSG4, sizeof(MSG4) - 1) != sizeof(MSG4) - 1)
186 exit(0);
187 }
188
189#define MSG5 "\07\07That was the last time I'll tell you. Bye.\n"
186 exit(0);
187 }
188
189#define MSG5 "\07\07That was the last time I'll tell you. Bye.\n"
190 (void)write(1, MSG5, sizeof(MSG5) - 1);
190 (void)write(STDOUT_FILENO, MSG5, sizeof(MSG5) - 1);
191 exit(0);
192}
193
194static void
195usage()
196{
197 fprintf(stderr, "usage: leave [[+]hhmm]\n");
198 exit(1);
199}
191 exit(0);
192}
193
194static void
195usage()
196{
197 fprintf(stderr, "usage: leave [[+]hhmm]\n");
198 exit(1);
199}