Use bools and enums where appropriate.
This commit is contained in:
parent
471308e163
commit
eefa28059a
40 changed files with 767 additions and 765 deletions
|
@ -17,7 +17,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
$Id: device.c,v 1.1.2.1 2003/07/21 15:51:00 guus Exp $
|
||||
$Id: device.c,v 1.1.2.2 2003/07/22 20:55:21 guus Exp $
|
||||
*/
|
||||
|
||||
#error "Device driver for MinGW environment not written yet!"
|
||||
|
@ -85,7 +85,7 @@ HANDLE handle;
|
|||
pid_t reader_pid;
|
||||
int sp[2];
|
||||
|
||||
int setup_device(void)
|
||||
bool setup_device(void)
|
||||
{
|
||||
HKEY key, key2, adapterkey;
|
||||
int i;
|
||||
|
@ -109,7 +109,7 @@ int setup_device(void)
|
|||
|
||||
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, (OSTYPE > 4 ? NETCARD_REG_KEY_2000 : NETCARD_REG_KEY), 0, KEY_READ, &key)) {
|
||||
logger(LOG_ERR, _("Unable to read registry"));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; ; i++) {
|
||||
|
@ -121,7 +121,7 @@ int setup_device(void)
|
|||
|
||||
if(RegOpenKeyEx (key, adapterid, 0, KEY_READ, &adapterkey)) {
|
||||
logger(LOG_ERR, _("Unable to read registry"));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
len = sizeof(productname);
|
||||
|
@ -147,7 +147,7 @@ skip:
|
|||
|
||||
if(!found) {
|
||||
logger(LOG_ERR, _("No CIPE adapters found!"));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Get adapter name */
|
||||
|
@ -167,14 +167,14 @@ skip:
|
|||
|
||||
if(socketpair(AF_UNIX, SOCK_DGRAM, PF_UNIX, sp)) {
|
||||
logger(LOG_DEBUG, _("System call `%s' failed: %s"), "socketpair", strerror(errno));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
reader_pid = fork();
|
||||
|
||||
if(reader_pid == -1) {
|
||||
logger(LOG_DEBUG, _("System call `%s' failed: %s"), "fork", strerror(errno));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!reader_pid) {
|
||||
|
@ -214,7 +214,7 @@ skip:
|
|||
|
||||
if(handle == INVALID_HANDLE_VALUE) {
|
||||
logger(LOG_ERR, _("Could not open CIPE tap device for writing!"));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
device_fd = sp[0];
|
||||
|
@ -229,7 +229,7 @@ skip:
|
|||
read(device_fd, &gelukt, 1);
|
||||
if(gelukt != 1) {
|
||||
logger(LOG_DEBUG, "Tap reader failed!");
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!get_config_string(lookup_config(config_tree, "Interface"), &iface))
|
||||
|
@ -239,7 +239,7 @@ skip:
|
|||
|
||||
logger(LOG_INFO, _("%s is a %s"), device, device_info);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void close_device(void)
|
||||
|
@ -253,7 +253,7 @@ void close_device(void)
|
|||
kill(reader_pid, SIGKILL);
|
||||
}
|
||||
|
||||
int read_packet(vpn_packet_t *packet)
|
||||
bool read_packet(vpn_packet_t *packet)
|
||||
{
|
||||
int lenin;
|
||||
|
||||
|
@ -262,7 +262,7 @@ int read_packet(vpn_packet_t *packet)
|
|||
if((lenin = read(sp[0], packet->data, MTU)) <= 0) {
|
||||
logger(LOG_ERR, _("Error while reading from %s %s: %s"), device_info,
|
||||
device, strerror(errno));
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
packet->len = lenin;
|
||||
|
@ -272,10 +272,10 @@ int read_packet(vpn_packet_t *packet)
|
|||
ifdebug(TRAFFIC) logger(LOG_DEBUG, _("Read packet of %d bytes from %s"), packet->len,
|
||||
device_info);
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int write_packet(vpn_packet_t *packet)
|
||||
bool write_packet(vpn_packet_t *packet)
|
||||
{
|
||||
int lenout;
|
||||
|
||||
|
@ -286,12 +286,12 @@ int write_packet(vpn_packet_t *packet)
|
|||
|
||||
if(!WriteFile (handle, packet->data, packet->len, &lenout, NULL)) {
|
||||
logger(LOG_ERR, "Error while writing to %s %s", device_info, device);
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
device_total_out += packet->len;
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void dump_device_stats(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue