/* decode_mode.c - Translate 5-character modes to sed expressions */ /* * Copyright (C) 1995 Jeffrey Chilton * * Permission is granted to anyone to make or distribute copies of * this program, in any medium, provided that the copyright notice * and permission notice are preserved, and that the distributor * grants the recipient permission for further redistribution as * permitted by this notice. * * Author's E-mail address: jwc@chilton.com * */ #include char *NoiseBlanker[4] = {"OFF", "NARROW", "?", "WIDE"}; char *AGC[4] = {"OFF", "?", "FAST", "SLOW"}; char *RF[4] = {"OFF", "ATTN", "PRE", "?"}; char *Notch_Filter[2] = {"OFF", "ON"}; char *Antenna[4] = {"1", "CONV", "2", "?"}; char *Mode[8] = {"LSB", "USB", "RTTY", "CW", "NFM", "AM", "?", "?"}; char *Bandwidth[8] = {"0.5", "1.8", "2.3", "4.0", "6.0", "?", "?", "?"}; char *BFO[2] = {"B", "A"}; char *Synchro[2] = {"OFF", "ON"}; char *Scanning[2] = {"OFF", "ON"}; struct Field { char *name; int width; char **values; }; #define N_FIELDS 12 struct Field Fields[N_FIELDS] = { "NoiseBlanker", 2, NoiseBlanker, "AGC", 2, AGC, "RF", 2, RF, "Notch_Filter", 1, Notch_Filter, "", 1, (char **)0, "Antenna", 2, Antenna, "Mode", 3, Mode, "Bandwidth", 3, Bandwidth, "VFO", 1, BFO, "Synchro", 1, Synchro, "Scanning", 1, Scanning, "", 1, (char **)0 }; main() { register int i; char line[80]; long status; char *t; fgets(line, 80, stdin); while (!feof(stdin)) { status = 0; for (i = 0; i < 5; i++) { if ((line[i] & 0xF0) != 0x30) { exit(1); } status <<= 4; status += line[i] & 0x0F; } for (i = N_FIELDS - 1; i > -1; i--) { if (Fields[i].values) { t = Fields[i].values[status & (1 << Fields[i].width) - 1]; printf("s/#%s/%s/; ", Fields[i].name, t); } status >>= Fields[i].width; } fgets(line, 80, stdin); } exit(0); }