summaryrefslogtreecommitdiff
path: root/games/morse/morse.c
diff options
context:
space:
mode:
Diffstat (limited to 'games/morse/morse.c')
-rw-r--r--games/morse/morse.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/games/morse/morse.c b/games/morse/morse.c
index be4d06d6646..ae246ad67e0 100644
--- a/games/morse/morse.c
+++ b/games/morse/morse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: morse.c,v 1.20 2016/01/18 11:27:19 sthen Exp $ */
+/* $OpenBSD: morse.c,v 1.21 2016/01/19 23:21:26 sthen Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -82,6 +82,7 @@ struct punc {
char c;
char *morse;
} other[] = {
+ { 'e', "..-.." }, /* accented e - only decodes */
{ ',', "--..--" },
{ '.', ".-.-.-" },
{ '?', "..--.." },
@@ -89,17 +90,34 @@ struct punc {
{ '-', "-....-" },
{ ':', "---..." },
{ ';', "-.-.-." },
- { '(', "-.--." },
+ { '(', "-.--." }, /* KN */
{ ')', "-.--.-" },
{ '"', ".-..-." },
{ '`', ".-..-." },
{ '\'', ".----." },
- { '+', ".-.-." }, /* AR */
- { '=', "-...-" }, /* BT */
- { '@', "...-.-" }, /* SK */
+ { '+', ".-.-." }, /* AR \n\n\n */
+ { '=', "-...-" }, /* BT \n\n */
+ { '@', ".--.-." },
+ { '\n', ".-.-" }, /* AA (will only decode) */
{ '\0', NULL }
};
+struct prosign {
+ char *c;
+ char *morse;
+} ps[] = {
+ { "<AS>", ".-..." }, /* wait */
+ { "<CL>", "-.-..-.." },
+ { "<CT>", "-.-.-" }, /* start */
+ { "<EE5>", "......" }, /* error */
+ { "<EE5>", "......." },
+ { "<EE5>", "........" },
+ { "<SK>", "...-.-" },
+ { "<SN>", "...-." }, /* understood */
+ { "<SOS>", "...---..." },
+ { NULL, NULL }
+};
+
void morse(int);
void decode(char *);
void show(char *);
@@ -233,6 +251,15 @@ decode(char *s)
}
i++;
}
+ i = 0;
+ while (ps[i].c) {
+ /* put whitespace around prosigns */
+ if (strcmp(ps[i].morse, s) == 0) {
+ printf(" %s ", ps[i].c);
+ return;
+ }
+ i++;
+ }
putchar('x'); /* line noise */
}