Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/networking/slattach.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/networking/slattach.c
r1765 r2725 5 5 * Author: Ignacio Garcia Perez (iggarpe at gmail dot com) 6 6 * 7 * License : GPLv2 or later, see LICENSE file in this tarball.7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 8 8 * 9 9 * There are some differences from the standard net-tools slattach: … … 21 21 int saved_disc; 22 22 struct termios saved_state; 23 } ;23 } FIX_ALIASING; 24 24 #define G (*(struct globals*)&bb_common_bufsiz1) 25 25 #define handle (G.handle ) 26 26 #define saved_disc (G.saved_disc ) 27 27 #define saved_state (G.saved_state ) 28 #define INIT_G() do { } while (0)28 #define INIT_G() do { } while (0) 29 29 30 30 … … 44 44 } 45 45 46 static int set_termios_state_ and_warn(struct termios *state)46 static int set_termios_state_or_warn(struct termios *state) 47 47 { 48 48 int ret; … … 65 65 * as possible. 66 66 */ 67 static void restore_state_and_exit(int exitcode) ATTRIBUTE_NORETURN;67 static void restore_state_and_exit(int exitcode) NORETURN; 68 68 static void restore_state_and_exit(int exitcode) 69 69 { … … 79 79 cfsetispeed(&state, B0); 80 80 cfsetospeed(&state, B0); 81 if (set_termios_state_ and_warn(&state))81 if (set_termios_state_or_warn(&state)) 82 82 exitcode = 1; 83 83 sleep(1); 84 84 85 85 /* Restore line status */ 86 if (set_termios_state_ and_warn(&saved_state))86 if (set_termios_state_or_warn(&saved_state)) 87 87 exit(EXIT_FAILURE); 88 88 if (ENABLE_FEATURE_CLEAN_UP) … … 100 100 101 101 /* Set line status */ 102 if (set_termios_state_ and_warn(state))102 if (set_termios_state_or_warn(state)) 103 103 goto bad; 104 104 /* Set line discliple (N_SLIP always) */ … … 111 111 if (ioctl_or_warn(handle, SIOCSIFENCAP, &encap) < 0) { 112 112 bad: 113 restore_state_and_exit( 1);114 } 115 } 116 117 static void sig_handler(int signo )118 { 119 restore_state_and_exit( 0);120 } 121 122 int slattach_main(int argc, char **argv) ;123 int slattach_main(int argc , char **argv)113 restore_state_and_exit(EXIT_FAILURE); 114 } 115 } 116 117 static void sig_handler(int signo UNUSED_PARAM) 118 { 119 restore_state_and_exit(EXIT_SUCCESS); 120 } 121 122 int slattach_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 123 int slattach_main(int argc UNUSED_PARAM, char **argv) 124 124 { 125 125 /* Line discipline code table */ … … 135 135 struct termios state; 136 136 const char *proto = "cslip"; 137 const char *extcmd; 137 const char *extcmd; /* Command to execute after hangup */ 138 138 const char *baud_str; 139 int baud_code = -1; 139 int baud_code = -1; /* Line baud rate (system code) */ 140 140 141 141 enum { … … 176 176 /* Trap signals in order to restore tty states upon exit */ 177 177 if (!(opt & OPT_e_quit)) { 178 signal(SIGHUP, sig_handler); 179 signal(SIGINT, sig_handler); 180 signal(SIGQUIT, sig_handler); 181 signal(SIGTERM, sig_handler); 178 bb_signals(0 179 + (1 << SIGHUP) 180 + (1 << SIGINT) 181 + (1 << SIGQUIT) 182 + (1 << SIGTERM) 183 , sig_handler); 182 184 } 183 185 … … 205 207 | ((opt & OPT_L_local) ? CLOCAL : 0) 206 208 | ((opt & OPT_F_noflow) ? 0 : CRTSCTS); 209 cfsetispeed(&state, cfgetispeed(&saved_state)); 210 cfsetospeed(&state, cfgetospeed(&saved_state)); 207 211 } 208 212 … … 238 242 239 243 /* Restore states and exit */ 240 restore_state_and_exit( 0);241 } 244 restore_state_and_exit(EXIT_SUCCESS); 245 }
Note:
See TracChangeset
for help on using the changeset viewer.