diff options
Diffstat (limited to 'spo256/speak.c')
-rw-r--r-- | spo256/speak.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/spo256/speak.c b/spo256/speak.c new file mode 100644 index 0000000..7de099f --- /dev/null +++ b/spo256/speak.c @@ -0,0 +1,86 @@ +/* + * Base (main) for spo server. + * $Id: speak.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. + * + * Abstract: + * Establish basic operating environment for SPO256-AL2 text-to-speech + * server. This module verifies system configuration, parses the + * config files for word lists that are stored in the quick-lookup + * internal hash word subsitution database, binds the server to a tcp + * network port, and accepts client requests. + */ + +#include <proc/process.h> +#include <std/string.h> +#include <std/files.h> +#include <other/config.h> +#include <net/socket.h> +#include <net/stream.h> +#include "speak.h" + +int spo; /* device id of spo */ +FILE *io; + +void main(int argc, char **argv) +{ + int port = getservice("speak"); + CONFIG *cfg; + SOCKET so; + char buf[1024]; + + if(!port) + fatal(EX_UNAVAILABLE, "spo256: speak: service not defined in /etc/services\n"); + + if(argc < 1 || argc > 2) + fatal(EX_USAGE, "use: spo256 [hostname]\n"); + + if(argc > 1) + client(argv[1], port); + + if(!stricmp(pathfname(argv[0]), "speak")) + client("localhost", port); + + if(NULL == (cfg = sys_config("speak"))) + fatal(EX_CONFIG, "spo256: speak.conf: config file missing\n"); + + /* get device configuration */ + + spo = getspo(cfg); + + getidx(cfg); + close_config(cfg); + + /* bind server to socket */ + + so = tcpsocket(mask, port, 5); + if(so == INVALID_SOCKET) + fatal(EX_UNAVAILABLE, "spo256: %d: failed to bind port\n", port); + + /* now, make ourselves a daemon */ + + pdetach(D_KEEPNONIO); + + /* Main loop of server. The server accepts one connection in + turn from each requesting user application. The remaining + application requests are kept in backlog while the current + application is served. This assures non-overlapping speech. + */ + + for(;;) + { + io = accepttcp(so); + if(!io) + continue; + + spo_init(); + puttcp("SPO256-AL2 Text-to-Speech Server 1.0\r\n", io); + + chars(io); + + spo_pause(P_END); + closetcp(io); + } +} + |