diff options
author | William Harrington <kb0iic@berzerkula.org> | 2025-01-14 16:06:02 -0600 |
---|---|---|
committer | William Harrington <kb0iic@berzerkula.org> | 2025-01-14 16:06:02 -0600 |
commit | 0cc9b20c15460213e488bf5e70963b941482f628 (patch) | |
tree | bb0143245583ec846630f39bfa2258dba640ccd7 /spo256/getspo.c | |
parent | 0e084ade5069756d487b5c948c48b777e37c00c9 (diff) |
Add source.
Diffstat (limited to 'spo256/getspo.c')
-rw-r--r-- | spo256/getspo.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/spo256/getspo.c b/spo256/getspo.c new file mode 100644 index 0000000..5ff64d7 --- /dev/null +++ b/spo256/getspo.c @@ -0,0 +1,68 @@ +/* + * Parse .conf file interface spec for spo communications. + * $Id: getspo.c 1.2 Mon, 24 Mar 1997 12:25:37 -0500 dyfet $ + * Copyright (c) 1997 by Tycho Softworks. + * For conditions of distribution and reuse see product license. + */ + +#include <other/string.h> +#include <other/config.h> +#include <std/files.h> +#include <proc/process.h> +#include <dev/tty.h> + +char *mask = NULL; + +int getspo(CONFIG *cfg) +{ + int spo = -1; + char *p; + stty_t stty; + + if(!seek_config(cfg, "interface")) + fatal(EX_CONFIG, "spo256: [interface]: missing from speak.conf\n"); + + while(NULL != read_config(cfg)) + { + if(NULL != (p = get_config(cfg, "bind"))) + { + mask = strdup(p); + continue; + } + + if(NULL != (p = get_config(cfg, "device"))) + { + spo = open(p, O_RDWR); + if(spo < 0) + fatal(EX_UNAVAILABLE, "spo256: %s: cannot access\n", p); + stty = getstty(spo); + interactive(stty, FALSE); + setflowctrl(stty, FC_HARD); + continue; + } + + if(NULL != (p = get_config(cfg, "speed"))) + { + if(spo < 0) + fatal(EX_CONFIG, "spo256: set speed for unspecified device\n"); + setspeed(stty, atol(p)); + continue; + } + + if(NULL != (p = get_config(cfg, "parity"))) + { + if(spo < 0) + fatal(EX_CONFIG, "spo256: set format for unspecified device\n"); + if(!stricmp(p, "even")) + setformat(stty, "7e1"); + if(!stricmp(p, "odd")) + setformat(stty, "7o1"); + if(!stricmp(p, "none")) + setformat(stty, "8n1"); + continue; + } + } + putstty(spo, stty, TRUE); + return spo; +} + |