$NetBSD: patch-ad,v 1.9 2012/11/19 23:15:10 joerg Exp $ --- main.c.orig 2004-07-27 02:26:47.000000000 +0000 +++ main.c @@ -5,8 +5,14 @@ #include #include #include -#include -#include +#include "config.h" + +#include "yaesu.h" + +static void bye_msg(void); +static int port_open(int, char*[]); +static void cleanup(int); + float freq_to_change_to; char flag_data_return[5]; char data_array[650]; @@ -17,41 +23,14 @@ char mode1, mode2, mode3; char narrow1, narrow2, narrow3, narrow4, narrow5, narrow6; char white_space; +struct termios defaults_serial; + int main(int argc, char* argv[]) { static char version[] = "yaesu v .11lx. May 19th, 1995. Author: Emarit Ranu, KG0CQ."; int fdSer; /* serial file descriptor integer */ int zero_port_byte; char flag_data_return[5]; struct termios termattribs; - struct termios *defaults_serial; - extern splt_tog(); - extern freq_out(); - extern mem_rec(); - extern vfo_2mem(); - extern mem_hide(); - extern mem_2vfo(); - extern step(); - extern lock(); - extern vfo_ab(); - extern clar(); - extern ham_gen(); - extern ptt(); - extern tuner10(); - extern stat_up(); - extern bright(); - extern mode(); - extern strt_tun(); - extern meter_rd(); - extern rd_flags(); - extern rptr_off(); - extern reptear(); - extern ctcss(); - extern stat_out(); - extern aux(); - extern wwv_find(); - extern outport(); - void yaesu(); - void cleanup(); signal(SIGINT, cleanup); yaesu_return = 1; @@ -59,7 +38,7 @@ int main(int argc, char* argv[]) { if (fdSer == -1) { exit(3); } - tcgetattr(fdSer,defaults_serial); /* save current serial settings */ + tcgetattr(fdSer, &defaults_serial); /* save current serial settings */ termattribs.c_iflag = IGNBRK | IGNPAR | IMAXBEL | IXOFF; termattribs.c_oflag = 0; @@ -94,35 +73,35 @@ int main(int argc, char* argv[]) { /* * This function returns the fd for the serial port. */ -port_open(int argc, char* argv[]) { +static int port_open(int argc, char* argv[]) { int fdSer; if (argc == 2) { switch(argv[1][0]) { case '0': - if ((fdSer = open("/dev/ttyS0", O_RDWR )) < 0) { - perror("open of /dev/ttyS0 failed!!!\n"); + if ((fdSer = open("/dev/tty00", O_RDWR )) < 0) { + perror("open of /dev/tty00 failed!!!\n"); exit(3); } break; case '1': - if ((fdSer = open("/dev/ttyS1", O_RDWR )) < 0) { - perror("open of /dev/ttyS1 failed!!!\n"); + if ((fdSer = open("/dev/tty01", O_RDWR )) < 0) { + perror("open of /dev/tty01 failed!!!\n"); exit(3); } break; case '2': - if ((fdSer = open("/dev/ttyS2", O_RDWR )) < 0) { - perror("open of /dev/ttyS2 failed"); + if ((fdSer = open("/dev/tty02", O_RDWR )) < 0) { + perror("open of /dev/tty02 failed"); exit(3); } break; case '3': - if ((fdSer = open("/dev/ttyS3", O_RDWR )) < 0) { - perror("open of /dev/ttyS3 failed"); + if ((fdSer = open("/dev/tty03", O_RDWR )) < 0) { + perror("open of /dev/tty03 failed"); exit(3); } break; @@ -130,6 +109,15 @@ port_open(int argc, char* argv[]) { printf("Invalid serial port number!!!\n Remember: com1 is 0, com2 is 1, etc.\n"); return(-1); } + } else if (argc == 3) { + if (strcmp("-p",argv[1]) != 0) { + perror("Invalid flag"); + exit(3); + } + if ((fdSer = open(argv[2], O_RDWR )) < 0) { + perror("open of serial port failed"); + exit(3); + } } else { printf("usage: yaesu [port #]\n"); exit(3); @@ -137,16 +125,29 @@ port_open(int argc, char* argv[]) { return(fdSer); } -bye_msg() { - -printf("\n Thank you for using KG0CQ's 'yaesu' program, this is version .1lx. You may use this program for as long as you like, it will always be free to use, no matter what version. You may distribute this program freely so long as it distributed in and with the original zipfile or tar file. Please do not distribute modifed versions. A nice Windows version, DOS console version, Linux console, and Linux X version should be on their way in the coming months. If you wish to support the author's efforts just say thanks via email or packet! email: drranu@holly.ColoState.EDU or packet: KG0CQ@KF0UW.#NECO.USA.NOAM Having fun hamming, hope to catch you on the air!!!\n\n"); +static void bye_msg(void) { +printf("\n\n\ + Thank you for using KG0CQ's 'yaesu' program, this is version .1lx.\n\ + You may use this program for as long as you like, it will always \n\ + be free to use, no matter what version. You may distribute this \n\ + program freely so long as it distributed in and with the original \n\ + zipfile or tar file. Please do not distribute modifed versions. \n\ + A nice Windows version, DOS console version, Linux console, and \n\ + Linux X version should be on their way in the coming months. \n\ + If you wish to support the author's efforts just say thanks via\n\ + email or packet!\n\ + \n\ + email: drranu@holly.ColoState.EDU\n\ + packet: KG0CQ@KF0UW.#NECO.USA.NOAM\n\ + \n\ + Having fun hamming, hope to catch you on the air!!!\n\n"); } -void -cleanup(int fdSer, struct termios *defaults_serial) +static void +cleanup(int fdSer) { - tcsetattr(fdSer, TCSANOW, defaults_serial); + tcsetattr(fdSer, TCSANOW, &defaults_serial); close(fdSer); bye_msg(); printf("Killed by signal 2!\n");