dst[j] = '\0';
}
-void main(int argc, char *argv[])
+int main(int argc, char *argv[])
{
if (argc != 2) {
fprintf(stderr, " Usage: check-net --proxy\n");
fprintf(stderr, " check-net --interface-all\n");
fprintf(stderr, " check-net --bridge\n");
fprintf(stderr, " check-net --host-ip\n");
- return;
+ return 1;
}
if (strcmp(argv[1], ARG_PROXY) == 0) {
get_host_proxy_os();
} else if (strcmp(argv[1], ARG_INTERFACE_ALL) == 0) {
- get_host_interface_all_os();
+ return get_host_interface_all_os();
} else if (strcmp(argv[1], ARG_BRIDGE) == 0) {
- get_host_bridge_os();
+ return get_host_bridge_os();
} else if (strcmp(argv[1], ARG_HOST_IP) == 0) {
get_host_ip_os();
}
+ return 0;
}
extern const char *pac_tempfile;
void get_host_proxy_os(void);
-void get_host_interface_all_os(void);
-void get_host_bridge_os(void);
+int get_host_interface_all_os(void);
+int get_host_bridge_os(void);
void download_url(char *);
size_t write_data(void *, size_t, size_t, FILE *);
}
}
-void get_host_interface_all_os(void)
+int get_host_interface_all_os(void)
{
if (access(PATH_IFCONFIG, F_OK) != -1) {
system("/sbin/ifconfig -a");
+ return 0;
} else {
fprintf(stderr, "ifconfig does not exist!\n");
+ return 1;
}
}
-void get_host_bridge_os(void)
+int get_host_bridge_os(void)
{
if (access(PATH_IFCONFIG, F_OK) != -1) {
system("/sbin/ifconfig bridge1");
+ return 0;
} else {
fprintf(stderr, "ifconfig does not exist!\n");
+ return 1;
}
}
pclose(output);
}
-void get_host_interface_all_os(void)
+int get_host_interface_all_os(void)
{
if (access(PATH_IFCONFIG, F_OK) != -1) {
system("/sbin/ifconfig -a");
+ return 0;
} else {
fprintf(stderr, "ifconfig does not exist!\n");
+ return 1;
}
}
-void get_host_bridge_os(void)
+int get_host_bridge_os(void)
{
if (access(PATH_IFCONFIG, F_OK) != -1) {
system("/sbin/ifconfig bridge1");
+ return 0;
} else {
fprintf(stderr, "ifconfig does not exist!\n");
+ return 1;
}
}
fprintf(stdout, "\n");
}
-static void get_host_interface(int value)
+static int get_host_interface(int value)
{
PIP_ADAPTER_ADDRESSES pAddresses = NULL;
PIP_ADAPTER_ADDRESSES pCurrAddresses = NULL;
pAddresses = (IP_ADAPTER_ADDRESSES *) MALLOC(outBufLen);
if (pAddresses == NULL) {
fprintf(stderr, "Memory allocation failed for IP_ADAPTER_ADDRESSES struct\n");
- return;
+ return 1;
}
dwRetAddressVal = GetAdaptersAddresses(AF_INET, flags, NULL, pAddresses, &outBufLen);
pAdapterInfo = (IP_ADAPTER_INFO *) MALLOC(sizeof (IP_ADAPTER_INFO));
if (pAdapterInfo == NULL) {
fprintf(stderr, "Error allocating memory needed to call GetAdaptersinfo\n");
- return;
+ return 1;
}
if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) {
FREE(pAdapterInfo);
pAdapterInfo = (IP_ADAPTER_INFO *) MALLOC(ulOutBufLen);
if (pAdapterInfo == NULL) {
fprintf(stderr, "Error allocating memory needed to call GetAdaptersinfo\n");
- return;
+ return 1;
}
}
dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
}
} else {
fprintf(stderr, "GetAdaptersInfo failed with error: %d\n", dwRetVal);
- return;
+ return 1;
}
if (pAdapterInfo)
FREE(pAdapterInfo);
+ return 0;
}
-void get_host_interface_all_os(void)
+int get_host_interface_all_os(void)
{
- get_host_interface(ALL_INTERFACE);
+ return get_host_interface(ALL_INTERFACE);
}
-void get_host_bridge_os(void)
+int get_host_bridge_os(void)
{
- get_host_interface(BRIDGE_ONLY);
+ return get_host_interface(BRIDGE_ONLY);
}
void get_host_ip_os(void)