summaryrefslogtreecommitdiffstats
path: root/axconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'axconfig.c')
-rw-r--r--axconfig.c148
1 files changed, 74 insertions, 74 deletions
diff --git a/axconfig.c b/axconfig.c
index 1b7077c..84199c1 100644
--- a/axconfig.c
+++ b/axconfig.c
@@ -237,13 +237,13 @@ static int ax25_config_init_port(int fd, int lineno, char *line, const char **if
found = 0;
char *cp;
if ((cp = strstr(call, "-0")) != NULL)
- *cp = '\0';
+ *cp = '\0';
for (;ifcalls && *ifcalls; ++ifcalls, ++ifdevs) {
- if (strcmp(call, *ifcalls) == 0) {
- found = 1;
- dev = *ifdevs;
- break;
- }
+ if (strcmp(call, *ifcalls) == 0) {
+ found = 1;
+ dev = *ifdevs;
+ break;
+ }
}
if (!found) {
@@ -294,83 +294,83 @@ int ax25_config_load_ports(void)
if ((fd = socket(PF_FILE, SOCK_DGRAM, 0)) < 0) {
- fprintf(stderr, "axconfig: unable to open socket (%s)\n", strerror(errno));
- goto cleanup;
+ fprintf(stderr, "axconfig: unable to open socket (%s)\n", strerror(errno));
+ goto cleanup;
}
if ((fp = fopen("/proc/net/dev", "r"))) {
- /* Two header lines.. */
- s = fgets(buffer, sizeof(buffer), fp);
- s = fgets(buffer, sizeof(buffer), fp);
- /* .. then network interface names */
- while (!feof(fp)) {
- if (!fgets(buffer, sizeof(buffer), fp))
- break;
- s = strchr(buffer, ':');
- if (s) *s = 0;
- s = buffer;
- while (isspace(*s & 0xff)) ++s;
-
- memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, s, IFNAMSIZ-1);
- ifr.ifr_name[IFNAMSIZ-1] = 0;
-
- if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {
- fprintf(stderr, "axconfig: SIOCGIFHWADDR: %s\n", strerror(errno));
- return FALSE;
- }
-
- if (ifr.ifr_hwaddr.sa_family != ARPHRD_AX25)
- continue;
-
- /* store found interface callsigns */
- /* ax25_ntoa() returns pointer to static buffer */
- s = ax25_ntoa((void*)ifr.ifr_hwaddr.sa_data);
-
- if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
- fprintf(stderr, "axconfig: SIOCGIFFLAGS: %s\n", strerror(errno));
- return FALSE;
- }
-
- if (!(ifr.ifr_flags & IFF_UP))
- continue;
-
- if ((pp = realloc(calllist, sizeof(char *) * (callcount+2))) == 0)
- break;
- calllist = pp;
- if ((pp = realloc(devlist, sizeof(char *) * (callcount+2))) == 0)
- break;
- devlist = pp;
- if ((calllist[callcount] = strdup(s)) != NULL) {
- if ((devlist[callcount] = strdup(ifr.ifr_name)) != NULL) {
- ++callcount;
- calllist[callcount] = NULL;
- devlist [callcount] = NULL;
- } else {
- free((void*)calllist[callcount]);
- calllist[callcount] = NULL;
- }
- }
- }
- fclose(fp);
- fp = NULL;
+ /* Two header lines.. */
+ s = fgets(buffer, sizeof(buffer), fp);
+ s = fgets(buffer, sizeof(buffer), fp);
+ /* .. then network interface names */
+ while (!feof(fp)) {
+ if (!fgets(buffer, sizeof(buffer), fp))
+ break;
+ s = strchr(buffer, ':');
+ if (s) *s = 0;
+ s = buffer;
+ while (isspace(*s & 0xff)) ++s;
+
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, s, IFNAMSIZ-1);
+ ifr.ifr_name[IFNAMSIZ-1] = 0;
+
+ if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {
+ fprintf(stderr, "axconfig: SIOCGIFHWADDR: %s\n", strerror(errno));
+ return FALSE;
+ }
+
+ if (ifr.ifr_hwaddr.sa_family != ARPHRD_AX25)
+ continue;
+
+ /* store found interface callsigns */
+ /* ax25_ntoa() returns pointer to static buffer */
+ s = ax25_ntoa((void*)ifr.ifr_hwaddr.sa_data);
+
+ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
+ fprintf(stderr, "axconfig: SIOCGIFFLAGS: %s\n", strerror(errno));
+ return FALSE;
+ }
+
+ if (!(ifr.ifr_flags & IFF_UP))
+ continue;
+
+ if ((pp = realloc(calllist, sizeof(char *) * (callcount+2))) == 0)
+ break;
+ calllist = pp;
+ if ((pp = realloc(devlist, sizeof(char *) * (callcount+2))) == 0)
+ break;
+ devlist = pp;
+ if ((calllist[callcount] = strdup(s)) != NULL) {
+ if ((devlist[callcount] = strdup(ifr.ifr_name)) != NULL) {
+ ++callcount;
+ calllist[callcount] = NULL;
+ devlist [callcount] = NULL;
+ } else {
+ free((void*)calllist[callcount]);
+ calllist[callcount] = NULL;
+ }
+ }
+ }
+ fclose(fp);
+ fp = NULL;
}
if ((fp = fopen(CONF_AXPORTS_FILE, "r")) == NULL) {
- fprintf(stderr, "axconfig: unable to open axports file %s (%s)\n", CONF_AXPORTS_FILE, strerror(errno));
- goto cleanup;
+ fprintf(stderr, "axconfig: unable to open axports file %s (%s)\n", CONF_AXPORTS_FILE, strerror(errno));
+ goto cleanup;
}
while (fp && fgets(buffer, 255, fp)) {
- if ((s = strchr(buffer, '\n')))
- *s = '\0';
+ if ((s = strchr(buffer, '\n')))
+ *s = '\0';
- if (strlen(buffer) > 0 && *buffer != '#')
- if (ax25_config_init_port(fd, lineno, buffer, calllist, devlist))
- n++;
+ if (strlen(buffer) > 0 && *buffer != '#')
+ if (ax25_config_init_port(fd, lineno, buffer, calllist, devlist))
+ n++;
- lineno++;
+ lineno++;
}
cleanup:;
@@ -378,9 +378,9 @@ int ax25_config_load_ports(void)
if (fp) fclose(fp);
for (i = 0; calllist && calllist[i]; ++i) {
- free((void*)calllist[i]);
- if (devlist[i] != NULL)
- free((void*)devlist[i]);
+ free((void*)calllist[i]);
+ if (devlist[i] != NULL)
+ free((void*)devlist[i]);
}
if (calllist) free(calllist);
if (devlist) free(devlist);