- merge and move execute_script functions to eth.cc

This commit is contained in:
Christophe Bothamy 2003-04-26 14:48:45 +00:00
parent ffb9fcf69e
commit 18e2900f02
4 changed files with 35 additions and 67 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: eth.cc,v 1.14 2002-11-20 19:06:22 bdenney Exp $
// $Id: eth.cc,v 1.15 2003-04-26 14:48:45 cbothamy Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -149,4 +149,34 @@ eth_locator_c::create(const char *type, const char *netif,
return (NULL);
}
int execute_script( char* scriptname, char* arg1 )
{
int pid,status;
if (!(pid=fork())) {
char filename[BX_PATHNAME_LEN];
if ( scriptname[0]=='/' ) {
strcpy (filename, scriptname);
}
else {
getcwd (filename, BX_PATHNAME_LEN);
strcat (filename, "/");
strcat (filename, scriptname);
}
// execute the script
BX_INFO(("Executing script '%s %s'",filename,arg1));
execle(filename, scriptname, arg1, NULL, NULL);
// if we get here there has been a problem
exit(-1);
}
wait (&status);
if (!WIFEXITED(status)) {
return -1;
}
return WEXITSTATUS(status);
}
#endif /* if BX_NE2K_SUPPORT */

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: eth.h,v 1.11 2002-09-02 16:56:24 bdenney Exp $
// $Id: eth.h,v 1.12 2003-04-26 14:48:45 cbothamy Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -31,6 +31,7 @@
typedef void (*eth_rx_handler_t)(void *arg, const void *buf, unsigned len);
int execute_script(char *name, char* arg1);
//
// The eth_pktmover class is used by ethernet chip emulations

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: eth_tap.cc,v 1.13 2003-04-26 13:31:23 cbothamy Exp $
// $Id: eth_tap.cc,v 1.14 2003-04-26 14:48:45 cbothamy Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -113,8 +113,6 @@
#define BX_ETH_TAP_LOGGING 1
#define BX_PACKET_BUFSIZ 2048 // Enough for an ether frame
int execute_script(char *name, char* arg1);
//
// Define the class. This is private to this module
//
@ -367,34 +365,4 @@ void bx_tap_pktmover_c::rx_timer ()
(*rxh)(rxarg, rxbuf, nbytes);
}
int execute_script( char* scriptname, char* arg1 )
{
int pid,status;
if (!(pid=fork())) {
char filename[BX_PATHNAME_LEN];
if ( scriptname[0]=='/' ) {
strcpy (filename, scriptname);
}
else {
getcwd (filename, BX_PATHNAME_LEN);
strcat (filename, "/");
strcat (filename, scriptname);
}
// execute the script
BX_INFO(("Executing script '%s %s'",filename,arg1));
execle(filename, scriptname, arg1, NULL, NULL);
// if we get here there has been a problem
exit(-1);
}
wait (&status);
if (!WIFEXITED(status)) {
return -1;
}
return WEXITSTATUS(status);
}
#endif /* if BX_NE2K_SUPPORT */

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: eth_tuntap.cc,v 1.8 2003-02-16 19:35:57 vruppert Exp $
// $Id: eth_tuntap.cc,v 1.9 2003-04-26 14:48:45 cbothamy Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -113,7 +113,6 @@
#define BX_PACKET_BUFSIZ 2048 // Enough for an ether frame
int tun_alloc(char *dev);
int execute_script(char *name, char* arg1);
//
// Define the class. This is private to this module
@ -399,34 +398,4 @@ void bx_tuntap_pktmover_c::rx_timer ()
return fd;
}
int execute_script( char* scriptname, char* arg1 )
{
int pid,status;
if (!(pid=fork())) {
char filename[BX_PATHNAME_LEN];
if ( scriptname[0]=='/' ) {
strcpy (filename, scriptname);
}
else {
getcwd (filename, BX_PATHNAME_LEN);
strcat (filename, "/");
strcat (filename, scriptname);
}
// execute the script
BX_INFO(("Executing script '%s %s'",filename,arg1));
execle(filename, scriptname, arg1, NULL, NULL);
// if we get here there has been a problem
exit(-1);
}
wait (&status);
if (!WIFEXITED(status)) {
return -1;
}
return WEXITSTATUS(status);
}
#endif /* if BX_NE2K_SUPPORT */