#ifndef FD_xtuner_h_ #include "xtuner.h" #endif extern flags_t flags; extern xtuner_data_t xtuner_data; extern mixer_data_t mixer_data; extern FD_xtuner *mainui; extern FD_misc *miscui; /* ======================================================================== */ /* Writes the presets out to file */ /* ======================================================================== */ void write_file(void) { int error_flag; int fd; fd = open(HOMEDIR, O_RDWR); if (fd == -1) { return; } error_flag = write(fd, xtuner_data.MemCh, sizeof(xtuner_data.MemCh)); if (error_flag == -1) { return; } close(fd); } /* ========================================================================= */ /* Reads the presets in from file */ /* ========================================================================= */ void read_file(void) { int i, error_flag; FILE *fdin; /* Open preset file and read in values */ fdin = fopen(HOMEDIR, "a+"); if (fdin == NULL) { printf("Error opening file!"); return; } rewind(fdin); for (i=0; i<10; i++) { error_flag = fread(&xtuner_data.MemCh[i], sizeof(xtuner_data.MemCh[i]), 1, fdin); if (error_flag == 0) { fclose(fdin); return; } } fclose(fdin); } /* ========================================================================= */ /* Gets the command line options */ /* ========================================================================= */ parse_options(int argc, char *argv[]) { int cmd = 1; xtuner_data.rport = 0x30f; flags.miltime_f = OFF; /* Process command line option */ while (cmd < argc) { if (strcmp(argv[cmd],"-0x20") == 0) { xtuner_data.rport = 0x20f; fprintf(stdout,"Port 0x20\n"); } else if (strcmp(argv[cmd],"-0x30") == 0) { /* default port # */ fprintf(stdout,"Port 0x30\n"); } else if (strcmp(argv[cmd],"-24") == 0) { fprintf(stdout,"Using 24hr time format\n"); flags.miltime_f = TRUE; } else { fprintf(stderr,"Usage: xtuner [-0x20 | -0x30] -24 \n"); fprintf(stderr,"Which specifies the port for the radio card and 24hr time format \n"); exit(1); } cmd++; } } /* ======================================================================== */ /* Preforms the io calls related to the sound card */ /* ======================================================================== */ do_ioctl(int cmd, int *arg, char *name, int dir) { int ret; char errmsg[64]; if ((ret = ioctl(mixer_data.dev_fd, cmd, arg)) < 0) { sprintf(errmsg, "Xtuner: ioctl failed on %s %d", name, dir); perror(errmsg); } } /* ======================================================================= */ /* Cleans up on exit */ /* ======================================================================= */ void do_exit() { fl_hide_form(miscui->quitform); fl_show_form(miscui->quitform2,FL_PLACE_MOUSE,FL_TRANSIENT,""); while (fl_do_forms() != miscui->sp) { if (miscui->dp) radiooff(); break; } fl_hide_form(miscui->quitform2); fl_hide_form(mainui->xtuner); fl_free_pixmap(happypixmap); write_file(); #if (defined(BSD) && (BSD >= 199306)) close(fpiopl); #else ioperm(xtuner_data.rport,2,0); #endif exit(0); }