/[gnokii]/gnokii/common/devices/unixserial.c
ViewVC logotype

Diff of /gnokii/common/devices/unixserial.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.37 by pkot, Wed Apr 20 20:37:41 2005 UTC revision 1.38 by pkot, Sun May 8 23:29:26 2005 UTC
# Line 133  int device_script(int fd, const char *se Line 133  int device_script(int fd, const char *se
133                  cfg_foreach(gn_cfg_info, section, device_script_cfgfunc);                  cfg_foreach(gn_cfg_info, section, device_script_cfgfunc);
134                  errno = 0;                  errno = 0;
135                  if (dup2(fd, 0) != 0 || dup2(fd, 1) != 1 || close(fd)) {                  if (dup2(fd, 0) != 0 || dup2(fd, 1) != 1 || close(fd)) {
136                          fprintf(stderr, _("device_script(\"%s\"): file descriptor prepare: %s\n"), scriptname, strerror(errno));                          fprintf(stderr, _("device_script(\"%s\"): file descriptor preparation failure: %s\n"), scriptname, strerror(errno));
137                          _exit(-1);                          _exit(-1);
138                  }                  }
139                  /* FIXME: close all open descriptors - how to track them?                  /* FIXME: close all open descriptors - how to track them?
140                   */                   */
141                  execl("/bin/sh", "sh", "-c", scriptname, NULL);                  execl("/bin/sh", "sh", "-c", scriptname, NULL);
142                  fprintf(stderr, _("device_script(\"%s\"): execute script: %s\n"), scriptname, strerror(errno));                  fprintf(stderr, _("device_script(\"%s\"): script exection failure: %s\n"), scriptname, strerror(errno));
143                  _exit(-1);                  _exit(-1);
144                  /* NOTREACHED */                  /* NOTREACHED */
145    
146          default:          default:
147                  if (pid == waitpid(pid, &status, 0 /* options */) && WIFEXITED(status) && !WEXITSTATUS(status))                  if (pid == waitpid(pid, &status, 0 /* options */) && WIFEXITED(status) && !WEXITSTATUS(status))
148                          return 0;                          return 0;
149                  fprintf(stderr, _("device_script(\"%s\"): child script failure: %s, exit code=%d\n"), scriptname,                  fprintf(stderr, _("device_script(\"%s\"): child script execution failure: %s, exit code=%d\n"), scriptname,
150                          (WIFEXITED(status) ? _("normal exit") : _("abnormal exit")),                          (WIFEXITED(status) ? _("normal exit") : _("abnormal exit")),
151                          (WIFEXITED(status) ? WEXITSTATUS(status) : -1));                          (WIFEXITED(status) ? WEXITSTATUS(status) : -1));
152                  errno = EIO;                  errno = EIO;
# Line 174  int serial_open(const char *file, int of Line 174  int serial_open(const char *file, int of
174    
175          retcode = tcgetattr(fd, &serial_termios);          retcode = tcgetattr(fd, &serial_termios);
176          if (retcode == -1) {          if (retcode == -1) {
177                  perror("Gnokii serial_open:tcgetattr");                  perror("Gnokii serial_open: tcgetattr");
178                  /* Don't call serial_close since serial_termios is not valid */                  /* Don't call serial_close since serial_termios is not valid */
179                  close(fd);                  close(fd);
180                  return -1;                  return -1;
# Line 189  int serial_close(int fd, struct gn_state Line 189  int serial_close(int fd, struct gn_state
189          /* handle config file disconnect_script:          /* handle config file disconnect_script:
190           */           */
191          if (device_script(fd, "disconnect_script", state) == -1)          if (device_script(fd, "disconnect_script", state) == -1)
192                  fprintf(stderr, _("Gnokii serial_close: disconnect_script\n"));                  dprintf("Gnokii serial_close: disconnect_script\n");
193    
194          if (fd >= 0) {          if (fd >= 0) {
195  #if 1 /* HACK */  #if 1 /* HACK */
# Line 277  int serial_opendevice(const char *file, Line 277  int serial_opendevice(const char *file,
277          /* handle config file connect_script:          /* handle config file connect_script:
278           */           */
279          if (device_script(fd, "connect_script", state) == -1) {          if (device_script(fd, "connect_script", state) == -1) {
280                  fprintf(stderr,"Gnokii serial_opendevice: connect_script\n");                  dprintf("Gnokii serial_opendevice: connect_script\n");
281                  serial_close(fd, state);                  serial_close(fd, state);
282                  return -1;                  return -1;
283          }          }
# Line 446  size_t serial_write(int fd, const __ptr_ Line 446  size_t serial_write(int fd, const __ptr_
446    
447  #ifndef TIOCMGET  #ifndef TIOCMGET
448          if (state->config.require_dcd)          if (state->config.require_dcd)
449                  fprintf(stderr, _("WARNING: global/require_dcd argument was set but it is not supported on this system!\n"));                  dprintf("WARNING: global/require_dcd argument was set but it is not supported on this system!\n");
450  #endif  #endif
451    
452          if (state->config.require_dcd)          if (state->config.require_dcd)

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26