Changes: * Move network interface configuration logic from bin/pattyd.c to bin/if.c; implement a more robust state machine * Move KISS TNC configuration code from bin/pattyd.c to bin/kiss.c * Ensure configuration file name, line number, and erroneous part of an expression are clearly indicated upon failure Other changes: * Improve bin/Makefile to rebuild objects when accompanying header files change * Refer to HEADERS_SUBDIR, not HEADER_SUBDIR, in Makefiles
39 lines
1.1 KiB
C
39 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include <patty/bin/kiss.h>
|
|
|
|
int patty_bin_kiss_config(patty_bin_kiss_data *data, int argc, char **argv) {
|
|
int i;
|
|
|
|
patty_kiss_tnc_info *info = &data->info;
|
|
|
|
info->flags |= PATTY_KISS_TNC_DEVICE;
|
|
info->device = argv[0];
|
|
|
|
for (i=1; i<argc; i++) {
|
|
if (strcmp(argv[i], "crtscts") == 0) {
|
|
info->flags |= PATTY_KISS_TNC_FLOW;
|
|
info->flow = PATTY_KISS_TNC_FLOW_CRTSCTS;
|
|
} else if (strcmp(argv[i], "xonxoff") == 0) {
|
|
info->flags |= PATTY_KISS_TNC_FLOW;
|
|
info->flow = PATTY_KISS_TNC_FLOW_XONXOFF;
|
|
} else if (argv[i][0] >= '0' && argv[i][0] <= '9') {
|
|
int baud = atoi(argv[i]);
|
|
|
|
info->flags |= PATTY_KISS_TNC_BAUD;
|
|
info->baud = baud;
|
|
} else {
|
|
snprintf(data->err, sizeof(data->err)-1,
|
|
"Invalid KISS TNC device parameter '%s'", argv[i]);
|
|
|
|
goto error_invalid_device_setting;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
|
|
error_invalid_device_setting:
|
|
return -1;
|
|
}
|