aboutsummaryrefslogtreecommitdiffstats
path: root/spo256/spo.c
diff options
context:
space:
mode:
authorWilliam Harrington <kb0iic@berzerkula.org>2025-01-14 16:06:02 -0600
committerWilliam Harrington <kb0iic@berzerkula.org>2025-01-14 16:06:02 -0600
commit0cc9b20c15460213e488bf5e70963b941482f628 (patch)
treebb0143245583ec846630f39bfa2258dba640ccd7 /spo256/spo.c
parent0e084ade5069756d487b5c948c48b777e37c00c9 (diff)
Add source.
Diffstat (limited to 'spo256/spo.c')
-rw-r--r--spo256/spo.c161
1 files changed, 161 insertions, 0 deletions
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 <other/config.h>
+#include <other/string.h>
+#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 <ESC><cmd>
+ * 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);
+}
+