From 0cc9b20c15460213e488bf5e70963b941482f628 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Tue, 14 Jan 2025 16:06:02 -0600 Subject: Add source. --- spo256/spo.c | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 spo256/spo.c (limited to 'spo256/spo.c') diff --git a/spo256/spo.c b/spo256/spo.c new file mode 100644 index 0000000..5c4f7ec --- /dev/null +++ b/spo256/spo.c @@ -0,0 +1,161 @@ +/* + * SPO256 low level operations. + * $Id: spo.c 1.2 Mon, 24 Mar 1997 12:25:37 -0500 dyfet $ + * Copyright (c) 1997 by Tycho Softworks. + * For conditions on distribution and reuse see product license. + * + * Abstract: + * Key SPO translation modules. This includes the word substution + * module, the numeric pronounciation system, pause control, and + * other low level spo services. + */ + +#include +#include +#include "speak.h" + +/* + * Flags and operating mode properties that may now be effected by + * server commands. + */ + +bool echo = FALSE; /* echo SPO output to user? */ +bool spell = FALSE; /* spell all words? */ +bool lit = FALSE; /* literally pronounce as is? */ + +/* + * A new 'init' function is added to initialize operating state for + * each new connection. This assures that spo command sequences + * issued from a previous session are not left in effect. + */ + +void spo_init(void) +{ + echo = FALSE; /* echo off by default */ + spell = FALSE; + lit = FALSE; +}; + +/* + * Interpret server specific commands embedded in + * sequences. The SPO has limited options to effect in this manner. + */ + +void spo_cmd(char *str) +{ + if(!stricmp(str, "echo")) + { + echo = TRUE; + return; + } + + if(!stricmp(str, "/echo")) + { + echo = FALSE; + return; + } + + if(!stricmp(str, "spell")) + { + spell = TRUE; + return; + } + + if(!stricmp(str, "/spell")) + { + spell = FALSE; + return; + } + + if(!stricmp(str, "lit")) + { + lit = TRUE; + return; + } + + if(!stricmp(str, "/lit")) + { + lit = FALSE; + return; + } +}; + +/* + * Pause spo output between words, numbers, and empty lines, so that + * words are properly announciated. This is typically accomplished with + * spaces and newline control. + */ + +void spo_pause(PAUSE p) +{ + switch(p) + { + case P_WORD: + write(spo, " ", 1); + if(echo) + puttcp(" ", io); + break; + case P_SENTANCE: + write(spo, " \n", 2); + if(echo) + puttcp(" \n", io); + break; + case P_LINE: + write(spo, " \r\n", 3); + if(echo) + puttcp(" \r\n", io); + break; + case P_END: + write(spo, "\r\n", 2); + } +} + +/* Announce quoted text. */ + +void spo_begquote(void) +{ + spo_word("quote"); +} + +void spo_endquote(void) +{ + spo_word("end"); + spo_begquote(); +} + +/* + * This performs low level lookup and pronounciation of words, either + * in the originally submitted spelling, or in the spo dictionary + * spelling. + */ + +void spo_word(char *word) +{ + char *p = find(widx, word); + if(!p) + p = word; + + if(lit) + p = word; + + if(spell) + { + p = word; + while(*p) + { + write(spo, p, 1); + if(echo) + fputc(*p, io); + spo_pause(P_WORD); + ++p; + } + } + else + { + write(spo, p, strlen(p)); + if(echo) + puttcp(p, io); + } + spo_pause(P_WORD); +} + -- cgit v1.2.3-54-g00ecf