/* * 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); }