aboutsummaryrefslogtreecommitdiff
path: root/comms/kb
diff options
context:
space:
mode:
authorDiane Bruce <db@FreeBSD.org>2007-12-21 16:55:15 +0000
committerDiane Bruce <db@FreeBSD.org>2007-12-21 16:55:15 +0000
commiteab2edfb13cf1b4ad5d8d8aa38026bd8e7492707 (patch)
treedf56b4f2178d3df4a8caf9cad01ac3c670eb6ac6 /comms/kb
parent41fc19e6a7f787ea14809807ed85becaa9ef7a14 (diff)
downloadports-eab2edfb13cf1b4ad5d8d8aa38026bd8e7492707.tar.gz
ports-eab2edfb13cf1b4ad5d8d8aa38026bd8e7492707.zip
Notes
Diffstat (limited to 'comms/kb')
-rw-r--r--comms/kb/Makefile49
-rw-r--r--comms/kb/distinfo6
-rw-r--r--comms/kb/files/Makefile16
-rw-r--r--comms/kb/files/bsd_bells.c163
-rw-r--r--comms/kb/files/kb7
-rw-r--r--comms/kb/files/kbserver34
-rw-r--r--comms/kb/files/patch-boxes.c35
-rw-r--r--comms/kb/files/patch-elogs.c915
-rw-r--r--comms/kb/files/patch-fields.c15
-rw-r--r--comms/kb/files/patch-globs.h27
-rw-r--r--comms/kb/files/patch-init.c150
-rw-r--r--comms/kb/files/patch-io.c533
-rw-r--r--comms/kb/files/patch-kb.c32
-rw-r--r--comms/kb/files/patch-support.c86
-rw-r--r--comms/kb/files/pkg_message8
-rw-r--r--comms/kb/pkg-descr14
-rw-r--r--comms/kb/pkg-plist15
17 files changed, 2105 insertions, 0 deletions
diff --git a/comms/kb/Makefile b/comms/kb/Makefile
new file mode 100644
index 000000000000..f67740970bf4
--- /dev/null
+++ b/comms/kb/Makefile
@@ -0,0 +1,49 @@
+# New ports collection makefile for: kb
+# Date created: June 5, 2007
+# Whom: Diane Bruce <db@db.net>
+#
+# $FreeBSD$
+
+PORTNAME= kb
+PORTVERSION= 7.09
+CATEGORIES= comms hamradio
+MASTER_SITES= http://www.db.net/downloads/ \
+ ${MASTER_SITE_LOCAL}
+MASTER_SITE_SUBDIR= db
+DISTFILES= kb_src-${PORTVERSION}.tar.gz kb_inst-${PORTVERSION}.tar.gz
+
+MAINTAINER= db@FreeBSD.org
+COMMENT= Amateur Radio contest logger
+
+USE_XLIB= yes
+USE_GNOME= libgnome gtk20 libbonobo
+NO_WRKSUBDIR= yes
+PKGMESSAGE= ${FILESDIR}/pkg_message
+
+pre-configure:
+ @${CP} ${FILESDIR}/Makefile ${WRKSRC}
+.if exists(/usr/include/dev/speaker/speaker.h)
+ @${REINPLACE_CMD} -e 's|-UBSDSOUND|-DBSDSOUND="<dev/speaker/speaker.h>"|' ${WRKSRC}/Makefile
+.elif exists(/usr/include/machine/speaker.h)
+ @${REINPLACE_CMD} -e 's|-UBSDSOUND|-DBSDSOUND="<machine/speaker.h>"|' ${WRKSRC}/Makefile
+.endif
+ @${RM} ${WRKSRC}/kb_server
+ @${RM} ${WRKSRC}/kb
+ @${CP} ${FILESDIR}/bsd_bells.c ${WRKSRC}
+
+do-install:
+ @${INSTALL_SCRIPT} ${FILESDIR}/kbserver ${LOCALBASE}/etc/rc.d
+ ${INSTALL_SCRIPT} ${FILESDIR}/kb ${LOCALBASE}/bin
+ ${INSTALL_PROGRAM} ${WRKSRC}/kb ${LOCALBASE}/bin/kb_bin
+ ${INSTALL_PROGRAM} ${WRKSRC}/kb_server ${LOCALBASE}/sbin
+ ${MKDIR} ${DATADIR}
+.for f in ${WRKSRC}/COUNTY.CQP ${WRKSRC}/DEFAULT.INI \
+ ${WRKSRC}/CALL_LIB.LST ${WRKSRC}/CALL_SS.LST \
+ ${WRKSRC}/CALL_FD.LST ${WRKSRC}/HELP.LST \
+ ${WRKSRC}/COUNTRY.LST ${WRKSRC}/HELPFD.LST \
+ ${WRKSRC}/SECTION.LST ${WRKSRC}/STATE.LST
+ ${INSTALL_DATA} ${WRKSRC}/$f ${DATADIR}
+.endfor
+ @${CAT} ${PKGMESSAGE}
+
+.include <bsd.port.mk>
diff --git a/comms/kb/distinfo b/comms/kb/distinfo
new file mode 100644
index 000000000000..0de283044f71
--- /dev/null
+++ b/comms/kb/distinfo
@@ -0,0 +1,6 @@
+MD5 (kb_src-7.09.tar.gz) = 2ac7a11e18c245278800f00b9bf3d300
+SHA256 (kb_src-7.09.tar.gz) = 7b6a7a8c8fbe01fbe1086f5b783414b056bf1d5db5945d086a3e7e6de1bfa6f8
+SIZE (kb_src-7.09.tar.gz) = 93896
+MD5 (kb_inst-7.09.tar.gz) = 1984eb53d5ba56b43c188f07de9ae3dd
+SHA256 (kb_inst-7.09.tar.gz) = 0890702b3ee182d056e9a33055aa4519fded84b15a67556279173865c1eb10d2
+SIZE (kb_inst-7.09.tar.gz) = 199940
diff --git a/comms/kb/files/Makefile b/comms/kb/files/Makefile
new file mode 100644
index 000000000000..8d3d0025cbc1
--- /dev/null
+++ b/comms/kb/files/Makefile
@@ -0,0 +1,16 @@
+# Makefile for: kb
+#
+# $FreeBSD$
+
+LIBS+= `pkg-config --cflags --libs gtk+-2.0`
+LIBS+= `pkg-config --cflags --libs libgnome-2.0`
+LIBS+= `pkg-config --cflags --libs bonobo-activation-2.0`
+
+all: kb_server kb
+
+kb_server: kb_server.c
+ ${CC} ${CFLAGS} -o kb_server kb_server.c -lm
+
+kb: boxes.c fboxes.c kb.c radio.c bsd_bells.c fields.c sboxes.c \
+ couzon.c init.c kb_server.c support.c elogs.c io.c network.c tree.c
+ ${CC} ${CFLAGS} -I. ${LIBS} kb.c -UBSDSOUND -o kb
diff --git a/comms/kb/files/bsd_bells.c b/comms/kb/files/bsd_bells.c
new file mode 100644
index 000000000000..86661c57bac2
--- /dev/null
+++ b/comms/kb/files/bsd_bells.c
@@ -0,0 +1,163 @@
+#ifdef DEBUG_BELLS
+#include <stdio.h>
+#include <stdlib.h>
+#include <dev/speaker/speaker.h>
+#include <fcntl.h>
+#include "kb_bells.h"
+#define MAX_BELLS (SPEED_CHANGE_SOUND+1)
+int fd_bells;
+
+static void bsd_play_bells(int isound);
+main()
+{
+ int i;
+ fd_bells = open("/dev/speaker",O_RDWR);
+
+ if(fd_bells<0) {
+ fprintf(stderr,"kldload speaker.ko\n");
+ exit(-1);
+ }
+
+ for(i=1;i < MAX_BELLS;i++) {
+ printf("%d \n", i);
+ bsd_play_bells(i);
+ getchar();
+ }
+}
+#endif
+
+static void bsd_play_bells(int isound)
+{
+ tone_t tones;
+
+ switch(isound)
+ {
+ case BELL_SOUND :
+ play_bell_sound ();
+ break;
+ case DUPE_SOUND :
+ play_dupe_sound ();
+ break;
+ case MESSAGE_SOUND :
+ play_message_sound ();
+ break;
+ case BAND_CHANGE_SOUND :
+ play_band_change_sound ();
+ break;
+ case SINGLE_MULT_SOUND :
+ play_single_mult_sound ();
+ break;
+ case DOUBLE_MULT_SOUND :
+ play_double_mult_sound ();
+ break;
+ case BAD_CALL_SOUND :
+ play_bad_call_sound ();
+ break;
+ case BAD_KEY_SOUND :
+ play_bad_key_sound ();
+ break;
+ case SPEED_CHANGE_SOUND :
+ play_speed_change_sound ();
+ break;
+ default:
+ break;
+ }
+}
+#define DELAY_TO_HZ(x) (x/4)
+play_bell_sound()
+{
+ tone_t tones;
+ tones.frequency = DELAY_TO_HZ(0x474);
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+}
+play_dupe_sound ()
+{
+ tone_t tones;
+ tones.frequency = DELAY_TO_HZ(0xfe0);
+ tones.duration = 12;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = DELAY_TO_HZ(0x17c8);
+ tones.duration = 12;
+ ioctl(fd_bells, SPKRTONE, &tones);
+}
+play_message_sound()
+{
+ tone_t tones;
+ tones.frequency = DELAY_TO_HZ(0xd58);
+ tones.duration = 12;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = DELAY_TO_HZ(0x8e8);
+ tones.duration = 12;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = DELAY_TO_HZ(0xd58);
+ tones.duration = 12;
+ ioctl(fd_bells, SPKRTONE, &tones);
+}
+play_band_change_sound()
+{
+ tone_t tones;
+ tones.frequency = DELAY_TO_HZ(0x710);
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = 0;
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = DELAY_TO_HZ(0x710);
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = 0;
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+}
+play_single_mult_sound()
+{
+ tone_t tones;
+ tones.frequency = DELAY_TO_HZ(0x8e8);
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = DELAY_TO_HZ(0x6ac);
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+}
+play_double_mult_sound()
+{
+ tone_t tones;
+ tones.frequency = DELAY_TO_HZ(0x8e8);
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = DELAY_TO_HZ(0x6ac);
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = 0;
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = DELAY_TO_HZ(0x8e8);
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+ tones.frequency = DELAY_TO_HZ(0x6ac);
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+}
+play_bad_call_sound ()
+{
+ tone_t tones;
+ tones.frequency = DELAY_TO_HZ(0x11d0);
+ tones.duration = 38;
+ ioctl(fd_bells, SPKRTONE, &tones);
+}
+play_bad_key_sound()
+{
+ tone_t tones;
+ tones.frequency = DELAY_TO_HZ(0x17cc);
+ tones.duration = 42;
+ ioctl(fd_bells, SPKRTONE, &tones);
+}
+play_speed_change_sound()
+{
+ tone_t tones;
+ tones.frequency = DELAY_TO_HZ(0x710);
+ tones.duration = 6;
+ ioctl(fd_bells, SPKRTONE, &tones);
+}
+
diff --git a/comms/kb/files/kb b/comms/kb/files/kb
new file mode 100644
index 000000000000..43865762c67d
--- /dev/null
+++ b/comms/kb/files/kb
@@ -0,0 +1,7 @@
+#!/bin/sh
+if [ ! -e ~/.kb ] ; then
+ mkdir ~/.kb
+fi
+cp -f /usr/local/share/kb/* ~/.kb
+cd ~/.kb
+exec kb_bin
diff --git a/comms/kb/files/kbserver b/comms/kb/files/kbserver
new file mode 100644
index 000000000000..4c83805581e4
--- /dev/null
+++ b/comms/kb/files/kbserver
@@ -0,0 +1,34 @@
+#! /bin/sh
+#
+# PROVIDE: kbserver
+# REQUIRE: NETWORKING
+#
+# Add the following lines to /etc/rc.conf to enable kb_server
+#
+#kbserver_enable="YES"
+
+. /etc/rc.subr
+
+name=kbserver
+rcvar=`set_rcvar`
+load_rc_config $name
+kbserver_enable=${kbserver_enable-"NO"}
+
+command=/usr/local/sbin/kb_server
+start_cmd=kbserver_start
+stop_cmd=kbserver_stop
+
+kbserver_start()
+{
+ echo "Starting kb_server: "
+ ${command}
+ return 0
+}
+kbserver_stop()
+{
+ echo "Stopping kb_server: "
+ killall kb_server
+ return 0
+}
+
+run_rc_command "$1"
diff --git a/comms/kb/files/patch-boxes.c b/comms/kb/files/patch-boxes.c
new file mode 100644
index 000000000000..2a6e8ae0b3db
--- /dev/null
+++ b/comms/kb/files/patch-boxes.c
@@ -0,0 +1,35 @@
+--- boxes.c.orig 2007-11-24 19:46:36.000000000 -0500
++++ boxes.c 2007-11-24 19:42:17.000000000 -0500
+@@ -749,8 +749,13 @@
+ guint ikey, istate;
+ gchar msg[43], email_file_names[5][13], lpr_line[81];
+ gint margin=9;
++#ifdef BSD
++ const gchar *lpr_cmd =
++ "lpr ";
++#else
+ const gchar *lpr_cmd =
+ "lpr -r -o page-top=36 -o page-left=18 -o page-bottom=36 ";
++#endif
+ const gchar *print_file_names[4] = {"PRINT.SUM", "PRINT.DUP",
+ "PRINT.LOG", "PRINT.MLT"};
+
+@@ -778,14 +783,14 @@
+ if(icall_count)
+ {
+ write_summary_file (print_file_names[obd->item], margin);
+- strcpy(lpr_line, lpr_cmd);
+- strcat(lpr_line, print_file_names[obd->item]);
++ snprintf(lpr_line, sizeof(lpr_line), "%s %s", lpr_cmd,
++ print_file_names[obd->item]);
+ icopy = system(lpr_line);
+ if(isel_contest==WPX)
+ {
+ write_multiplier_file (print_file_names[3], margin);
+- strcpy(lpr_line, lpr_cmd);
+- strcat(lpr_line, print_file_names[3]);
++ snprintf(lpr_line, sizeof(lpr_line), "%s %s", lpr_cmd,
++ print_file_names[3]);
+ icopy = system(lpr_line);
+ }
+ if(!icopy)
diff --git a/comms/kb/files/patch-elogs.c b/comms/kb/files/patch-elogs.c
new file mode 100644
index 000000000000..0cb6442775de
--- /dev/null
+++ b/comms/kb/files/patch-elogs.c
@@ -0,0 +1,915 @@
+--- elogs.c.orig 2007-11-22 13:24:56.000000000 -0500
++++ elogs.c 2007-11-22 14:19:17.000000000 -0500
+@@ -56,7 +56,6 @@
+ gchar locus_line[4], ops_line[45];
+ gint iqsos[2] = {0, 0}, idupes[2] = {0, 0}, ipoints[2] = {0, 0};
+ gint mults[2] = {0, 0}, izones[2] = {0, 0}, nlw[2] = {0, 0};
+- gchar skip_line[3] = {'\r', '\n', '\0'};
+ const gchar *stpr = "State/Province: ";
+ const gchar *category_choices[8] = {"Single Operator",
+ "Single Operator, Assisted",
+@@ -106,9 +105,7 @@
+ concat(line_out, cr_array[1].date, 4, 5, !COPY);
+ strcat(line_out, " ");
+ strcat(line_out, select_contest_items[isel_contest]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Call: ");
+ strcpy(station, init_screen_choices[0]);
+@@ -169,9 +166,7 @@
+ strcat(line_out, "Section: ___");
+ break;
+ }
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp, "%s\n\n", line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Category: ");
+ for(i=0; i<8; i++)
+@@ -192,16 +187,12 @@
+ strcpy(ops_line, "");
+ break;
+ }
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp, "%s\n\n", line_out);
+ if(strlen(ops_line))
+ {
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, ops_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp, "%s\n\n", line_out);
+ }
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Mode: ");
+@@ -211,24 +202,18 @@
+ strcat(line_out, power_line);
+ concat(line_out, blank80, 0, 9, !COPY);
+ strcat(line_out, "Hours of Operation: __");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
+- fputs(skip_line, fp);
++ fprintf(fp, "%s\n\n\n", line_out);
+ switch (isel_contest)
+ {
+ case DX :
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " Net QSO Country Claimed");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " QSOs Points Mults Score");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp, "%s\n\n", line_out);
+ for(i=0; i<6; i++)
+ {
+ concat(line_out, blank80, 0, margin+2, COPY);
+@@ -247,10 +232,9 @@
+ int_to_comma (score_mb.mults[mode][i], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n", line_out);
+ }
+- fputs(skip_line, fp);
++ fprintf(fp,"\n");
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "All Bands");
+ concat(line_out, blank80, 0, 3, !COPY);
+@@ -269,21 +253,17 @@
+ int_to_comma (ipoints[mode]*mults[mode], score_line);
+ left_blank_pad (score_line, sizeof(score_line));
+ strcat(line_out, score_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ break;
+ case FD :
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " Net CW Net PH");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " QSOs QSOs");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ for(i=0; i<6; i++)
+ {
+ concat(line_out, blank80, 0, margin+2, COPY);
+@@ -297,10 +277,9 @@
+ int_to_comma (score_mb.qsos[PH][i]-score_mb.dupes[PH][i], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+- fputs(skip_line, fp);
++ fprintf(fp,"\n");
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "All Bands");
+ concat(line_out, blank80, 0, 4, !COPY);
+@@ -315,8 +294,7 @@
+ int_to_comma (iqsos[CW]-idupes[CW]+iqsos[PH]-idupes[PH], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "QSO Points");
+ concat(line_out, blank80, 0, 3, !COPY);
+@@ -331,8 +309,7 @@
+ int_to_comma (ipoints[CW]+ipoints[PH], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Power Multiplier");
+ concat(line_out, blank80, 0, 21, !COPY);
+@@ -345,43 +322,34 @@
+ int_to_comma (pm, sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "QSO Score");
+ concat(line_out, blank80, 0, 28, !COPY);
+ int_to_comma (pm*(ipoints[CW]+ipoints[PH]), sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Bonus Points");
+ concat(line_out, blank80, 0, 24, !COPY);
+ concat(line_out, under_line, 0, 6, !COPY);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Claimed Score");
+ concat(line_out, blank80, 0, 23, !COPY);
+ concat(line_out, under_line, 0, 6, !COPY);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ break;
+ case WPX :
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " Net QSO Prefix Claimed");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " QSOs Points Mults Score");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ for(i=0; i<6; i++)
+ {
+ concat(line_out, blank80, 0, margin+2, COPY);
+@@ -400,10 +368,9 @@
+ int_to_comma (score_mb.mults[mode][i], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+- fputs(skip_line, fp);
++ fprintf(fp,"\n");
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "All Bands");
+ concat(line_out, blank80, 0, 3, !COPY);
+@@ -422,8 +389,7 @@
+ int_to_comma (ipoints[mode]*mults[mode], score_line);
+ left_blank_pad (score_line, sizeof(score_line));
+ strcat(line_out, score_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ break;
+ case CQP :
+ break;
+@@ -431,14 +397,11 @@
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " Net QSO Country Zone Claimed");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " QSOs Points Mults Mults Score");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ for(i=0; i<6; i++)
+ {
+ concat(line_out, blank80, 0, margin+2, COPY);
+@@ -461,10 +424,9 @@
+ int_to_comma (score_mb.zones[mode][i], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+- fputs(skip_line, fp);
++ fprintf(fp,"\n");
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "All Bands");
+ concat(line_out, blank80, 0, 2, !COPY);
+@@ -487,22 +449,17 @@
+ int_to_comma (ipoints[mode]*(mults[mode]+izones[mode]), score_line);
+ left_blank_pad (score_line, sizeof(score_line));
+ strcat(line_out, score_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ break;
+ case SS :
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " Net QSO Section Claimed");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " QSOs Points Mults Score");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ concat(line_out, blank80, 0, 12, !COPY);
+ int_to_comma (iqsos[mode]-idupes[mode], sum_line);
+@@ -520,21 +477,15 @@
+ int_to_comma (ipoints[mode]*mults[mode], score_line);
+ left_blank_pad (score_line, sizeof(score_line));
+ strcat(line_out, score_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " ARRL Sections Check-Off List");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " (Sections worked marked with an asterisk)");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ for(j=1; j<11; j++)
+ {
+ concat(line_out, blank80, 0, margin, COPY);
+@@ -554,8 +505,7 @@
+ strcat(line_out, mult_line);
+ strcat(line_out, locus_line);
+ }
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ break;
+ case A160 :
+@@ -565,18 +515,14 @@
+ int_to_comma (iqsos[CW]-idupes[CW], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "QSO Points");
+ concat(line_out, blank80, 0, 9, !COPY);
+ int_to_comma (ipoints[CW], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "States/Prov");
+ for(i=0; i<2; i++)
+@@ -587,9 +533,7 @@
+ int_to_comma (nlw[CW], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Countries");
+ nlw[0] = 0;
+@@ -602,18 +546,14 @@
+ int_to_comma (nlw[CW], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Total Mults");
+ concat(line_out, blank80, 0, 8, !COPY);
+ int_to_comma (mults[CW], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Claimed Score");
+ concat(line_out, blank80, 0, 1, !COPY);
+@@ -621,16 +561,13 @@
+ score_line);
+ left_blank_pad (score_line, sizeof(score_line));
+ strcat(line_out, score_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ break;
+ case TEN :
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ " CW Phone All");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "QSOs");
+ concat(line_out, blank80, 0, 15, !COPY);
+@@ -645,9 +582,7 @@
+ int_to_comma (iqsos[CW]-idupes[CW]+iqsos[PH]-idupes[PH], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "QSO Points");
+ concat(line_out, blank80, 0, 9, !COPY);
+@@ -662,9 +597,7 @@
+ int_to_comma (ipoints[CW]+ipoints[PH], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "States/Prov");
+ for(i=0; i<2; i++)
+@@ -683,9 +616,7 @@
+ int_to_comma (nlw[CW]+nlw[PH], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Countries");
+ nlw[0] = 0;
+@@ -706,9 +637,7 @@
+ int_to_comma (nlw[CW]+nlw[PH], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Total Mults");
+ concat(line_out, blank80, 0, 8, !COPY);
+@@ -723,9 +652,7 @@
+ int_to_comma (mults[CW]+mults[PH], sum_line);
+ left_blank_pad (sum_line, sizeof(sum_line));
+ strcat(line_out, sum_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Claimed Score");
+ concat(line_out, blank80, 0, 30, !COPY);
+@@ -733,76 +660,51 @@
+ score_line);
+ left_blank_pad (score_line, sizeof(score_line));
+ strcat(line_out, score_line);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ break;
+ }
+- fputs(skip_line, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"\n\n");
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ "Club Participation? ( ) Yes ( ) No If yes, print name below.");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Name of Club: ");
+ concat(line_out, under_line, 0, 49, !COPY);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Rigs: ");
+ concat(line_out, under_line, 0, 57, !COPY);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ concat(line_out, under_line, 0, 63, !COPY);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Antennas: ");
+ concat(line_out, under_line, 0, 53, !COPY);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ concat(line_out, under_line, 0, 63, !COPY);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Remarks: ");
+ concat(line_out, under_line, 0, 54, !COPY);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ concat(line_out, under_line, 0, 63, !COPY);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n%s\n\n",line_out,line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ "This is to certify that in this contest I have operated my");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ "transmitter within the limitations of my license and have");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out,
+ "observed fully the rules and regulations of the contest.");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, "Date ");
+ concat(line_out, under_line, 0, 9, !COPY);
+@@ -810,25 +712,20 @@
+ concat(line_out, under_line, 0, 22, !COPY);
+ strcat(line_out, ", ");
+ strcat(line_out, init_screen_choices[1]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, init_screen_choices[2]);
+ strcat(line_out, ", ");
+ strcat(line_out, init_screen_choices[1]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, init_screen_choices[3]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ if(strlen(init_screen_choices[4]))
+ {
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, init_screen_choices[4]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, init_screen_choices[5]);
+@@ -836,8 +733,7 @@
+ strcat(line_out, init_screen_choices[6]);
+ strcat(line_out, " ");
+ strcat(line_out, init_screen_choices[7]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ fflush(fp);
+ fsync(fileno(fp));
+ fclose(fp);
+@@ -852,7 +748,6 @@
+ gchar station[14], mode_line[6], dupe_line[2];
+ gchar title_line[74], header_line1[74], call_hold[14], call_fill[14];
+ gint iqsos[2] = {0, 0}, max_lines=54;
+- gchar skip_line[3] = {'\r', '\n', '\0'};
+ gchar form_feed[2] = {'\f', '\0'};
+
+ fp = fopen(filnam, "w");
+@@ -924,10 +819,7 @@
+ int_to_char (npages, npages_char);
+ left_blank_pad (npages_char, sizeof(npages_char));
+ strcat(line_out, npages_char);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n\n",line_out);
+ }
+ if(margin || new_mb)
+ {
+@@ -936,9 +828,7 @@
+ strcat(line_out, header_line1);
+ strcat(line_out, bandw[i]);
+ strcat(line_out, mode_char[j]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ }
+ strcpy(call_hold, "");
+ ic = 0;
+@@ -973,8 +863,7 @@
+ ic %= 4;
+ if(!ic)
+ {
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ idl++;
+ }
+ }
+@@ -986,14 +875,13 @@
+ }
+ if(ic)
+ {
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ if(margin)
+ fputs(form_feed, fp);
+ }
+ if(!margin)
+- fputs(skip_line, fp);
++ fprintf(fp,"\n");
+ }
+ fflush(fp);
+ fsync(fileno(fp));
+@@ -1014,7 +902,6 @@
+ gchar hl2_zone[7], hl2_country[10];
+ gint iqsos[2] = {0, 0}, nqsos[2] = {0, 0};
+ gint nzones[2] = {0, 0}, nmults[2] = {0, 0}, npts[2] = {0, 0};
+- gchar skip_line[3] = {'\r', '\n', '\0'};
+ gchar form_feed[2] = {'\f', '\0'};
+
+ fp = fopen(filnam, "w");
+@@ -1154,19 +1041,13 @@
+ strcat(line_out, ipage_char);
+ strcat(line_out, " of ");
+ strcat(line_out, npages_char);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, header_line1);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, header_line2);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ }
+ for(i=(ipage-1)*50+1; i<=ipage*50; i++)
+ {
+@@ -1361,11 +1242,10 @@
+ npts[0] += atoi(cr_array[i].points);
+ npts[1] += atoi(cr_array[i].points);
+ strcat(line_out, cr_array[i].points);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ else if(margin)
+- fputs(skip_line, fp);
++ fprintf(fp,"\n");
+ }
+ if(margin)
+ {
+@@ -1385,7 +1265,7 @@
+ left_blank_pad (footer2_vars[2], sizeof(footer2_vars[2]));
+ int_to_char (npts[1], footer2_vars[3]);
+ left_blank_pad (footer2_vars[3], sizeof(footer2_vars[3]));
+- fputs(skip_line, fp);
++ fprintf(fp,"\n");
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, footer_line1);
+ concat(line_out, blank80, 0, 9, !COPY);
+@@ -1402,8 +1282,7 @@
+ strcat(line_out, footer1_vars[2]);
+ concat(line_out, blank80, 0, 3, !COPY);
+ strcat(line_out, footer1_vars[3]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, footer_line2);
+ concat(line_out, blank80, 0, 9, !COPY);
+@@ -1420,9 +1299,7 @@
+ strcat(line_out, footer2_vars[2]);
+ concat(line_out, blank80, 0, 3, !COPY);
+ strcat(line_out, footer2_vars[3]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(form_feed, fp);
++ fprintf(fp,"%s\f\n",line_out);
+ }
+ }
+ fflush(fp);
+@@ -1439,7 +1316,6 @@
+ gchar title_line[74], header_line1[74];
+ gint max_lines=54;
+ gint iqsos[2] = {0, 0};
+- gchar skip_line[3] = {'\r', '\n', '\0'};
+ gchar form_feed[2] = {'\f', '\0'};
+
+ fp = fopen(filnam, "w");
+@@ -1499,15 +1375,10 @@
+ strcat(line_out, ipage_char);
+ strcat(line_out, " of ");
+ strcat(line_out, npages_char);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n\n",line_out);
+ concat(line_out, blank80, 0, margin, COPY);
+ strcat(line_out, header_line1);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(skip_line, fp);
++ fprintf(fp,"%s\n\n",line_out);
+ }
+ jfirst = (ipage-1)*max_lines*10+1;
+ jlast = ipage*max_lines*10<px_tree.npx ?
+@@ -1525,14 +1396,12 @@
+ ic %= 10;
+ if(!ic)
+ {
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ }
+ if(ic)
+ {
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ if(margin)
+ fputs(form_feed, fp);
+@@ -1662,8 +1531,7 @@
+ strcat(category_cab, " ");
+ strcat(category_cab, mode_cab);
+ strcpy(line_out, "START-OF-LOG: 2.0");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ if(strlen(section)>0)
+ {
+ strcpy(line_out, "ARRL-SECTION: ");
+@@ -1671,80 +1539,45 @@
+ }
+ else
+ strcpy(line_out, "ARRL-SECTION:");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ strcpy(line_out, "CALLSIGN: ");
+ strcat(line_out, init_screen_choices[0]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ strcpy(line_out, "CATEGORY: ");
+ strcat(line_out, category_cab);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ if(isel_contest==WPX && !strcmp(init_screen_choices[11], "<SO-TRI/SE>"))
+ {
+ strcpy(line_out, "CATEGORY-OVERLAY: ");
+ strcat(line_out, "TB-WIRES");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ strcpy(line_out, "CLAIMED-SCORE: ");
+ strcat(line_out, score_cab);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ strcpy(line_out, "CLUB:");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ strcpy(line_out, "CONTEST: ");
+ strcat(line_out, contest_cab);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ strcpy(line_out, "NAME: ");
+ strcat(line_out, init_screen_choices[2]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ strcpy(line_out, "ADDRESS: ");
+ strcat(line_out, init_screen_choices[3]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- if(strlen(init_screen_choices[4]))
+- {
+- strcpy(line_out, "ADDRESS: ");
+- strcat(line_out, init_screen_choices[4]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- strcpy(line_out, "ADDRESS: ");
+- strcat(line_out, init_screen_choices[5]);
+- strcat(line_out, ", ");
+- strcat(line_out, init_screen_choices[6]);
+- strcat(line_out, " ");
+- strcat(line_out, init_screen_choices[7]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- }
+- else
+- {
+- strcpy(line_out, "ADDRESS: ");
+- strcat(line_out, init_screen_choices[5]);
+- strcat(line_out, ", ");
+- strcat(line_out, init_screen_choices[6]);
+- strcat(line_out, " ");
+- strcat(line_out, init_screen_choices[7]);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- strcpy(line_out, "ADDRESS:");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- }
+- strcpy(line_out, "OPERATORS:");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- strcpy(line_out, "SOAPBOX:");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
+- fputs(line_out, fp);
+- fputs(line_out, fp);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
++ if(strlen(init_screen_choices[4])!=0)
++ fprintf(fp,"ADDRESS: %s\n",
++ init_screen_choices[4]);
++ fprintf(fp,"ADDRESS: %s, %s %s\n",init_screen_choices[5],
++ init_screen_choices[6],init_screen_choices[7]);
++
++ fprintf(fp,"OPERATORS:\n");
++ fprintf(fp,"SOAPBOX:\n");
++ fprintf(fp,"SOAPBOX:\n");
++ fprintf(fp,"SOAPBOX:\n");
++ fprintf(fp,"SOAPBOX:\n");
++ fprintf(fp,"SOAPBOX:\n");
+ switch (isel_contest)
+ {
+ case WPX :
+@@ -1790,8 +1623,7 @@
+ strcat(line_out, exch_rcvd_cab);
+ strcat(line_out, " ");
+ strcat(line_out, cr_array[i].tx);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ break;
+ case FD :
+@@ -1836,8 +1668,7 @@
+ strcat(line_out, exch_rcvd_cab);
+ strcat(line_out, " ");
+ strcat(line_out, cr_array[i].tx);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ break;
+ case CQP :
+@@ -1892,8 +1723,7 @@
+ strcat(line_out, ck_rcvd_cab);
+ strcat(line_out, " ");
+ strcat(line_out, rst_rcvd_cab);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ break;
+ case A160 :
+@@ -1947,8 +1777,7 @@
+ strcat(line_out, exch_rcvd_cab);
+ strcat(line_out, " ");
+ strcat(line_out, cr_array[i].tx);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ break;
+ default :
+@@ -1995,13 +1824,10 @@
+ strcat(line_out, exch_rcvd_cab);
+ strcat(line_out, " ");
+ strcat(line_out, cr_array[i].tx);
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"%s\n",line_out);
+ }
+ }
+- strcpy(line_out, "END-OF-LOG:");
+- add_eol_chars (line_out);
+- fputs(line_out, fp);
++ fprintf(fp,"END-OF-LOG:\n");
+ fflush(fp);
+ fsync(fileno(fp));
+ fclose(fp);
diff --git a/comms/kb/files/patch-fields.c b/comms/kb/files/patch-fields.c
new file mode 100644
index 000000000000..cfcf3b859c03
--- /dev/null
+++ b/comms/kb/files/patch-fields.c
@@ -0,0 +1,15 @@
+--- fields.c.orig 2007-09-10 10:57:01.000000000 -0400
++++ fields.c 2007-11-22 19:53:19.000000000 -0500
+@@ -1418,6 +1418,12 @@
+ gint cyan_bar_color, text_color;
+ gchar str_hold[81];
+
++ /* If esk->ikey is nul shunt it off here. I saw it happen - db VA3DB */
++ if (esd->ikey == '\0')
++ {
++ play_bells (BELL_SOUND);
++ return;
++ }
+ beep = 1;
+ ccol = *esd->cursor_colp-esd->field_col;
+ lflp = strlen(esd->field_linep);
diff --git a/comms/kb/files/patch-globs.h b/comms/kb/files/patch-globs.h
new file mode 100644
index 000000000000..df7aaf0da8b2
--- /dev/null
+++ b/comms/kb/files/patch-globs.h
@@ -0,0 +1,27 @@
+--- globs.h.orig 2007-07-20 10:26:01.000000000 -0400
++++ globs.h 2007-11-23 09:38:53.000000000 -0500
+@@ -169,8 +169,15 @@
+ "<18.0>", "<19.2>", "<20.6>", "<22.2>", "<24.0>",
+ "<26.2>", "<28.8>", "<32.0>", "<36.0>", "<41.1>",
+ "<48.0>", "<57.6>", "<72.0>"};
++/* These device names are really specific to FreeBSD -db */
++#ifdef BSD
++static const gchar *port_bracket[6] = {"<OFF>", "<ttyd0>", "<ttyd1>",
++ "<ttyU0>", "<ttyU1>", "<TELNET>"};
++#else
+ static const gchar *port_bracket[6] = {"<OFF>", "<ttyS0>", "<ttyS1>",
+ "<ttyUSB0>", "<ttyUSB1>", "<TELNET>"};
++#endif
++
+ static const gchar *yn_bracket[2] = {"<YES>", "<NO>"};
+ static const gchar *dupe_bracket[2] = {"<ASK>", "<ALWAYS>"};
+ static const gchar *partial_bracket[3] = {"<NO>", "<2>", "<3>"};
+@@ -178,7 +185,7 @@
+ " Station Call Sign", "Operator Call Sign",
+ " Operator Name", " Address",
+ " Address", " City",
+- " State", " Zip Code",
++ " State/Province", " Zip/Postal Code",
+ " Latitude", " Longitude",
+ " Offset to UTC", " Entry Category",
+ " Power", " Contest Type",
diff --git a/comms/kb/files/patch-init.c b/comms/kb/files/patch-init.c
new file mode 100644
index 000000000000..4081df6845f9
--- /dev/null
+++ b/comms/kb/files/patch-init.c
@@ -0,0 +1,150 @@
+--- init.c.orig 2007-09-10 10:34:21.000000000 -0400
++++ init.c 2007-11-24 16:43:45.000000000 -0500
+@@ -30,6 +30,7 @@
+ static gint set_error_check(gpointer data);
+ static gint check_precedence(void);
+ static gint butt_kick(gpointer widget);
++static void set_fixed_font(GtkWidget *);
+ struct init_vars
+ {
+ gint row1;
+@@ -108,33 +109,13 @@
+ (col1+9)*wcol,
+ (row1+9)*hrow+hrow/2,
+ layout);
+- pfd = pango_font_description_from_string ("misc fixed 16");
+- pc = gtk_widget_get_pango_context (widget);
+- pl = pango_context_get_language (pc);
+- pfm = pango_context_get_metrics (pc, pfd, pl);
+- ipfmgadw = pango_font_metrics_get_approximate_digit_width (pfm);
+- cursor_offset = 8-pango_font_metrics_get_descent (pfm)/PANGO_SCALE;
+- pango_font_metrics_unref (pfm);
+- if(ipfmgadw==10240)
+- {
+- pango_layout_set_font_description (layout, pfd);
+- pango_font_description_free (pfd);
+- }
+- else
+- {
+- pango_font_description_free (pfd);
+- pfd = pango_font_description_from_string ("luxi mono 12");
+- pango_layout_set_font_description (layout, pfd);
+- pango_font_description_free (pfd);
+- printf("%s\n", missing_font);
+- printf("For a more readable KB screen ");
+- printf("add the Misc Fixed font to your system.\n");
+- printf("%s\n", missing_font);
+- write_line (row1+23, col1+20, missing_font, HI_RED, SAVEPIX);
+- write_line (row1+24, col1+6,
+- "Now Using Alternate Font. KB Screens May Exhibit Display Problems.",
+- HI_RED, SAVEPIX);
+- }
++ /* Original code would only work on a 1024 wide screen.
++ * This works for other sized screens, including mine which is 1280 wide.
++ *
++ * - Diane VA3DB db@db.net
++ */
++ set_fixed_font(widget);
++
+ concat(comp_mon, __DATE__, 0, 2, COPY);
+ concat(comp_yr, __DATE__, 7, 10, COPY);
+ while(strcmp(comp_mon, month_array[icm]) && icm<11)
+@@ -404,6 +385,7 @@
+ mode = CW;
+ else
+ mode = PH;
++ shift_fkeys = 0;
+ if(!sccfn && strcmp(init_screen_choices[16], port_bracket[0]))
+ {
+ idisplay_type = IDT_KEYER;
+@@ -1139,8 +1121,13 @@
+ beep = 0;
+ break;
+ case 7 :
+- if(isdigit_ui(ikey) || ikey=='-')
+- beep = 0;
++ /* Canadian postal codes will be ANA[space]NAN
++ * I will cheat and allow any combination of alpha, numeric and space.
++ * - Diane VA3DB <db@db.net>
++ */
++ ikey = toupper_ui(ikey);
++ if(isalpha_ui(ikey) || isdigit_ui(ikey) || ikey==' ' || ikey=='-')
++ beep = 0;
+ break;
+ case 8 :
+ ikey = toupper_ui(ikey);
+@@ -1163,7 +1150,7 @@
+ edit_line (&esd);
+ }
+ else
+- play_bells (BAD_KEY_SOUND);
++ play_bells (BAD_KEY_SOUND);
+ }
+ return TRUE;
+ }
+@@ -1791,6 +1778,7 @@
+ }
+ write_ini_file ();
+ insert_mode = 0;
++ shift_fkeys = 0;
+ shift_fkeys = (strcmp(set_screen_choices[11], yn_bracket[1]));
+ ssd->done = TRUE;
+ break;
+@@ -2381,3 +2369,57 @@
+ update_rect.height);
+ return TRUE;
+ }
++
++/*
++ * set_fixed_font
++ *
++ * Author - Diane Bruce <db@db.net> VA3DB
++ * Inputs - None
++ * Output - None
++ * Side effects - Try to find a font that fits the screen
++ * giving 80 columns across
++ * KB relies upon the width of a monospace font being equal
++ * in width to one of 80 (NUMBER_OF_COLUMNS) columns.
++ * Bugs - I am sure there must be better ways of doing this.
++ * There is probably a mapping function between
++ * font size and pixel width. I'll look for that next.
++ */
++#define SBUFSIZE 64
++static void
++set_fixed_font(GtkWidget *widget)
++{
++ int width_col;
++ char font_desc[SBUFSIZE];
++ int width_font;
++ int font_size;
++ gint ipfmgadw;
++ PangoFontDescription *pfd;
++ PangoContext *pc;
++ PangoLanguage *pl;
++ PangoFontMetrics *pfm;
++
++ width_col = widget->allocation.width/NUMBER_OF_COLUMNS;
++
++ pc = gtk_widget_get_pango_context (widget);
++ pl = pango_context_get_language (pc);
++
++ for (font_size = 10; font_size < 24; font_size++)
++ {
++ snprintf(font_desc, sizeof(font_desc)-1, "monospace %d", font_size);
++
++ pfd = pango_font_description_from_string (font_desc);
++ pfm = pango_context_get_metrics (pc, pfd, pl);
++ ipfmgadw = pango_font_metrics_get_approximate_digit_width (pfm);
++ if (ipfmgadw/PANGO_SCALE == width_col)
++ {
++ printf("Found a good font [%s]\n", font_desc);
++ pango_font_metrics_unref (pfm);
++ break;
++ }
++ pango_font_metrics_unref (pfm);
++ }
++
++ cursor_offset = 8-pango_font_metrics_get_descent (pfm)/PANGO_SCALE;
++ pango_layout_set_font_description (layout, pfd);
++ pango_font_description_free (pfd);
++}
diff --git a/comms/kb/files/patch-io.c b/comms/kb/files/patch-io.c
new file mode 100644
index 000000000000..041ea0655cb5
--- /dev/null
+++ b/comms/kb/files/patch-io.c
@@ -0,0 +1,533 @@
+--- io.c.orig 2007-07-01 15:19:57.000000000 -0400
++++ io.c 2007-11-24 18:14:00.000000000 -0500
+@@ -17,6 +17,7 @@
+ static void rewrite_contest_file(void);
+ static void write_call_library_file(void);
+ static gint process_tmp_file(const gchar *filnam);
++static char* chomp(char *s);
+
+ static void fill_iend_array(void)
+ {
+@@ -99,24 +100,22 @@
+ strcat(contest_line, cr_array[qnum].tx);
+ strcpy(field_hold, cr_array[qnum].prefix);
+ right_blank_pad(field_hold, sizeof(cr_array[qnum].prefix));
+- strcat(contest_line, field_hold);
+- add_eol_chars (contest_line);
++ sprintf(contest_line,"%s%s\n",contest_line,field_hold);
+ }
+
+ static void read_ini_file(void)
+ {
+ FILE *fp;
+ gchar filnam[13], msg[49], contest_ini_line[76];
+- gint i, icolon, lcil, socil;
++ gint i, socil;
++ char *token;
+ guint answer;
+
+- strcpy(filnam, contest_file_base);
+- strcat(filnam, ".INI");
++ snprintf(filnam,sizeof(filnam), "%s.INI", contest_file_base);
+ fp = fopen(filnam, "r");
+ if(fp==NULL)
+ {
+- strcpy(msg, filnam);
+- strcat(msg, " does not exist. Use default? (Y/N)");
++ snprintf(msg,sizeof(msg),"%s does not exist. Use default? (Y/N)");
+ play_bells (DUPE_SOUND);
+ answer = boxed_message (msg, 0, LT_GRAY);
+ if(toupper_ui(answer)=='Y') fp = fopen("DEFAULT.INI","r");
+@@ -125,53 +124,41 @@
+ socil = sizeof(contest_ini_line);
+ for(i=0; i<MAX_INIT_ITEMS; i++)
+ {
+- fgets(contest_ini_line, socil, fp);
+- if(feof(fp)) break;
+- icolon = kb_index (contest_ini_line, ":");
+- if(icolon>-1)
+- {
+- lcil = strlen(contest_ini_line);
+- if(contest_ini_line[lcil-1]=='\n') contest_ini_line[lcil-1] = '\0';
+- if(contest_ini_line[lcil-2]=='\r') contest_ini_line[lcil-2] = '\0';
+- lcil = strlen(contest_ini_line);
+- if(lcil>icolon+1)
+- concat(init_screen_choices[i], contest_ini_line,
+- icolon+1, lcil-1, COPY);
+- }
++ if(fgets(contest_ini_line, socil, fp) == NULL)
++ break;
++ token = strtok(contest_ini_line, ":\r\n");
++ if (token != NULL)
++ {
++ token = strtok(NULL,":\r\n");
++ if (token != NULL)
++ strcpy(init_screen_choices[i], token);
++ }
+ }
+ for(i=0; i<MAX_SET_ITEMS; i++)
+ {
+- fgets(contest_ini_line, socil, fp);
+- if(feof(fp)) break;
+- icolon = kb_index (contest_ini_line, ":");
+- if(icolon>-1)
+- {
+- lcil = strlen(contest_ini_line);
+- if(contest_ini_line[lcil-1]=='\n') contest_ini_line[lcil-1] = '\0';
+- if(contest_ini_line[lcil-2]=='\r') contest_ini_line[lcil-2] = '\0';
+- lcil = strlen(contest_ini_line);
+- if(lcil>icolon+1)
+- concat(set_screen_choices[i], contest_ini_line,
+- icolon+1, lcil-1, COPY);
+- }
++ if(fgets(contest_ini_line, socil, fp) == NULL)
++ break;
++ token = strtok(contest_ini_line, ":\r\n");
++ if (token != NULL)
++ {
++ token = strtok(NULL,":\r\n");
++ if (token != NULL)
++ strcpy(set_screen_choices[i], token);
++ }
+ }
+ if(!strcmp(set_screen_choices[1], "<NEVER>"))
+ strcpy(set_screen_choices[1], dupe_bracket[0]);
+ for(i=0; i<MAX_KEYER_ITEMS; i++)
+ {
+- fgets(contest_ini_line, socil, fp);
+- if(feof(fp)) break;
+- icolon = kb_index (contest_ini_line, ":");
+- if(icolon>-1)
+- {
+- lcil = strlen(contest_ini_line);
+- if(contest_ini_line[lcil-1]=='\n') contest_ini_line[lcil-1] = '\0';
+- if(contest_ini_line[lcil-2]=='\r') contest_ini_line[lcil-2] = '\0';
+- lcil = strlen(contest_ini_line);
+- if(lcil>icolon+1)
+- concat(keyer_screen_choices[i], contest_ini_line,
+- icolon+1, lcil-1, COPY);
+- }
++ if(fgets(contest_ini_line, socil, fp) == NULL)
++ break;
++ token = strtok(contest_ini_line, ":\r\n");
++ if(token != NULL)
++ {
++ token = strtok(NULL,":\r\n");
++ if (token != NULL)
++ strcpy(keyer_screen_choices[i], token);
++ }
+ }
+ fclose(fp);
+ }
+@@ -187,17 +174,14 @@
+ fp = fopen(filnam, "r");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error reading ");
+- strcat(msg, filnam);
++ snprintf(msg, sizeof(msg), "Error reading %s", filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+ icall_count = 0;
+ socl = sizeof(contest_line);
+- for( ; ; )
++ while(fgets(contest_line, socl, fp) != NULL)
+ {
+- fgets(contest_line, socl, fp);
+- if(feof(fp)) break;
+ icall_count++;
+ fill_cr_array_all (contest_line, icall_count);
+ }
+@@ -257,16 +241,13 @@
+ gchar filnam[13], contest_line[76];
+
+ ded_num = 0;
+- strcpy(filnam, contest_file_base);
+- strcat(filnam, ".DED");
++ sprintf(filnam,"%s.DED", filnam);
+ fp = fopen(filnam, "r");
+ if(fp==NULL)
+ return;
+ socl = sizeof(contest_line);
+- for( ; ; )
++ while(fgets(contest_line, socl, fp) != NULL)
+ {
+- fgets(contest_line, socl, fp);
+- if(feof(fp)) break;
+ ded_num++;
+ strcpy(ded_array[ded_num], contest_line);
+ }
+@@ -276,7 +257,7 @@
+ static void read_locus_file(void)
+ {
+ FILE *fp;
+- gint i, j, lcil, icn, soli;
++ gint i, j, icn, soli;
+ gchar filnam[13], msg[49], clat[5], clong[6];
+ gchar line_in[80];
+ gint n=0;
+@@ -320,20 +301,14 @@
+ fp = fopen(filnam, "r");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error reading ");
+- strcat(msg, filnam);
++ snprintf(msg,sizeof(msg),"Error reading %s",filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+ soli = sizeof(line_in);
+- for( ; ; )
++ while(fgets(line_in, soli, fp) != NULL)
+ {
+- fgets(line_in, soli, fp);
+- if(feof(fp)) break;
+- lcil = strlen(line_in);
+- if(line_in[lcil-1]=='\n') line_in[lcil-1] = '\0';
+- if(line_in[lcil-2]=='\r') line_in[lcil-2] = '\0';
+- lcil = strlen(line_in);
++ chomp(line_in);
+ n++;
+ concat(loci.locus_name[n], line_in,
+ col_num[icn][0], col_num[icn][1], COPY);
+@@ -376,8 +351,7 @@
+ fp = fopen(filnam, "r");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error reading ");
+- strcat(msg, filnam);
++ snprintf(msg, sizeof(msg), "Error reading %s",filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+@@ -385,12 +359,12 @@
+ contest_nc[i][0] = '\0';
+ for(i=0; i<MAX_COUNTRIES; i++)
+ {
+- countries.country_name[i][0] = '\0';
+- countries.country_abv[i][0] = '\0';
+- countries.country_syn[i][0] = '\0';
+- countries.continent_abv[i][0] = '\0';
+- countries.zones_in_country[i][0] = '\0';
+- countries.country_lat[i] = 0.;
++ countries.country_name[i][0] = '\0';
++ countries.country_abv[i][0] = '\0';
++ countries.country_syn[i][0] = '\0';
++ countries.continent_abv[i][0] = '\0';
++ countries.zones_in_country[i][0] = '\0';
++ countries.country_lat[i] = 0.;
+ countries.country_long[i] = 0.;
+ }
+ for(i=0; i<6; i++)
+@@ -401,13 +375,9 @@
+ countries.izone_worked[i][j] = 0;
+ }
+ soli = sizeof(line_in);
+- for( ; ; )
++ while(fgets(line_in, soli, fp) != NULL)
+ {
+- fgets(line_in, soli, fp);
+- if(feof(fp)) break;
+- lcil = strlen(line_in);
+- if(line_in[lcil-1]=='\n') line_in[lcil-1] = '\0';
+- if(line_in[lcil-2]=='\r') line_in[lcil-2] = '\0';
++ chomp(line_in);
+ lcil = strlen(line_in);
+ if(line_in[0]=='-')
+ {
+@@ -456,11 +426,11 @@
+ countries.country_lat[0] = -89.;
+ for(i=0; i<=n; i++)
+ {
+- right_blank_unpad (countries.country_name[i]);
+- right_blank_unpad (countries.country_abv[i]);
+- right_blank_unpad (countries.country_syn[i]);
+- right_blank_unpad (countries.continent_abv[i]);
+- right_blank_unpad (countries.zones_in_country[i]);
++ right_blank_unpad (countries.country_name[i]);
++ right_blank_unpad (countries.country_abv[i]);
++ right_blank_unpad (countries.country_syn[i]);
++ right_blank_unpad (countries.continent_abv[i]);
++ right_blank_unpad (countries.zones_in_country[i]);
+ }
+ for(i=0; i<=notc; i++)
+ {
+@@ -491,16 +461,16 @@
+ for(k=j; k<=n; k++)
+ {
+ strcpy(countries.country_name[k],
+- countries.country_name[k+1]);
++ countries.country_name[k+1]);
+ strcpy(countries.country_abv[k],
+- countries.country_abv[k+1]);
++ countries.country_abv[k+1]);
+ strcpy(countries.country_syn[k],
+- countries.country_syn[k+1]);
++ countries.country_syn[k+1]);
+ strcpy(countries.continent_abv[k],
+- countries.continent_abv[k+1]);
++ countries.continent_abv[k+1]);
+ strcpy(countries.zones_in_country[k],
+- countries.zones_in_country[k+1]);
+- countries.country_lat[k] = countries.country_lat[k+1];
++ countries.zones_in_country[k+1]);
++ countries.country_lat[k] = countries.country_lat[k+1];
+ countries.country_long[k] = countries.country_long[k+1];
+ }
+ n--;
+@@ -557,19 +527,14 @@
+ fp = fopen(clib.filnam, "r");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error reading ");
+- strcat(msg, clib.filnam);
++ snprintf(msg, sizeof(msg), "Error reading %s", clib.filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+ soli = sizeof(line_in);
+- for( ; ; )
++ while(fgets(line_in, soli, fp) != NULL)
+ {
+- fgets(line_in, soli, fp);
+- if(feof(fp)) break;
+- lcil = strlen(line_in);
+- if(line_in[lcil-1]=='\n') line_in[lcil-1] = '\0';
+- if(line_in[lcil-2]=='\r') line_in[lcil-2] = '\0';
++ chomp(line_in);
+ right_blank_pad (line_in, soli);
+ lcil = strlen(line_in);
+ n++;
+@@ -595,9 +560,9 @@
+ fclose(fp);
+ for(i=0; i<=n; i++)
+ {
+- right_blank_unpad (clib.call[i]);
+- right_blank_unpad (clib.country[i]);
+- right_blank_unpad (clib.section[i]);
++ right_blank_unpad (clib.call[i]);
++ right_blank_unpad (clib.country[i]);
++ right_blank_unpad (clib.section[i]);
+ right_blank_unpad (clib.county[i]);
+ }
+ clib.number_of_calls = n+1;
+@@ -606,7 +571,6 @@
+ static void read_help_file(void)
+ {
+ FILE *fp;
+- gint lcil, soli;
+ gchar filnam[13], msg[49];
+ gchar line_in[80];
+ gint n=-1;
+@@ -622,19 +586,13 @@
+ fp = fopen(filnam, "r");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error reading ");
+- strcat(msg, filnam);
++ snprintf(msg,sizeof(msg), "Error reading %s",filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+- soli = sizeof(line_in);
+- for( ; ; )
++ while(fgets(line_in, sizeof(line_in), fp) != NULL)
+ {
+- fgets(line_in, soli, fp);
+- if(feof(fp)) break;
+- lcil = strlen(line_in);
+- if(line_in[lcil-1]=='\n') line_in[lcil-1] = '\0';
+- if(line_in[lcil-2]=='\r') line_in[lcil-2] = '\0';
++ chomp(line_in);
+ n++;
+ strcpy(helpbv.help_lines[n], line_in);
+ }
+@@ -652,13 +610,10 @@
+ fp = fopen(filnam, "w");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error writing ");
+- strcat(msg, filnam);
++ snprintf(msg,sizeof(msg),"Error writing %s",filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+-// fflush(fp);
+-// fsync(fileno(fp));
+ fclose(fp);
+ }
+
+@@ -672,11 +627,7 @@
+ concat(filnam_hold, filnam, 0, idot-1, COPY);
+ else
+ strcpy(filnam_hold, filnam);
+- strcpy(msg, "cp ");
+- strcat(msg, filnam);
+- strcat(msg, " ");
+- strcat(msg, filnam_hold);
+- strcat(msg, ".BAK");
++ snprintf(msg, sizeof(msg), "cp %s %s.BAK",filnam,filnam_hold);
+ icopy = system(msg);
+ return icopy;
+ }
+@@ -687,13 +638,11 @@
+ gchar filnam[13], msg[49], contest_ini_line[76];
+ gint i;
+
+- strcpy(filnam, contest_file_base);
+- strcat(filnam, ".INI");
++ snprintf(filnam, sizeof(filnam), "%s.INIT", contest_file_base);
+ fp = fopen(filnam, "w");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error writing ");
+- strcat(msg, filnam);
++ snprintf(msg, sizeof(msg), "Error writing %s", filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+@@ -703,8 +652,7 @@
+ left_blank_unpad(contest_ini_line);
+ strcat(contest_ini_line, ":");
+ strcat(contest_ini_line, init_screen_choices[i]);
+- add_eol_chars (contest_ini_line);
+- fputs(contest_ini_line, fp);
++ fprintf(fp,"%s\n",contest_ini_line);
+ }
+ for(i=0; i<MAX_SET_ITEMS; i++)
+ {
+@@ -712,8 +660,7 @@
+ left_blank_unpad(contest_ini_line);
+ strcat(contest_ini_line, ":");
+ strcat(contest_ini_line, set_screen_choices[i]);
+- add_eol_chars (contest_ini_line);
+- fputs(contest_ini_line, fp);
++ fprintf(fp,"%s\n",contest_ini_line);
+ }
+ for(i=0; i<MAX_KEYER_ITEMS; i++)
+ {
+@@ -721,8 +668,7 @@
+ left_blank_unpad(contest_ini_line);
+ strcat(contest_ini_line, ":");
+ strcat(contest_ini_line, keyer_screen_choices[i]);
+- add_eol_chars (contest_ini_line);
+- fputs(contest_ini_line, fp);
++ fprintf(fp,"%s\n",contest_ini_line);
+ }
+ fflush(fp);
+ fsync(fileno(fp));
+@@ -738,8 +684,7 @@
+ fp = fopen(filnam, "a");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error writing ");
+- strcat(msg, filnam);
++ snprintf(msg, sizeof(msg), "Error writing %s", filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+@@ -757,21 +702,18 @@
+ FILE *fp;
+ gchar filnam[13], msg[49], contest_line[76];
+
+- strcpy(filnam, contest_file_base);
+- strcat(filnam, ".DED");
++ snprintf(filnam, sizeof(filnam), "%s.DED", contest_file_base);
+ fp = fopen(filnam, "a");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error writing ");
+- strcat(msg, filnam);
++ snprintf(msg, sizeof(msg), "Error writing %s",filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+ strcpy(contest_line, cmd);
+- add_eol_chars (contest_line);
+- fputs(contest_line, fp);
++ fprintf(fp,"%s\n",contest_line);
+ make_contest_line (contest_line, qnum);
+- fputs(contest_line, fp);
++ fprintf(fp, "%s\n", contest_line);
+ fflush(fp);
+ fsync(fileno(fp));
+ fclose(fp);
+@@ -789,8 +731,7 @@
+ fp = fopen(filnam, "w");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error writing ");
+- strcat(msg, filnam);
++ snprintf(msg, sizeof(msg), "Error writing %s", filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+@@ -813,8 +754,7 @@
+ fp = fopen(clib.filnam, "w");
+ if(fp==NULL)
+ {
+- strcpy(msg, "Error writing ");
+- strcat(msg, clib.filnam);
++ snprintf(msg, sizeof(msg),"Error writing %s",clib.filnam);
+ rw_error_box (main_drawing_area, msg);
+ return;
+ }
+@@ -856,8 +796,7 @@
+ strcat(library_line, " ");
+ strcat(library_line, clib.check[9999]);
+ right_blank_unpad(library_line);
+- add_eol_chars (library_line);
+- fputs(library_line, fp);
++ fprintf(fp,"%s\n",library_line);
+ }
+ fflush(fp);
+ fsync(fileno(fp));
+@@ -867,24 +806,35 @@
+ static gint process_tmp_file(const gchar *filnam)
+ {
+ FILE *fp;
++ FILE *pfp;
+ gchar filnam_hold[14], psc_line[81], system_line[41];
+ gint ami_running=-1;
+
+- strcpy(filnam_hold, filnam);
+- strcat(filnam_hold, ".tmp");
+- strcpy(system_line, "ps -C ");
+- strcat(system_line, filnam);
+- strcat(system_line, " | sort > ");
+- strcat(system_line, filnam_hold);
+- system(system_line);
+- fp = fopen(filnam_hold, "r");
+- if(fp!=NULL)
++ snprintf(system_line, sizeof(system_line) - 1, "ps|grep %s|grep -v grep",
++ filnam);
++ pfp = popen(system_line, "r");
++ if(pfp!=NULL)
+ {
+- fgets(psc_line, sizeof(psc_line), fp);
++ fgets(psc_line, sizeof(psc_line), pfp);
+ if(kb_index (psc_line, filnam)>-1)
+ ami_running = 0;
+- fclose(fp);
+- remove(filnam_hold);
++ fclose(pfp);
+ }
+ return ami_running;
+ }
++
++static char*
++chomp(char *s)
++{
++ char *p;
++
++ p = strchr(s, '\n');
++ if (p != NULL)
++ {
++ *p = '\0';
++ p--;
++ if (*p == '\r')
++ *p = '\0';
++ }
++}
++
diff --git a/comms/kb/files/patch-kb.c b/comms/kb/files/patch-kb.c
new file mode 100644
index 000000000000..b1554aeef8b6
--- /dev/null
+++ b/comms/kb/files/patch-kb.c
@@ -0,0 +1,32 @@
+--- kb.c.orig 2007-09-10 14:58:04.000000000 -0400
++++ kb.c 2007-11-24 14:46:35.000000000 -0500
+@@ -1,7 +1,12 @@
+ #include <stdio.h>
+ #include <fcntl.h>
+ #include <sys/ioctl.h>
++#if (defined(__unix__) || defined(unix)) && !defined(USG)
++#include <sys/param.h>
++#endif
++#ifndef BSD
+ #include <sys/io.h>
++#endif
+ #include <stdlib.h>
+ #include <time.h>
+ #include <string.h>
+@@ -3090,10 +3095,14 @@
+
+ gtk_key_snooper_install (kp_snooper, drawing_area);
+
++#ifdef __FreeBSD__
++ fd_bells = open("/dev/speaker", O_RDWR);
++#else
+ fd_bells = open("/dev/kb_bells", O_RDWR);
++#endif
+ g_thread_init (NULL);
+ gtk_main ();
+- close(fd_bells);
+-
++ if(fd_bells > 0)
++ close(fd_bells);
+ return 0;
+ }
diff --git a/comms/kb/files/patch-support.c b/comms/kb/files/patch-support.c
new file mode 100644
index 000000000000..6e28e8e1a5ce
--- /dev/null
+++ b/comms/kb/files/patch-support.c
@@ -0,0 +1,86 @@
+--- support.c.orig 2007-07-18 14:21:10.000000000 -0400
++++ support.c 2007-12-20 18:48:00.000000000 -0500
+@@ -1,3 +1,6 @@
++#ifdef BSDSOUND
++#include BSDSOUND
++#endif
+ #include <termios.h>
+ #include <libgnome/libgnome.h>
+ #include <sys/utsname.h>
+@@ -20,7 +23,6 @@
+ static void concat(gchar *s1, const gchar *s2, gint is2, gint js2,
+ gint nullout_s1);
+ static gint kb_index(const gchar *s1, const gchar *s2);
+-static void add_eol_chars(gchar *line_out);
+ static void left_zero_pad(gchar *s1, gint ss1);
+ static void left_blank_pad(gchar *s1, gint ss1);
+ static void left_blank_unpad(gchar *s1);
+@@ -144,10 +146,22 @@
+ layout);
+ }
+
++#ifdef BSDSOUND
++#include "bsd_bells.c"
++#endif
+ static void play_bells(int isound)
+ {
+- if(!strcmp(set_screen_choices[3], "<YES>"))
+- ioctl(fd_bells, _IO(KB_BELLS_IOCTL_BASE, isound));
++ if(fd_bells<0)
++ return;
++ if(strcmp(set_screen_choices[3], "<YES>") !=0)
++ return;
++#ifdef BSD
++#ifdef BSDSOUND
++ bsd_play_bells(isound);
++#endif
++#else
++ ioctl(fd_bells, _IO(KB_BELLS_IOCTL_BASE, isound));
++#endif
+ }
+
+ static void get_kb_time(void)
+@@ -189,25 +203,8 @@
+
+ static void fill_kb_dt(void)
+ {
+- gchar *t1;
+-
+- t1 = asctime(&kb_time);
+- kb_dt.date[0] = month_num[2*kb_time.tm_mon];
+- kb_dt.date[1] = month_num[2*kb_time.tm_mon+1];
+- kb_dt.date[2] = *(t1+8);
+- if(kb_dt.date[2]==' ')
+- kb_dt.date[2] = '0';
+- kb_dt.date[3] = *(t1+9);
+- kb_dt.date[4] = *(t1+22);
+- kb_dt.date[5] = *(t1+23);
+- kb_dt.date[6] = '\0';
+- kb_dt.time[0] = *(t1+11);
+- kb_dt.time[1] = *(t1+12);
+- kb_dt.time[2] = *(t1+14);
+- kb_dt.time[3] = *(t1+15);
+- kb_dt.time[4] = *(t1+17);
+- kb_dt.time[5] = *(t1+18);
+- kb_dt.time[6] = '\0';
++ strftime(kb_dt.date, sizeof(kb_dt.date), "%m%d%g", &kb_time);
++ strftime(kb_dt.time, sizeof(kb_dt.time), "%H%M%S", &kb_time);
+ }
+
+ static gint idelta_time(const gchar *day1, const gchar *day2,
+@@ -284,15 +281,6 @@
+ return -1;
+ }
+
+-static void add_eol_chars(gchar *line_out)
+-{
+- gint lcil;
+-
+- lcil = strlen(line_out);
+- line_out[lcil] = '\r';
+- line_out[lcil+1] = '\n';
+- line_out[lcil+2] = '\0';
+-}
+
+ static void left_zero_pad(gchar *s1, gint ss1)
+ {
diff --git a/comms/kb/files/pkg_message b/comms/kb/files/pkg_message
new file mode 100644
index 000000000000..1b1b70002057
--- /dev/null
+++ b/comms/kb/files/pkg_message
@@ -0,0 +1,8 @@
+kb is now installed.
+If you want the speaker bell to work, make sure you add
+speaker_load="YES" to /boot/loader.conf if your kernel
+does not have speaker support. You will also need to modify
+/etc/devfs.conf to add permission for users to use the speaker.
+...
+perm speaker 0660
+...
diff --git a/comms/kb/pkg-descr b/comms/kb/pkg-descr
new file mode 100644
index 000000000000..ad9111bd3a58
--- /dev/null
+++ b/comms/kb/pkg-descr
@@ -0,0 +1,14 @@
+The KB contest logging computer program runs on the Linux operating system
+with the Gnome desktop. The program is under development, and currently
+supports the CQ WW, CQ WPX, and ARRL DX contests, plus Field Day.
+Features include on-the-fly dupe checking, CW and voice message keying,
+super check partial, packet (Telnet and rf nodes), networking, and
+radio control (currently for the FT-1000 only). The program is designed
+to be used by U.S. stations, with some support for Canadian stations.
+New features and contests are being added regularly, and I will consider
+adding support for DX stations if there is sufficient demand.
+
+(The port version has bug fixes and some modifications for Canadian stations.
+- db)
+
+WWW: http://www.k2ct.net/kbsoftware/kbsoftware.htm
diff --git a/comms/kb/pkg-plist b/comms/kb/pkg-plist
new file mode 100644
index 000000000000..e6ad72b3a5dc
--- /dev/null
+++ b/comms/kb/pkg-plist
@@ -0,0 +1,15 @@
+bin/kb
+bin/kb_bin
+sbin/kb_server
+etc/rc.d/kbserver
+%%DATADIR%%/CALL_FD.LST
+%%DATADIR%%/CALL_LIB.LST
+%%DATADIR%%/CALL_SS.LST
+%%DATADIR%%/COUNTY.CQP
+%%DATADIR%%/COUNTRY.LST
+%%DATADIR%%/DEFAULT.INI
+%%DATADIR%%/HELP.LST
+%%DATADIR%%/HELPFD.LST
+%%DATADIR%%/SECTION.LST
+%%DATADIR%%/STATE.LST
+@dirrm %%DATADIR%%