kopia lustrzana https://github.com/jamescoxon/dl-fldigi
				
				
				
			Upstream version 2.09E
							rodzic
							
								
									2eecd2e933
								
							
						
					
					
						commit
						c40dccc5b8
					
				|  | @ -2,6 +2,8 @@ Change Log: | |||
| 
 | ||||
| 2.09  1) Modified src/Makefile.am for FreeBSD name space clash | ||||
|       2) Added psk multi-channel viewer | ||||
|       3) Rewrote audio capture/playback/generate routines to use the | ||||
|          libsndfile C API. Added .au support (32bit floats, host endianness) | ||||
| 
 | ||||
| 2.08  1) Changes to build process: | ||||
| 	     a. Use PortAudio's C API; the C++ bindings are no longer required | ||||
|  |  | |||
							
								
								
									
										10
									
								
								configure.ac
								
								
								
								
							
							
						
						
									
										10
									
								
								configure.ac
								
								
								
								
							|  | @ -4,7 +4,7 @@ | |||
| AC_COPYRIGHT([Copyright (C) 2007 Stelios Bounanos, M0GLD (m0gld AT enotty DOT net)]) | ||||
| 
 | ||||
| AC_PREREQ(2.61) | ||||
| AC_INIT([fldigi], [2.09D], [w1hkj AT w1hkj DOT com]) | ||||
| AC_INIT([fldigi], [2.09E], [w1hkj AT w1hkj DOT com]) | ||||
| AC_CONFIG_AUX_DIR([build-aux]) | ||||
| AM_INIT_AUTOMAKE([-Wall foreign std-options 1.9.6]) | ||||
| AM_MAINTAINER_MODE | ||||
|  | @ -21,7 +21,7 @@ AC_PROG_CC | |||
| # Checks for header files. | ||||
| AC_HEADER_STDC | ||||
| AC_HEADER_DIRENT | ||||
| AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h memory.h netdb.h netinet/in.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h termios.h unistd.h values.h execinfo.h]) | ||||
| AC_CHECK_HEADERS([arpa/inet.h execinfo.h fcntl.h limits.h memory.h netdb.h netinet/in.h regex.h stdint.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h termios.h unistd.h values.h]) | ||||
| 
 | ||||
| # Checks for typedefs, structures, and compiler characteristics. | ||||
| AC_HEADER_STDBOOL | ||||
|  | @ -51,7 +51,7 @@ AC_FUNC_SELECT_ARGTYPES | |||
| AC_TYPE_SIGNAL | ||||
| AC_FUNC_STRFTIME | ||||
| AC_FUNC_STRTOD | ||||
| AC_CHECK_FUNCS([gethostbyname localtime_r memmove memset mkdir select socket strcasecmp strchr strdup strerror strncasecmp strrchr strstr strtol uname]) | ||||
| AC_CHECK_FUNCS([gethostbyname localtime_r memmove memset mkdir select snprintf socket strcasecmp strchr strdup strerror strncasecmp strcasestr strrchr strstr strtol uname vsnprintf]) | ||||
| 
 | ||||
| 
 | ||||
| AC_PRESERVE_HELP_ORDER | ||||
|  | @ -299,7 +299,7 @@ if test "x$ac_cv_want_hamlib" = "xno"; then | |||
| else | ||||
|     PKG_CHECK_EXISTS(hamlib >= 1.2.4, ac_cv_hamlib=yes, ac_cv_hamlib=no) | ||||
|     if test "x$ac_cv_want_hamlib" = "xcheck"; then | ||||
|         PKG_CHECK_MODULES(HAMLIB, hamlib >= 1.2.0, [:], [:]) | ||||
|         PKG_CHECK_MODULES(HAMLIB, hamlib >= 1.2.4, [:], [:]) | ||||
|         if test "x$ac_cv_hamlib" = "xyes"; then | ||||
|             AC_DEFINE(USE_HAMLIB, 1, [Define to 1 if we are using hamlib]) | ||||
|         else | ||||
|  | @ -311,7 +311,7 @@ else | |||
|         else | ||||
|             AC_DEFINE(USE_HAMLIB, 1, [Define to 1 if we are using hamlib]) | ||||
|         fi | ||||
|         PKG_CHECK_MODULES(HAMLIB, hamlib >= 1.2.0) # for the error message | ||||
|         PKG_CHECK_MODULES(HAMLIB, hamlib >= 1.2.4) # for the error message | ||||
|     fi | ||||
| fi | ||||
| AC_SUBST([HAMLIB_CFLAGS]) | ||||
|  |  | |||
|  | @ -233,11 +233,11 @@ void cw::update_Status() | |||
| { | ||||
| 	static char RXmsg[20]; | ||||
| 	static char TXmsg[20]; | ||||
| 	sprintf(RXmsg,"Rx %d", cw_receive_speed); | ||||
| 	snprintf(RXmsg, sizeof(RXmsg), "Rx %d", cw_receive_speed); | ||||
| 	if (usedefaultWPM) | ||||
| 		sprintf(TXmsg,"Tx %d **", progdefaults.defCWspeed); | ||||
| 		snprintf(TXmsg, sizeof(TXmsg), "Tx %d **", progdefaults.defCWspeed); | ||||
| 	else | ||||
| 		sprintf(TXmsg,"Tx %d", progdefaults.CWspeed); | ||||
| 		snprintf(TXmsg, sizeof(TXmsg), "Tx %d", progdefaults.CWspeed); | ||||
| 	put_Status1(RXmsg); | ||||
| 	put_Status2(TXmsg);	 | ||||
| } | ||||
|  |  | |||
|  | @ -66,9 +66,9 @@ void rtty::init() | |||
| 	modem::init(); | ||||
| 	rx_init(); | ||||
| 	put_MODEstatus(mode); | ||||
| 	sprintf(msg1,"Shft %-4.0f", rtty_shift);  | ||||
| 	snprintf(msg1, sizeof(msg1), "Shft %-4.0f", rtty_shift);  | ||||
| 	put_Status1(msg1); | ||||
| 	sprintf(msg2,"Baud %-4.1f", rtty_baud);  | ||||
| 	snprintf(msg2, sizeof(msg2), "Baud %-4.1f", rtty_baud);  | ||||
| 	put_Status2(msg2); | ||||
| 	if (progdefaults.PreferXhairScope) | ||||
| 		digiscope->mode(Digiscope::XHAIRS); | ||||
|  | @ -137,9 +137,9 @@ void rtty::restart() | |||
| 	 | ||||
| 	metric = 0.0; | ||||
| 
 | ||||
| 	sprintf(msg1,"Shft %-4.0f", rtty_shift);  | ||||
| 	snprintf(msg1, sizeof(msg1), "Shft %-4.0f", rtty_shift);  | ||||
| 	put_Status1(msg1); | ||||
| 	sprintf(msg2,"Baud %-4.1f", rtty_baud);  | ||||
| 	snprintf(msg2, sizeof(msg2), "Baud %-4.1f", rtty_baud);  | ||||
| 	put_Status2(msg2); | ||||
| 	put_MODEstatus(mode); | ||||
| } | ||||
|  |  | |||
|  | @ -991,6 +991,13 @@ progdefaults.changed = true; | |||
| initViewer(); | ||||
| } | ||||
| 
 | ||||
| Fl_Spinner *cntTimeout=(Fl_Spinner *)0; | ||||
| 
 | ||||
| static void cb_cntTimeout(Fl_Spinner* o, void*) { | ||||
|   progdefaults.VIEWERtimeout = (int)(o->value()); | ||||
| progdefaults.changed = true; | ||||
| } | ||||
| 
 | ||||
| Fl_Group *tabRTTY=(Fl_Group *)0; | ||||
| 
 | ||||
| Fl_Choice *selShift=(Fl_Choice *)0; | ||||
|  | @ -1948,6 +1955,7 @@ fect after a restart."); | |||
|             o->end(); | ||||
|           } | ||||
|           { Fl_Group* o = tabPSK = new Fl_Group(0, 50, 400, 170, "Psk"); | ||||
|             o->hide(); | ||||
|             { Fl_Counter* o = cntSearchRange = new Fl_Counter(25, 60, 80, 21, "Search Range"); | ||||
|               o->type(1); | ||||
|               o->minimum(10); | ||||
|  | @ -1979,33 +1987,46 @@ fect after a restart."); | |||
|               } | ||||
|               o->end(); | ||||
|             } | ||||
|             { Fl_Group* o = new Fl_Group(15, 140, 370, 75, "PSK Viewer"); | ||||
|             o->end(); | ||||
|           } | ||||
|           { Fl_Group* o = new Fl_Group(0, 50, 400, 170, "PskViewer"); | ||||
|             { Fl_Group* o = new Fl_Group(5, 60, 390, 155); | ||||
|               o->box(FL_ENGRAVED_FRAME); | ||||
|               o->align(FL_ALIGN_TOP_LEFT|FL_ALIGN_INSIDE); | ||||
|               { Fl_Check_Button* o = btnMarquee = new Fl_Check_Button(25, 162, 120, 15, "Marquee style"); | ||||
|               { Fl_Check_Button* o = btnMarquee = new Fl_Check_Button(25, 87, 120, 15, "Marquee style"); | ||||
|                 o->down_box(FL_DOWN_BOX); | ||||
|                 o->callback((Fl_Callback*)cb_btnMarquee); | ||||
|                 o->value(progdefaults.VIEWERmarquee); | ||||
|               } | ||||
|               { Fl_Check_Button* o = btnShowFrequencies = new Fl_Check_Button(25, 190, 150, 15, "Show Frequencies"); | ||||
|               { Fl_Check_Button* o = btnShowFrequencies = new Fl_Check_Button(25, 125, 150, 15, "Show Frequencies"); | ||||
|                 o->down_box(FL_DOWN_BOX); | ||||
|                 o->callback((Fl_Callback*)cb_btnShowFrequencies); | ||||
|                 o->value(progdefaults.VIEWERshowfreq); | ||||
|               } | ||||
|               { Fl_Spinner* o = cntStartFrequency = new Fl_Spinner(315, 185, 60, 25, "Start Frequency:"); | ||||
|               { Fl_Spinner* o = cntStartFrequency = new Fl_Spinner(190, 120, 60, 25, "Start Frequency:"); | ||||
|                 o->callback((Fl_Callback*)cb_cntStartFrequency); | ||||
|                 o->align(FL_ALIGN_RIGHT); | ||||
|                 o->minimum(200); | ||||
|                 o->maximum(1000); | ||||
|                 o->step(100); | ||||
|                 o->value(progdefaults.VIEWERstart); | ||||
|               } | ||||
|               { Fl_Spinner* o = cntChannels = new Fl_Spinner(325, 157, 50, 25, "# Channels:"); | ||||
|               { Fl_Spinner* o = cntChannels = new Fl_Spinner(190, 82, 50, 25, "# Channels:"); | ||||
|                 o->callback((Fl_Callback*)cb_cntChannels); | ||||
|                 o->align(FL_ALIGN_RIGHT); | ||||
|                 o->minimum(5); | ||||
|                 o->maximum(30); | ||||
|                 o->step(1); | ||||
|                 o->value(progdefaults.VIEWERchannels); | ||||
|               } | ||||
|               { Fl_Spinner* o = cntTimeout = new Fl_Spinner(190, 155, 50, 25, "Aging (sec)"); | ||||
|                 o->callback((Fl_Callback*)cb_cntTimeout); | ||||
|                 o->align(FL_ALIGN_RIGHT); | ||||
|                 o->minimum(10); | ||||
|                 o->maximum(180); | ||||
|                 o->step(1); | ||||
|                 o->value(progdefaults.VIEWERtimeout); | ||||
|               } | ||||
|               o->end(); | ||||
|             } | ||||
|             o->end(); | ||||
|  |  | |||
|  | @ -1090,7 +1090,7 @@ progdefaults.changed = true;} | |||
|           } | ||||
|           Fl_Group tabPSK { | ||||
|             label Psk open | ||||
|             xywh {0 50 400 170} | ||||
|             xywh {0 50 400 170} hide | ||||
|           } { | ||||
|             Fl_Counter cntSearchRange { | ||||
|               label {Search Range} | ||||
|  | @ -1120,16 +1120,20 @@ progdefaults.changed = true;} | |||
|                 code0 {o->value(progdefaults.SearchRange);} | ||||
|               } | ||||
|             } | ||||
|             Fl_Group {} { | ||||
|               label {PSK Viewer} open | ||||
|               xywh {15 140 370 75} box ENGRAVED_FRAME align 21 | ||||
|           } | ||||
|           Fl_Group {} { | ||||
|             label PskViewer open | ||||
|             xywh {0 50 400 170} | ||||
|           } { | ||||
|             Fl_Group {} {open | ||||
|               xywh {5 60 390 155} box ENGRAVED_FRAME align 21 | ||||
|             } { | ||||
|               Fl_Check_Button btnMarquee { | ||||
|                 label {Marquee style} | ||||
|                 callback {progdefaults.VIEWERmarquee = o->value(); | ||||
| progdefaults.changed = true; | ||||
| initViewer();} | ||||
|                 xywh {25 162 120 15} down_box DOWN_BOX | ||||
|                 xywh {25 87 120 15} down_box DOWN_BOX | ||||
|                 code0 {o->value(progdefaults.VIEWERmarquee);} | ||||
|               } | ||||
|               Fl_Check_Button btnShowFrequencies { | ||||
|  | @ -1137,7 +1141,7 @@ initViewer();} | |||
|                 callback {progdefaults.VIEWERshowfreq = o->value(); | ||||
| progdefaults.changed = true; | ||||
| initViewer();} | ||||
|                 xywh {25 190 150 15} down_box DOWN_BOX | ||||
|                 xywh {25 125 150 15} down_box DOWN_BOX | ||||
|                 code0 {o->value(progdefaults.VIEWERshowfreq);} | ||||
|               } | ||||
|               Fl_Spinner cntStartFrequency { | ||||
|  | @ -1145,7 +1149,7 @@ initViewer();} | |||
|                 callback {progdefaults.VIEWERstart = (int)(o->value()); | ||||
| progdefaults.changed = true; | ||||
| initViewer();} | ||||
|                 xywh {315 185 60 25} | ||||
|                 xywh {190 120 60 25} align 8 | ||||
|                 code0 {o->minimum(200);} | ||||
|                 code1 {o->maximum(1000);} | ||||
|                 code2 {o->step(100);} | ||||
|  | @ -1155,13 +1159,23 @@ initViewer();} | |||
|                 label {\# Channels:} | ||||
|                 callback {progdefaults.VIEWERchannels = (int)(o->value()); | ||||
| progdefaults.changed = true; | ||||
| initViewer();} selected | ||||
|                 xywh {325 157 50 25} | ||||
| initViewer();} | ||||
|                 xywh {190 82 50 25} align 8 | ||||
|                 code0 {o->minimum(5);} | ||||
|                 code1 {o->maximum(30);} | ||||
|                 code2 {o->step(1);} | ||||
|                 code3 {o->value(progdefaults.VIEWERchannels);} | ||||
|               } | ||||
|               Fl_Spinner cntTimeout { | ||||
|                 label {Aging (sec)} | ||||
|                 callback {progdefaults.VIEWERtimeout = (int)(o->value()); | ||||
| progdefaults.changed = true;} selected | ||||
|                 xywh {190 155 50 25} align 8 | ||||
|                 code0 {o->minimum(10);} | ||||
|                 code1 {o->maximum(180);} | ||||
|                 code2 {o->step(1);} | ||||
|                 code3 {o->value(progdefaults.VIEWERtimeout);} | ||||
|               } | ||||
|             } | ||||
|           } | ||||
|           Fl_Group tabRTTY { | ||||
|  |  | |||
|  | @ -1,16 +1,20 @@ | |||
| #include <config.h> | ||||
| 
 | ||||
| #include "Viewer.h" | ||||
| #include "main.h" | ||||
| #include "viewpsk.h" | ||||
| #include "configuration.h" | ||||
| #include "waterfall.h" | ||||
| #include <FL/Enumerations.H> | ||||
| #include <FL/Fl_Slider.H> | ||||
| 
 | ||||
| #include <sys/types.h> | ||||
| #include <regex.h> | ||||
| 
 | ||||
| #include <string> | ||||
| 
 | ||||
| string bwsrfreq; | ||||
| string bwsrline[MAXCHANNELS]; | ||||
| string ucaseline[MAXCHANNELS]; | ||||
| string tofind; | ||||
| 
 | ||||
| static int  brwsFreq[MAXCHANNELS]; | ||||
| static int  freq; | ||||
|  | @ -24,8 +28,6 @@ string dkblue; | |||
| string dkgreen; | ||||
| string bkselect; | ||||
| string white; | ||||
| string snow; | ||||
| string slategray1; | ||||
| string bkgnd[2]; | ||||
| 
 | ||||
| int cols[] = {100, 0}; | ||||
|  | @ -51,11 +53,11 @@ string fline; | |||
| 		else     dfreq = rfc - freq; | ||||
|  	} else  | ||||
|  		dfreq = freq; | ||||
| 	if (progdefaults.VIEWERshowfreq) | ||||
| 		sprintf(szLine,"%10.3f", dfreq / 1000.0); | ||||
| 	else | ||||
| 		sprintf(szLine,"%3d", progdefaults.VIEWERchannels - i);	 | ||||
| //	if (szLine[0] == ' ') strcpy(szLine, &szLine[1]);
 | ||||
|   	if (progdefaults.VIEWERshowfreq) | ||||
|  		snprintf(szLine, sizeof(szLine), "%10.3f", dfreq / 1000.0); | ||||
|   	else | ||||
|  		snprintf(szLine, sizeof(szLine), "%3d", progdefaults.VIEWERchannels - i);	 | ||||
| 
 | ||||
| 	fline = "@f"; | ||||
| 	fline += bkselect.c_str(); | ||||
| 	fline += white.c_str(); | ||||
|  | @ -67,6 +69,44 @@ string fline; | |||
| 	return fline; | ||||
| } | ||||
| 
 | ||||
| regex_t* seek_re = 0; | ||||
| void re_comp(const char* needle) | ||||
| { | ||||
|         if (seek_re) | ||||
|                 regfree(seek_re); | ||||
|         else | ||||
|                 seek_re = new regex_t; | ||||
|         if (!(needle && *needle && regcomp(seek_re, needle, REG_EXTENDED | REG_ICASE | REG_NOSUB) == 0)) { | ||||
|                 delete seek_re; | ||||
|                 seek_re = 0; | ||||
|         } | ||||
| } | ||||
| // match haystack against seek_re
 | ||||
| bool re_find(const char* haystack) | ||||
| { | ||||
|         return seek_re && !regexec(seek_re, haystack, 0, 0, REG_NOTBOL | REG_NOTEOL); | ||||
| } | ||||
| #if !HAVE_STRCASESTR | ||||
| // a simple inefficient implementation of strcasestr
 | ||||
| char* strcasestr(const char* haystack, const char* needle) | ||||
| { | ||||
|         char *h = NULL, *n = NULL, *p; | ||||
| 	if ((h = strdup(haystack)) == NULL || (n = strdup(needle)) == NULL) { | ||||
| 		free(h); | ||||
|                 free(n); | ||||
|                 return NULL; | ||||
|         } | ||||
| 	for (p = h; *p; p++) | ||||
| 		*p = tolower(*p); | ||||
| 	for (p = n; *p; p++) | ||||
| 		*p = tolower(*p); | ||||
| 	p = strstr(h, n); | ||||
| 	free(h); | ||||
| 	free(n); | ||||
| 	return p; | ||||
| } | ||||
| #endif // !HAVE_STRCASESTR
 | ||||
| 
 | ||||
| void pskBrowser::resize(int x, int y, int w, int h) { | ||||
| 		unsigned int nuchars = (w - cols[0] - 20) / cwidth; | ||||
| 		string bline; | ||||
|  | @ -78,14 +118,13 @@ void pskBrowser::resize(int x, int y, int w, int h) { | |||
| 
 | ||||
| 				bline = freqformat(i); | ||||
| 
 | ||||
| 				if (!tofind.empty()) | ||||
| 				if (ucaseline[i].find(tofind) != string::npos) | ||||
| 				if (re_find(bwsrline[i].c_str())) | ||||
| 					bline.append(dkred); | ||||
| 				else if (!progdefaults.myCall.empty()) | ||||
| 					if (ucaseline[i].find(progdefaults.myCall) != string::npos) | ||||
| 						bline.append(dkgreen); | ||||
| 			 | ||||
| 				bline.append(bwsrline[i]); | ||||
| 				else if (!progdefaults.myCall.empty() && | ||||
| 					 strcasestr(bwsrline[i].c_str(), progdefaults.myCall.c_str())) | ||||
| 					bline.append(dkgreen); | ||||
| 
 | ||||
| 				bline.append("@.").append(bwsrline[i]); | ||||
| 				Fl_Hold_Browser::add(bline.c_str()); | ||||
| 			} | ||||
| 		} | ||||
|  | @ -99,47 +138,59 @@ Fl_Button *btnCloseViewer=(Fl_Button *)0; | |||
| Fl_Button *btnClearViewer=(Fl_Button *)0; | ||||
| pskBrowser *brwsViewer=(pskBrowser *)0; | ||||
| Fl_Input  *inpSeek = (Fl_Input *)0; | ||||
| Fl_Slider *sldrViewerSquelch = (Fl_Slider *)0; | ||||
| Fl_Light_Button *chkBeep = 0; | ||||
| 
 | ||||
| // Adjust and return fg color to ensure good contrast with bg
 | ||||
| static Fl_Color adjust_color(Fl_Color fg, Fl_Color bg) | ||||
| { | ||||
| 	Fl_Color adj; | ||||
| 	unsigned max = 24; | ||||
| 	while ((adj = fl_contrast(fg, bg)) != fg  &&  max--) | ||||
| 		fg = (adj == FL_WHITE) ? fl_color_average(fg, FL_WHITE, .9) | ||||
| 				       : fl_color_average(fg, FL_BLACK, .9); | ||||
| 	return fg; | ||||
| } | ||||
| static void make_colors() | ||||
| { | ||||
| 	char tempstr[20]; | ||||
| 	sprintf(tempstr,"@C%d",  | ||||
| 			fl_color_cube(128 * (FL_NUM_RED - 1) / 255, | ||||
|             0 * (FL_NUM_GREEN - 1) / 255, | ||||
|             0 * (FL_NUM_BLUE - 1) / 255)); // dark red
 | ||||
|     dkred = "@b"; | ||||
|     dkred += tempstr; | ||||
| 	sprintf(tempstr,"@C%d",  | ||||
| 			fl_color_cube(0 * (FL_NUM_RED - 1) / 255, | ||||
|             128 * (FL_NUM_GREEN - 1) / 255, | ||||
|             0 * (FL_NUM_BLUE - 1) / 255)); // dark green
 | ||||
|     dkgreen = "@b"; | ||||
|     dkgreen += tempstr; | ||||
| 	sprintf(tempstr,"@C%d",  | ||||
| 			fl_color_cube(0 * (FL_NUM_RED - 1) / 255, | ||||
|             0 * (FL_NUM_GREEN - 1) / 255, | ||||
|             128 * (FL_NUM_BLUE - 1) / 255)); // dark blue
 | ||||
|     dkblue = "@b"; | ||||
|     dkblue += tempstr; | ||||
| 	sprintf(tempstr,"@C%d",  | ||||
| 			fl_color_cube(248 * (FL_NUM_RED - 1) / 255, | ||||
|             248 * (FL_NUM_GREEN - 1) / 255, | ||||
|             248 * (FL_NUM_BLUE - 1) / 255)); // white foreground
 | ||||
|     white = tempstr; | ||||
|     sprintf(tempstr, "@B%d", FL_SELECTION_COLOR); | ||||
|     bkselect = tempstr;                      // default selection color bkgnd
 | ||||
| 	sprintf(tempstr,"@B%d",  | ||||
| 			fl_color_cube(255 * (FL_NUM_RED - 1) / 255, | ||||
|             255 * (FL_NUM_GREEN - 1) / 255, | ||||
|             255 * (FL_NUM_BLUE - 1) / 255)); // snow background
 | ||||
|     snow = tempstr; | ||||
|     bkgnd[0] = snow; | ||||
| 	sprintf(tempstr,"@B%d",  | ||||
| 			fl_color_cube(198 * (FL_NUM_RED - 1) / 255, | ||||
|             226 * (FL_NUM_GREEN - 1) / 255, | ||||
|             255 * (FL_NUM_BLUE - 1) / 255)); // slategray1 background
 | ||||
|     slategray1 = tempstr; | ||||
|     bkgnd[1] = slategray1; | ||||
| 
 | ||||
| 	snprintf(tempstr, sizeof(tempstr), "@b@C%d", | ||||
| 		 adjust_color(fl_color_cube(128 * (FL_NUM_RED - 1) / 255, | ||||
| 					    0 * (FL_NUM_GREEN - 1) / 255, | ||||
| 					    0 * (FL_NUM_BLUE - 1) / 255), | ||||
| 			      FL_BACKGROUND2_COLOR)); // dark red
 | ||||
| 	dkred = tempstr; | ||||
| 
 | ||||
| 	snprintf(tempstr, sizeof(tempstr), "@b@C%d", | ||||
| 		 adjust_color(fl_color_cube(0 * (FL_NUM_RED - 1) / 255, | ||||
| 					    128 * (FL_NUM_GREEN - 1) / 255, | ||||
| 					    0 * (FL_NUM_BLUE - 1) / 255), | ||||
| 			      FL_BACKGROUND2_COLOR)); // dark green
 | ||||
| 	dkgreen = tempstr; | ||||
| 
 | ||||
| 	snprintf(tempstr, sizeof(tempstr), "@b@C%d", | ||||
| 		 adjust_color(fl_color_cube(0 * (FL_NUM_RED - 1) / 255, | ||||
| 					    0 * (FL_NUM_GREEN - 1) / 255, | ||||
| 					    128 * (FL_NUM_BLUE - 1) / 255), | ||||
| 			      FL_BACKGROUND2_COLOR)); // dark blue
 | ||||
| 	dkblue = tempstr; | ||||
| 
 | ||||
| 	snprintf(tempstr, sizeof(tempstr), "@C%d", FL_FOREGROUND_COLOR); // foreground
 | ||||
| 	white = tempstr; | ||||
| 
 | ||||
| 	snprintf(tempstr, sizeof(tempstr), "@B%d", | ||||
| 		 adjust_color(FL_SELECTION_COLOR, FL_FOREGROUND_COLOR)); // default selection color bkgnd
 | ||||
| 	bkselect = tempstr; | ||||
| 
 | ||||
| 	snprintf(tempstr, sizeof(tempstr), "@B%d", FL_BACKGROUND2_COLOR); // background for odd rows
 | ||||
| 	bkgnd[0] = tempstr; | ||||
| 
 | ||||
| 	Fl_Color bg2 = fl_color_average(FL_BACKGROUND2_COLOR, FL_BLACK, .9); | ||||
| 	if (bg2 == FL_BLACK) | ||||
| 		bg2 = fl_color_average(FL_BACKGROUND2_COLOR, FL_WHITE, .9); | ||||
| 	snprintf(tempstr, sizeof(tempstr), "@B%d", adjust_color(bg2, FL_FOREGROUND_COLOR)); // even rows
 | ||||
| 	bkgnd[1] = tempstr; | ||||
| } | ||||
| 
 | ||||
| static void evalcwidth() | ||||
|  | @ -165,8 +216,7 @@ void ClearViewer() { | |||
|   		else 		   freq = progdefaults.VIEWERstart + 100 * (progdefaults.VIEWERchannels - 1 - i); | ||||
| 
 | ||||
| 		bline = freqformat(i); | ||||
|   		bwsrline[i] = ""; | ||||
|   		ucaseline[i] = ""; | ||||
|   		bwsrline[i].clear(); | ||||
|   		brwsViewer->add(bline.c_str()); | ||||
|   	} | ||||
| 	if (progdefaults.VIEWERshowfreq) | ||||
|  | @ -201,9 +251,13 @@ static void cb_brwsViewer(Fl_Hold_Browser*, void*) { | |||
| 
 | ||||
| static void cb_Seek(Fl_Input *, void *) | ||||
| { | ||||
| 	tofind = inpSeek->value(); | ||||
| 	for (size_t i = 0; i < tofind.length(); i++) | ||||
| 		tofind[i] = toupper(tofind[i]); | ||||
| 	re_comp(inpSeek->value()); | ||||
| } | ||||
| 
 | ||||
| static void cb_Squelch(Fl_Slider *, void *) | ||||
| { | ||||
| 	progdefaults.VIEWERsquelch = sldrViewerSquelch->value(); | ||||
| 	progdefaults.changed = true; | ||||
| } | ||||
| 
 | ||||
| Fl_Double_Window* createViewer() { | ||||
|  | @ -217,6 +271,7 @@ Fl_Double_Window* createViewer() { | |||
| 	int viewerheight = 50 + cheight * progdefaults.VIEWERchannels + 4; | ||||
| 
 | ||||
| 	w = new Fl_Double_Window(viewerwidth, viewerheight, "Psk Viewer"); | ||||
| 	w->xclass(PACKAGE_NAME); | ||||
| 	p = new Fl_Pack(0,0,viewerwidth, viewerheight); | ||||
| 		Fl_Pack *p1 = new Fl_Pack(0, 0, viewerwidth, 25); | ||||
| 			p1->type(1); | ||||
|  | @ -224,11 +279,13 @@ Fl_Double_Window* createViewer() { | |||
| 	    	inpSeek = new Fl_Input(50, 5, 200, 25, "Find: ");  | ||||
|     		inpSeek->callback((Fl_Callback*)cb_Seek); | ||||
|     		inpSeek->when(FL_WHEN_CHANGED); | ||||
| 			inpSeek->textfont(FL_SCREEN); | ||||
|     		inpSeek->value("CQ"); | ||||
| 			chkBeep = new Fl_Light_Button(inpSeek->x() + 4, inpSeek->y(), 60, inpSeek->h(), "Beep"); | ||||
|     		bx = new Fl_Box(250, 5, 200, 25); | ||||
|     		p1->resizable(bx); | ||||
|     	p1->end(); | ||||
|     	tofind = "CQ"; | ||||
|     	inpSeek->do_callback(); | ||||
| 
 | ||||
|     	brwsViewer = new pskBrowser(2, 25, viewerwidth, viewerheight - 50); | ||||
|     	brwsViewer->callback((Fl_Callback*)cb_brwsViewer); | ||||
|  | @ -242,13 +299,20 @@ Fl_Double_Window* createViewer() { | |||
| 		 | ||||
| 		Fl_Pack *p2 = new Fl_Pack(0, viewerheight - 25, viewerwidth, 25); | ||||
| 			p2->type(1); | ||||
| 			bx = new Fl_Box(0,435, 10, 25); | ||||
|     		btnClearViewer = new Fl_Button(10, 435, 65, 25, "Clear"); | ||||
| 			bx = new Fl_Box(0,viewerheight - 25, 10, 25); | ||||
|     		btnClearViewer = new Fl_Button(10, viewerheight - 25, 65, 25, "Clear"); | ||||
|     		btnClearViewer->callback((Fl_Callback*)cb_btnClearViewer); | ||||
|     		bx = new Fl_Box(75, 435, 10, 25); | ||||
| 	    	btnCloseViewer = new Fl_Button(85, 435, 65, 25, "Close"); | ||||
|     		bx = new Fl_Box(75, viewerheight - 25, 10, 25); | ||||
| 	    	btnCloseViewer = new Fl_Button(85, viewerheight - 25, 65, 25, "Close"); | ||||
|     		btnCloseViewer->callback((Fl_Callback*)cb_btnCloseViewer); | ||||
|     		bx = new Fl_Box(150, 435, 300, 25); | ||||
|     		bx = new Fl_Box(140, viewerheight - 25, 5, 25); | ||||
|     		sldrViewerSquelch = new Fl_Slider(145, viewerheight - 25, 200, 25); | ||||
|     		sldrViewerSquelch->tooltip("Set Viewer Squelch"); | ||||
|     		sldrViewerSquelch->type(FL_HOR_NICE_SLIDER); | ||||
|     		sldrViewerSquelch->range(0.0, 100.0); | ||||
|     		sldrViewerSquelch->value(progdefaults.VIEWERsquelch); | ||||
|     		sldrViewerSquelch->callback((Fl_Callback*)cb_Squelch); | ||||
|     		bx = new Fl_Box(345, viewerheight - 25, 25, 25); | ||||
|     		p2->resizable(bx); | ||||
| 		p2->end(); | ||||
| 		p->resizable(brwsViewer); | ||||
|  | @ -292,40 +356,44 @@ void viewaddchr(int ch, int freq, char c) { | |||
| 
 | ||||
| 	int index = progdefaults.VIEWERchannels - 1 - ch; | ||||
| 	if (progdefaults.VIEWERmarquee) { | ||||
| 		if (bwsrline[index].length() > nchars ) { | ||||
| 		if (bwsrline[index].length() > nchars ) | ||||
| 			bwsrline[index].erase(0,1); | ||||
| 			ucaseline[index].erase(0,1); | ||||
| 		} | ||||
| 		if (c >= ' ' && c <= 'z') { | ||||
| 		if (c >= ' ' && c <= '~') | ||||
| 			bwsrline[index] += c; | ||||
| 			ucaseline[index] += toupper(c); | ||||
| 		} else { | ||||
| 		else | ||||
| 			bwsrline[index] += ' '; | ||||
| 			ucaseline[index] += ' '; | ||||
| 		} | ||||
| 	} else { | ||||
| 		if (c >= ' ' && c <= 'z') { | ||||
| 		if (c >= ' ' && c <= '~') | ||||
| 			bwsrline[index] += c; | ||||
| 			ucaseline[index] += toupper(c); | ||||
| 		} else { | ||||
| 		else | ||||
| 			bwsrline[index] += ' '; | ||||
| 			ucaseline[index] += ' '; | ||||
| 		} | ||||
| 		if (bwsrline[index].length() > nchars) { | ||||
| 			bwsrline[index] = ""; | ||||
| 			ucaseline[index] = ""; | ||||
| 		} | ||||
| 		if (bwsrline[index].length() > nchars) | ||||
| 			bwsrline[index].clear(); | ||||
| 	} | ||||
| 	nuline = freqformat(index); | ||||
| 
 | ||||
| 	if (!tofind.empty()) | ||||
| 		if (ucaseline[index].find(tofind) != string::npos) | ||||
| 			nuline.append(dkred); | ||||
| 	else if (!progdefaults.myCall.empty()) | ||||
| 		if (ucaseline[index].find(progdefaults.myCall) != string::npos) | ||||
| 			nuline.append(dkgreen); | ||||
| 			 | ||||
| 	nuline.append(bwsrline[index]); | ||||
| 	if (re_find(bwsrline[index].c_str())) { | ||||
| 		nuline.append(dkred); | ||||
| 		if (chkBeep->value()) | ||||
| 			fl_beep(); | ||||
| 	} | ||||
| 	else if (!progdefaults.myCall.empty() && | ||||
| 		 strcasestr(bwsrline[index].c_str(), progdefaults.myCall.c_str())) { | ||||
| 		nuline.append(dkgreen); | ||||
| 		if (chkBeep->value()) | ||||
| 			fl_beep(); | ||||
| 	} | ||||
| 
 | ||||
| 	nuline.append("@.").append(bwsrline[index]); | ||||
| 	brwsViewer->text(1 + index, nuline.c_str()); | ||||
| 	brwsViewer->redraw(); | ||||
| } | ||||
| 
 | ||||
| void viewclearchannel(int ch) | ||||
| { | ||||
| 	int index = progdefaults.VIEWERchannels - 1 - ch; | ||||
| 	string nuline = freqformat(index); | ||||
| 	bwsrline[index] = ""; | ||||
| 	brwsViewer->text( 1 + index, nuline.c_str()); | ||||
| 	brwsViewer->redraw(); | ||||
| } | ||||
|  |  | |||
|  | @ -190,7 +190,7 @@ Font_Browser::Font_Browser(const char *lbl ) : | |||
|    | ||||
| 	char buf[5]; | ||||
| 	for (int i = 1; i < 48; i+=1) { | ||||
| 		sprintf(buf, "%d", i); | ||||
|             snprintf(buf, sizeof(buf), "%d", i); | ||||
|         lst_Size->add(buf); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -393,7 +393,7 @@ void dominoex::eval_s2n(complex curr, complex n) | |||
| 
 | ||||
| 	display_metric(metric); | ||||
| 
 | ||||
| 	sprintf(dommsg, "s/n %3.0f dB", metric); | ||||
| 	snprintf(dommsg, sizeof(dommsg), "s/n %3.0f dB", metric); | ||||
| 	put_Status1(dommsg); | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -151,6 +151,11 @@ extern Fl_Group *tabPSK; | |||
| extern Fl_Counter *cntSearchRange; | ||||
| extern Fl_Check_Button *btnPSKmailSweetSpot; | ||||
| extern Fl_Counter *cntServerOffset; | ||||
| extern Fl_Check_Button *btnMarquee; | ||||
| extern Fl_Check_Button *btnShowFrequencies; | ||||
| extern Fl_Spinner *cntStartFrequency; | ||||
| extern Fl_Spinner *cntChannels; | ||||
| extern Fl_Spinner *cntTimeout; | ||||
| extern Fl_Group *tabRTTY; | ||||
| extern Fl_Choice *selShift; | ||||
| extern Fl_Choice *selBaud; | ||||
|  |  | |||
|  | @ -25,5 +25,6 @@ extern Fl_Double_Window* createViewer(); | |||
| extern void openViewer(); | ||||
| extern void viewaddchr(int ch, int freq, char c); | ||||
| extern void initViewer(); | ||||
| extern void viewclearchannel(int ch); | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -170,6 +170,8 @@ struct configuration { | |||
| 	bool	VIEWERshowfreq; | ||||
| 	int		VIEWERstart; | ||||
| 	int		VIEWERchannels; | ||||
| 	double	VIEWERsquelch; | ||||
| 	int		VIEWERtimeout; | ||||
| 
 | ||||
| public: | ||||
| 	void writeDefaultsXML(); | ||||
|  |  | |||
|  | @ -25,11 +25,11 @@ public: | |||
| 	int		error; | ||||
| 	MixerException() { *szError = 0; error = 0; } | ||||
| 	MixerException(int e) { | ||||
| 		sprintf(szError,"Error: %d, %s", e, strerror(e)); | ||||
| 		snprintf(szError, sizeof(szError), "Error: %d, %s", e, strerror(e)); | ||||
| 		error = e; | ||||
| 	} | ||||
| 	MixerException(char *s) { | ||||
| 		sprintf(szError,"Error: %s", s); | ||||
| 		snprintf(szError, sizeof(szError), "Error: %s", s); | ||||
| 		error = 1; | ||||
| 	} | ||||
| }; | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ | |||
| // Copyright (C) 2006-2007
 | ||||
| //              Dave Freese, W1HKJ
 | ||||
| //
 | ||||
| // Copyright (C) 2007
 | ||||
| // Copyright (C) 2007-2008
 | ||||
| //              Stelios Bounanos, M0GLD
 | ||||
| //
 | ||||
| // This file is part of fldigi.
 | ||||
|  | @ -28,32 +28,15 @@ | |||
| #ifndef _SOUND_H | ||||
| #define _SOUND_H | ||||
| 
 | ||||
| #include <stdio.h> | ||||
| #include <errno.h> | ||||
| #include <stdlib.h> | ||||
| #include <cstring> | ||||
| #include <unistd.h> | ||||
| 
 | ||||
| #include <sys/ioctl.h> | ||||
| #include <fcntl.h> | ||||
| 
 | ||||
| #include <sys/types.h> | ||||
| #include <sys/stat.h> | ||||
| #include <errno.h> | ||||
| #include <sys/soundcard.h> | ||||
| #include <math.h> | ||||
| 
 | ||||
| #include <string> | ||||
| #include <vector> | ||||
| #if USE_SNDFILE | ||||
| 	#include <sndfile.hh> | ||||
| 	#include <sndfile.h> | ||||
| #endif | ||||
| #include <iostream> | ||||
| 
 | ||||
| #if USE_PORTAUDIO | ||||
| 	#include <portaudio.h> | ||||
| #endif | ||||
| 
 | ||||
| #include <samplerate.h> | ||||
| 
 | ||||
| #define MAXSC 32767.0; | ||||
|  | @ -100,9 +83,9 @@ protected: | |||
| 	float		*src_buffer; | ||||
| 
 | ||||
| #if USE_SNDFILE | ||||
| 	SndfileHandle* ofCapture; | ||||
| 	SndfileHandle* ifPlayback; | ||||
| 	SndfileHandle* ofGenerate; | ||||
| 	SNDFILE* ofCapture; | ||||
| 	SNDFILE* ifPlayback; | ||||
| 	SNDFILE* ofGenerate; | ||||
| #endif | ||||
| 
 | ||||
| 	bool	capture; | ||||
|  | @ -114,7 +97,7 @@ protected: | |||
| 	int  readPlayback(double *buff, int count); | ||||
| #if USE_SNDFILE | ||||
| 	bool format_supported(int format); | ||||
| 	void tag_file(SndfileHandle *fh, const char *title); | ||||
| 	void tag_file(SNDFILE *sndfile, const char *title); | ||||
| #endif | ||||
| public: | ||||
| 	cSound(); | ||||
|  | @ -126,9 +109,10 @@ public: | |||
| 	virtual int	Read(double *, int) = 0; | ||||
| 	virtual bool	full_duplex(void) { return false; } | ||||
| #if USE_SNDFILE | ||||
| 	int		Capture(bool on); | ||||
| 	int		Playback(bool on); | ||||
| 	int		Generate(bool on); | ||||
| 	void		get_file_params(const char* def_fname, char** fname, int* format); | ||||
| 	int		Capture(bool val); | ||||
| 	int		Playback(bool val); | ||||
| 	int		Generate(bool val); | ||||
| #endif | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -100,6 +100,16 @@ const__ uint32_t floor2(uint32_t n); | |||
| } // extern "C"
 | ||||
| #endif | ||||
| 
 | ||||
| #if !defined(NDEBUG) && defined(deprecated__) | ||||
| #include <stdio.h> | ||||
| #include <string.h> | ||||
| deprecated__ typeof(sprintf) sprintf; | ||||
| /* there are far too many of these in the qrz code
 | ||||
| deprecated__ typeof(strcpy) strcpy; | ||||
| deprecated__ typeof(strcat) strcat; | ||||
| */ | ||||
| #endif | ||||
| 
 | ||||
| #endif /* UTIL_H */ | ||||
| 
 | ||||
| /*
 | ||||
|  |  | |||
|  | @ -67,6 +67,8 @@ private: | |||
| 	int				dcdbits; | ||||
| 	int				sigsearch[MAXCHANNELS]; | ||||
| 	int				waitcount[MAXCHANNELS]; | ||||
| 	time_t			now; | ||||
| 	time_t			timeout[MAXCHANNELS]; | ||||
| 
 | ||||
| 	void			rx_symbol(int ch, complex symbol); | ||||
| 	void 			rx_bit(int ch, int bit); | ||||
|  |  | |||
|  | @ -117,13 +117,17 @@ int writeadif () { | |||
| 
 | ||||
| void putadif(int num, const char *s) | ||||
| { | ||||
| 	char tempstr[80], tempfld[80]; | ||||
| 	memset(tempstr, 0, 80); | ||||
| 	strcpy(tempfld, s); | ||||
| 	if (strlen(tempfld) > fields[num].size) | ||||
| 		tempfld[fields[num].size -1] = 0; | ||||
| 	sprintf(tempstr, "<%s:%zu>%s", fields[num].name, strlen(tempfld), tempfld); | ||||
| 	adif.append(tempstr); | ||||
|         char tempstr[100]; | ||||
|         size_t slen = strlen(s); | ||||
|         if (slen > fields[num].size) slen = fields[num].size; | ||||
|         int n = snprintf(tempstr, sizeof(tempstr), "<%s:%zu>", fields[num].name, slen); | ||||
|         if (n == -1) { | ||||
|                 perror("putadif snprintf"); | ||||
|                 return; | ||||
|         } | ||||
|         memcpy(tempstr + n, s, slen); | ||||
|         tempstr[n + slen] = '\0'; | ||||
|         adif.append(tempstr); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -147,12 +151,12 @@ int submit_log(void) | |||
| 	time(&t); | ||||
|         tm = gmtime(&t); | ||||
| 		strftime(logdate, sizeof(logdate), "%d %b %Y", tm); | ||||
| 		sprintf(adifdate,"%04d%02d%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); | ||||
| 		snprintf(adifdate, sizeof(adifdate), "%04d%02d%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); | ||||
| 		strftime(logtime, sizeof(logtime), "%H%M", tm); | ||||
| 
 | ||||
| 	const char *mode = mode_info[active_modem->get_mode()].sname; | ||||
| 	 | ||||
| 	sprintf(strFreqMhz,"%-12f", wf->dFreq()/1.0e6); | ||||
| 	snprintf(strFreqMhz, sizeof(strFreqMhz), "%-12f", wf->dFreq()/1.0e6); | ||||
| 
 | ||||
| 	adif.erase(); | ||||
| 	 | ||||
|  | @ -188,8 +192,9 @@ int submit_log(void) | |||
| 
 | ||||
| 	writeadif(); | ||||
| 	 | ||||
| 	strcpy(msgbuf.mtext, log_msg.c_str()); | ||||
| 	 | ||||
| 	strncpy(msgbuf.mtext, log_msg.c_str(), sizeof(msgbuf.mtext)); | ||||
| 	msgbuf.mtext[sizeof(msgbuf.mtext) - 1] = '\0'; | ||||
| 
 | ||||
| 	if ((msqid = msgget(LOG_MKEY, 0666 | IPC_CREAT)) == -1) { | ||||
| 		errmsg = "msgget: "; | ||||
| 		errmsg.append(strerror(errno)); | ||||
|  |  | |||
|  | @ -965,7 +965,7 @@ void cb_picTxSendColor( Fl_Widget *w, void *who) | |||
| 			for (ix = 0; ix < W; ix++) | ||||
| 				outbuf[rowstart + rgb*W + ix] = inbuf[rowstart + rgb + ix*3]; | ||||
| 	} | ||||
| 	sprintf(my->picheader, "\nSending Pic:%dx%dC;", W, H); | ||||
| 	snprintf(my->picheader, sizeof(my->picheader), "\nSending Pic:%dx%dC;", W, H); | ||||
| 	my->xmtbytes = W * H * 3; | ||||
| 	my->color = true; | ||||
| 	my->rgb = 0; | ||||
|  | @ -1001,7 +1001,7 @@ void cb_picTxSendGrey( Fl_Widget *w, void *who) | |||
| 	unsigned char *inbuf = my->xmtimg; | ||||
| 	for (int i = 0; i < W*H; i++) | ||||
| 		outbuf[i] = ( 31 * inbuf[i*3] + 61 * inbuf[i*3 + 1] + 8 * inbuf[i*3 + 2])/100; | ||||
| 	sprintf(my->picheader, "\nSending Pic:%dx%d;", W, H); | ||||
| 	snprintf(my->picheader, sizeof(my->picheader), "\nSending Pic:%dx%d;", W, H); | ||||
| 	my->xmtbytes = W * H; | ||||
| 	my->color = false; | ||||
| 	my->col = 0; | ||||
|  |  | |||
|  | @ -171,6 +171,8 @@ configuration progdefaults = { | |||
| 	true,			// bool	VIEWERshowfreq
 | ||||
| 	500,			// int		VIEWERstart
 | ||||
| 	20,				// int		VIEWERchannels
 | ||||
| 	20.0,			// double	VIEWERsquelch
 | ||||
| 	15,				// int  VIEWERtimeout
 | ||||
| }; | ||||
| 
 | ||||
| const char *szBaudRates[] = { | ||||
|  | @ -230,7 +232,8 @@ enum TAG { \ | |||
| 	MICIN, LINEIN, ENABLEMIXER, MUTEINPUT, | ||||
| 	PALETTE0, PALETTE1, PALETTE2, PALETTE3, PALETTE4,  | ||||
| 	PALETTE5, PALETTE6, PALETTE7, PALETTE8, | ||||
| 	VIEWERMARQUEE, VIEWERSHOWFREQ, VIEWERSTART, VIEWERCHANNELS | ||||
| 	VIEWERMARQUEE, VIEWERSHOWFREQ, VIEWERSTART,  | ||||
| 	VIEWERCHANNELS, VIEWERSQUELCH, VIEWERTIMEOUT | ||||
| }; | ||||
| //	, ALT_TEXT_WIDGETS };
 | ||||
| 	 | ||||
|  | @ -418,6 +421,8 @@ void configuration::writeDefaultsXML() | |||
| 	writeXMLbool(f, "VIEWERSHOWFREQ", VIEWERshowfreq); | ||||
| 	writeXMLint(f, "VIEWERSTART", VIEWERstart); | ||||
| 	writeXMLint(f, "VIEWERCHANNELS", VIEWERchannels); | ||||
| 	writeXMLdbl(f, "VIEWERSQUELCH", VIEWERsquelch); | ||||
| 	writeXMLint(f, "VIEWERTIMEOUT", VIEWERtimeout); | ||||
| 	 | ||||
| 	f << "</FLDIGI_DEFS>\n"; | ||||
| 	f.close(); | ||||
|  | @ -841,6 +846,12 @@ bool configuration::readDefaultsXML() | |||
| 					case VIEWERCHANNELS : | ||||
| 						VIEWERchannels = atoi(xml->getNodeData()); | ||||
| 						break; | ||||
| 					case VIEWERSQUELCH : | ||||
| 						VIEWERsquelch = atof(xml->getNodeData()); | ||||
| 						break; | ||||
| 					case VIEWERTIMEOUT : | ||||
| 						VIEWERtimeout = atoi(xml->getNodeData()); | ||||
| 						break; | ||||
| //					case ALT_TEXT_WIDGETS :
 | ||||
| //						alt_text_widgets = atoi(xml->getNodeData());
 | ||||
| //						break;
 | ||||
|  | @ -977,6 +988,8 @@ bool configuration::readDefaultsXML() | |||
| 				else if (!strcmp("VIEWERSHOWFREQ", nodeName))	tag = VIEWERSHOWFREQ; | ||||
| 				else if (!strcmp("VIEWERSTART", nodeName))		tag = VIEWERSTART; | ||||
| 				else if (!strcmp("VIEWERCHANNELS", nodeName))	tag = VIEWERCHANNELS; | ||||
| 				else if (!strcmp("VIEWERSQUELCH", nodeName))	tag = VIEWERSQUELCH; | ||||
| 				else if (!strcmp("VIEWERTIMEOUT", nodeName))	tag = VIEWERTIMEOUT; | ||||
| //				else if (!strcmp("ALT_TEXT_WIDGETS", nodeName)) 	tag = ALT_TEXT_WIDGETS;
 | ||||
| 				else tag = IGNORE; | ||||
| 				} | ||||
|  |  | |||
|  | @ -235,7 +235,7 @@ void pCNTR(string &s, size_t &i) | |||
| 	int  contestval; | ||||
| 	contestval = contest_count.count + progdefaults.ContestStart; | ||||
| 	contest_count.Format(progdefaults.ContestDigits, progdefaults.UseLeadingZeros); | ||||
| 	sprintf(contest_count.szCount, contest_count.fmt.c_str(), contestval); | ||||
| 	snprintf(contest_count.szCount, sizeof(contest_count.szCount), contest_count.fmt.c_str(), contestval); | ||||
| 	s.replace (i, 6, contest_count.szCount); | ||||
| } | ||||
| 
 | ||||
|  | @ -245,8 +245,8 @@ void pDECR(string &s, size_t &i) | |||
| 	contest_count.count--; | ||||
| 	contestval = contest_count.count + progdefaults.ContestStart; | ||||
| 	s.replace (i, 6, ""); | ||||
| 	sprintf(contest_count.szCount, contest_count.fmt.c_str(), contestval); | ||||
| 	sprintf(contest_count.szDisp,"Next Nbr: %s", contest_count.szCount); | ||||
| 	snprintf(contest_count.szCount, sizeof(contest_count.szCount), contest_count.fmt.c_str(), contestval); | ||||
| 	snprintf(contest_count.szDisp, sizeof(contest_count.szDisp), "Next Nbr: %s", contest_count.szCount); | ||||
| 	put_status(contest_count.szDisp); | ||||
| } | ||||
| 
 | ||||
|  | @ -256,8 +256,8 @@ void pINCR(string &s, size_t &i) | |||
| 	contest_count.count++; | ||||
| 	contestval = contest_count.count + progdefaults.ContestStart; | ||||
| 	s.replace (i, 6, ""); | ||||
| 	sprintf(contest_count.szCount, contest_count.fmt.c_str(), contestval); | ||||
| 	sprintf(contest_count.szDisp,"Next Nbr: %s", contest_count.szCount); | ||||
| 	snprintf(contest_count.szCount, sizeof(contest_count.szCount), contest_count.fmt.c_str(), contestval); | ||||
| 	snprintf(contest_count.szDisp, sizeof(contest_count.szDisp), "Next Nbr: %s", contest_count.szCount); | ||||
| 	put_status(contest_count.szDisp); | ||||
| } | ||||
| 
 | ||||
|  | @ -310,7 +310,7 @@ int MACROTEXT::loadMacros(string filename) | |||
| 	} | ||||
| // clear all of the macros
 | ||||
| 	for (int i = 0; i < 20; i++) { | ||||
| 		sprintf(szTemp,"%d", i+1); | ||||
| 		snprintf(szTemp, sizeof(szTemp), "%d", i+1); | ||||
| 		name[i] = "Macro "; | ||||
| 		name[i] = name[i] + szTemp; | ||||
| 		text[i] = ""; | ||||
|  |  | |||
|  | @ -226,8 +226,13 @@ void QRZ::OpenQRZFiles( const char *fname ) | |||
|   } | ||||
|   memset( index, 0, idxsize ); | ||||
| 
 | ||||
|   fread( &idxhdr.dataname, 1, 48, idxfile ); | ||||
|   fread( index, 1, idxsize, idxfile ) ; | ||||
|   if (fread( &idxhdr.dataname, 1, 48, idxfile ) != 1 || | ||||
|       fread( index, 1, idxsize, idxfile ) != 1) { | ||||
|     fclose( idxfile ); | ||||
|     free( index ); | ||||
|     QRZvalid = 0; | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   fflush( stdout ); | ||||
| 
 | ||||
|  | @ -895,7 +900,7 @@ char * QRZ::CSV_Record() | |||
| { | ||||
|   static char info[256]; | ||||
|   memset( info, 0, 256 ); | ||||
|   snprintf( info, 256, "%s,%s,%s,%s,%s,%s,%s,%s,%s", | ||||
|   snprintf( info,  sizeof(info) - 1, "%s,%s,%s,%s,%s,%s,%s,%s,%s", | ||||
|             GetCall(), Qopclass, Qefdate, | ||||
|             Qlname, Qfname, Qmail_str, Qmail_city, Qmail_st, Qmail_zip ); | ||||
|   return info; | ||||
|  | @ -905,7 +910,7 @@ char *QRZ::Fmt_Record() | |||
| { | ||||
|   static char info[256]; | ||||
|   memset( info, 0, 256 ); | ||||
|   sprintf( info, "%s   %s : %s\n%s %s\n%s\n%s, %s  %s\n", | ||||
|   snprintf( info, sizeof(info) - 1, "%s   %s : %s\n%s %s\n%s\n%s, %s  %s\n", | ||||
|            GetCall(), Qopclass, Qefdate, | ||||
|            Qfname, Qlname, | ||||
|            Qmail_str, | ||||
|  |  | |||
|  | @ -443,14 +443,14 @@ void psk::update_syncscope() | |||
| 	s2n = 10.0*log10( snratio ); | ||||
| 	display_metric(metric); | ||||
| 
 | ||||
| 	sprintf(msg1, "s/n %2d dB", (int)(floor(s2n)));  | ||||
| 	snprintf(msg1, sizeof(msg1), "s/n %2d dB", (int)(floor(s2n)));  | ||||
|     put_Status1(msg1); | ||||
| 
 | ||||
| 	if (imdratio < 1) | ||||
| 		imd = 10.0*log10( imdratio ); | ||||
| 	else | ||||
| 		imd = 0.0; | ||||
| 	sprintf(msg2, "imd %3d dB", (int)(floor(imd)));  | ||||
| 	snprintf(msg2, sizeof(msg2), "imd %3d dB", (int)(floor(imd)));  | ||||
|     put_Status2(msg2); | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -81,6 +81,7 @@ void viewpsk::init() | |||
| 		frequency[i] = nomfreq[i]; | ||||
| 		for (int j = 0; j < 16; j++) | ||||
| 			syncbuf[i * 16 + j] = 0.0; | ||||
| 		timeout[i] = -1; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -144,8 +145,10 @@ void viewpsk::rx_bit(int ch, int bit) | |||
| 	if ((shreg[ch] & 3) == 0) { | ||||
| 		c = psk_varicode_decode(shreg[ch] >> 2); | ||||
| 		shreg[ch] = 0; | ||||
| 		if (c != -1) | ||||
| 		if (c != -1) { | ||||
| 			REQ(&viewaddchr, ch, (int)frequency[ch], c); | ||||
| 			timeout[ch] = now + progdefaults.VIEWERtimeout; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  | @ -220,7 +223,7 @@ void viewpsk::rx_symbol(int ch, complex symbol) | |||
| 		break; | ||||
| 
 | ||||
| 	default: | ||||
| 		if (metric[ch] > progdefaults.sldrSquelchValue) | ||||
| 		if (metric[ch] > progdefaults.VIEWERsquelch) | ||||
| 			dcd[ch] = true; | ||||
| 		else  | ||||
| 			dcd[ch] = false; | ||||
|  | @ -243,6 +246,8 @@ int viewpsk::rx_process(const double *buf, int len) | |||
| 	while (len-- > 0) { | ||||
| // process all CHANNELS (25)
 | ||||
| 		for (int channel = 0; channel < progdefaults.VIEWERchannels; channel++) { | ||||
| 			now = time(NULL); | ||||
| 			 | ||||
| // Mix with the internal NCO for each channel
 | ||||
| 			z[channel] = complex ( *buf * cos(phaseacc[channel]), *buf * sin(phaseacc[channel]) ); | ||||
| 
 | ||||
|  | @ -279,6 +284,10 @@ int viewpsk::rx_process(const double *buf, int len) | |||
| 		buf++; | ||||
| 	} | ||||
| 	for (int channel = 0; channel < progdefaults.VIEWERchannels; channel++) {		 | ||||
| 		if (timeout[channel] != -1 && timeout[channel] < now) { | ||||
| 			REQ( &viewclearchannel, channel); | ||||
| 			timeout[channel] = -1; | ||||
| 		} | ||||
| 		if (sigsearch[channel]) | ||||
| 			findsignal(channel); | ||||
| 		else { | ||||
|  |  | |||
|  | @ -57,10 +57,14 @@ struct rmode_name_t { | |||
| 	{ RIG_MODE_PKTFM, "PKTFM" }, | ||||
| 	{ RIG_MODE_ECSSUSB, "ECSSUSB" }, | ||||
| 	{ RIG_MODE_ECSSLSB, "ECSSLSB" }, | ||||
| 	{ RIG_MODE_FAX, "FAX" }, | ||||
| 	{ RIG_MODE_FAX, "FAX" } | ||||
| // the above are covered by our requirement that hamlib be >= 1.2.4
 | ||||
| #if (defined(RIG_MODE_SAM) && defined(RIG_MODE_SAL) && defined(RIG_MODE_SAH)) | ||||
| 	, // C99 trailing commas in enumerations not yet in the C++ standard
 | ||||
| 	{ RIG_MODE_SAM, "SAM" }, | ||||
| 	{ RIG_MODE_SAL, "SAL" }, | ||||
| 	{ RIG_MODE_SAH, "SAH" } | ||||
| #endif | ||||
| }; | ||||
| 
 | ||||
| map<string, rmode_t> mode_nums; | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ | |||
| // Copyright (C) 2006-2007
 | ||||
| //              Dave Freese, W1HKJ
 | ||||
| //
 | ||||
| // Copyright (C) 2007
 | ||||
| // Copyright (C) 2007-2008
 | ||||
| //              Stelios Bounanos, M0GLD
 | ||||
| //
 | ||||
| // This file is part of fldigi.
 | ||||
|  | @ -27,6 +27,21 @@ | |||
| 
 | ||||
| #include <config.h> | ||||
| 
 | ||||
| #include <iostream> | ||||
| 
 | ||||
| #include <cstdio> | ||||
| #include <cstdlib> | ||||
| #include <errno.h> | ||||
| #include <unistd.h> | ||||
| 
 | ||||
| #include <sys/ioctl.h> | ||||
| #include <fcntl.h> | ||||
| #include <sys/types.h> | ||||
| #include <sys/stat.h> | ||||
| 
 | ||||
| #include <sys/soundcard.h> | ||||
| #include <math.h> | ||||
| 
 | ||||
| #include "sound.h" | ||||
| #include "configuration.h" | ||||
| #include <FL/Fl.H> | ||||
|  | @ -52,125 +67,124 @@ cSound::~cSound() | |||
| 	if (rx_src_state) src_delete (rx_src_state); | ||||
| 	if (tx_src_state) src_delete (tx_src_state); | ||||
| #if USE_SNDFILE | ||||
| 	delete ofGenerate; | ||||
| 	delete ofCapture; | ||||
| 	delete ifPlayback; | ||||
| 	if (ofGenerate) sf_close(ofGenerate); | ||||
| 	if (ofCapture) sf_close(ofCapture); | ||||
| 	if (ifPlayback) sf_close(ifPlayback); | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| #if USE_SNDFILE | ||||
| int cSound::Capture(bool on) | ||||
| void cSound::get_file_params(const char* def_fname, char** fname, int* format) | ||||
| { | ||||
| 	if (on) { | ||||
| 		string deffilename = "./capture.wav"; | ||||
| 		const char *formats; | ||||
| 		if (format_supported(SF_FORMAT_FLAC | SF_FORMAT_PCM_16)) | ||||
| 			formats = "*.{wav,flac}"; | ||||
| 		else | ||||
| 			formats = "*.wav"; | ||||
| 	const char* suffixes; | ||||
| 	if (format_supported(SF_FORMAT_FLAC | SF_FORMAT_PCM_16)) | ||||
| 		suffixes = "*.{wav,flac,au}"; | ||||
| 	else | ||||
| 		suffixes = "*.{wav,au}"; | ||||
| 
 | ||||
| 		char *fn = File_Select("Capture audio file", formats, deffilename.c_str(), 0); | ||||
| 		if (fn) { | ||||
| 			int format; | ||||
| 			char *suffix = strrchr(fn, '.'); | ||||
| 			if (suffix && !strcasecmp(suffix, ".flac")) | ||||
| 				format = SF_FORMAT_FLAC; | ||||
| 			else | ||||
| 				format = SF_FORMAT_WAV; | ||||
| 			ofCapture = new SndfileHandle(fn, SFM_WRITE, | ||||
| 						      format | SF_FORMAT_PCM_16, | ||||
| 						      1, sample_frequency); | ||||
| 			if (!*ofCapture) { | ||||
| 				cerr << "Could not write " << fn << endl; | ||||
| 				delete ofCapture; | ||||
| 				ofCapture = 0; | ||||
| 				return 0; | ||||
| 			} | ||||
| 			ofCapture->command(SFC_SET_UPDATE_HEADER_AUTO, 0, SF_TRUE); | ||||
| 			tag_file(ofCapture, "Captured audio"); | ||||
| 	if ((*fname = File_Select("Audio file", suffixes, def_fname, 0)) == 0) | ||||
| 		return; | ||||
| 
 | ||||
| 	char* suffix = strrchr(*fname, '.'); | ||||
| 	if (suffix && !strcasecmp(suffix, ".flac")) | ||||
| 		*format = SF_FORMAT_FLAC | SF_FORMAT_PCM_16; | ||||
| 	else if (suffix && !strcasecmp(suffix, ".au")) | ||||
| 		*format = SF_FORMAT_AU | SF_FORMAT_FLOAT | SF_ENDIAN_CPU; | ||||
| 	else | ||||
| 		*format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; | ||||
| } | ||||
| 
 | ||||
| int cSound::Capture(bool val) | ||||
| { | ||||
| 	if (!val) { | ||||
| 		if (ofCapture) { | ||||
| 			int err; | ||||
| 			if ((err = sf_close(ofCapture)) != 0) | ||||
| 				cerr << "sf_close error: " << sf_error_number(err) << '\n'; | ||||
| 			ofCapture = 0; | ||||
| 		} | ||||
| 		else | ||||
| 			return 0; | ||||
| 		capture = false; | ||||
| 		return 1; | ||||
| 	} | ||||
| 	else { | ||||
| 		delete ofCapture; | ||||
| 		ofCapture = 0; | ||||
| 
 | ||||
| 	char* fname; | ||||
| 	int format; | ||||
| 	get_file_params("./capture.wav", &fname, &format); | ||||
| 	if (!fname) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	// frames (ignored), freq, channels, format, sections (ignored), seekable (ignored)
 | ||||
| 	SF_INFO info = { 0, sample_frequency, 1, format, 0, 0 }; | ||||
| 	if ((ofCapture = sf_open(fname, SFM_WRITE, &info)) == NULL) { | ||||
| 		cerr << "Could not write " << fname << '\n'; | ||||
| 		return 0; | ||||
| 	} | ||||
| 	capture = on; | ||||
| 	if (sf_command(ofCapture, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) != SF_TRUE) | ||||
| 		cerr << "ofCapture update header command failed: " << sf_strerror(ofCapture) << '\n'; | ||||
| 	tag_file(ofCapture, "Captured audio"); | ||||
| 
 | ||||
| 	capture = true; | ||||
| 	return 1; | ||||
| } | ||||
| 
 | ||||
| int cSound::Playback(bool on) | ||||
| int cSound::Playback(bool val) | ||||
| { | ||||
| 	if (on) { | ||||
| 		string deffilename = "./playback.wav"; | ||||
| 		const char *formats; | ||||
| 		if (format_supported(SF_FORMAT_FLAC | SF_FORMAT_PCM_16)) | ||||
| 			formats = "*.{wav,flac}"; | ||||
| 		else | ||||
| 			formats = "*.wav"; | ||||
| 
 | ||||
| 		char *fn = File_Select("Playback audio file", formats, deffilename.c_str(), 0); | ||||
| 		if (fn) { | ||||
| 			ifPlayback = new SndfileHandle(fn); | ||||
| 			if (!*ifPlayback) { | ||||
| 				cerr << "Could not read " << fn << endl; | ||||
| 				delete ifPlayback; | ||||
| 				ifPlayback = 0; | ||||
| 				return 0; | ||||
| 			} | ||||
| 			playback = true; | ||||
| 	if (!val) { | ||||
| 		if (ifPlayback) { | ||||
| 			int err; | ||||
| 			if ((err = sf_close(ifPlayback)) != 0) | ||||
| 				cerr << "sf_close error: " << sf_error_number(err) << '\n'; | ||||
| 			ifPlayback = 0; | ||||
| 		} | ||||
| 		else | ||||
| 			return 0; | ||||
| 	} | ||||
| 	else { | ||||
| 		delete ifPlayback; | ||||
| 		ifPlayback = 0; | ||||
| 		playback = false; | ||||
| 		return 1; | ||||
| 	} | ||||
| 	char* fname; | ||||
| 	int format; | ||||
| 	get_file_params("./playback.wav", &fname, &format); | ||||
| 	if (!fname) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	SF_INFO info = { 0, 0, 0, 0, 0, 0 }; | ||||
| 	if ((ifPlayback = sf_open(fname, SFM_READ, &info)) == NULL) { | ||||
| 		cerr << "Could not read " << fname << '\n'; | ||||
| 		return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	playback = true; | ||||
| 	return 1; | ||||
| } | ||||
| 
 | ||||
| int cSound::Generate(bool on) | ||||
| int cSound::Generate(bool val) | ||||
| { | ||||
| 	if (on) { | ||||
| 		string deffilename = "./generate.wav"; | ||||
| 		const char *formats; | ||||
| 		if (format_supported(SF_FORMAT_FLAC | SF_FORMAT_PCM_16)) | ||||
| 			formats = "*.{wav,flac}"; | ||||
| 		else | ||||
| 			formats = "*.wav"; | ||||
| 
 | ||||
| 		char *fn = File_Select("Generate audio file", formats, deffilename.c_str(), 0); | ||||
| 		if (fn) { | ||||
| 			int format; | ||||
| 			char *suffix = strrchr(fn, '.'); | ||||
| 			if (suffix && !strcasecmp(suffix, ".flac")) | ||||
| 				format = SF_FORMAT_FLAC; | ||||
| 			else | ||||
| 				format = SF_FORMAT_WAV; | ||||
| 			ofGenerate = new SndfileHandle(fn, SFM_WRITE, | ||||
| 						       format | SF_FORMAT_PCM_16, | ||||
| 						       1, sample_frequency); | ||||
| 			if (!*ofGenerate) { | ||||
| 				cerr << "Could not write " << fn << endl; | ||||
| 				delete ofGenerate; | ||||
| 				ofGenerate = 0; | ||||
| 				return 0; | ||||
| 			} | ||||
| 			ofGenerate->command(SFC_SET_UPDATE_HEADER_AUTO, 0, SF_TRUE); | ||||
| 			tag_file(ofGenerate, "Generated audio"); | ||||
| 
 | ||||
| 	if (!val) { | ||||
| 		if (ofGenerate) { | ||||
| 			int err; | ||||
| 			if ((err = sf_close(ofGenerate)) != 0) | ||||
| 				cerr << "sf_close error: " << sf_error_number(err) << '\n'; | ||||
| 			ofGenerate = 0; | ||||
| 		} | ||||
| 		else | ||||
| 			return 0; | ||||
| 		generate = false; | ||||
| 		return 1; | ||||
| 	} | ||||
| 	else { | ||||
| 		delete ofGenerate; | ||||
| 		ofGenerate = 0; | ||||
| 
 | ||||
| 	char* fname; | ||||
| 	int format; | ||||
| 	get_file_params("./generate.wav", &fname, &format); | ||||
| 	if (!fname) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	// frames (ignored), freq, channels, format, sections (ignored), seekable (ignored)
 | ||||
| 	SF_INFO info = { 0, sample_frequency, 1, format, 0, 0 }; | ||||
| 	if ((ofGenerate = sf_open(fname, SFM_WRITE, &info)) == NULL) { | ||||
| 		cerr << "Could not write " << fname << '\n'; | ||||
| 		return 0; | ||||
| 	} | ||||
| 	generate = on; | ||||
| 	if (sf_command(ofGenerate, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) != SF_TRUE) | ||||
| 		cerr << "ofGenerate update header command failed: " << sf_strerror(ofGenerate) << '\n'; | ||||
| 	tag_file(ofGenerate, "Generated audio"); | ||||
| 
 | ||||
| 	generate = true; | ||||
| 	return 1; | ||||
| } | ||||
| #endif // USE_SNDFILE
 | ||||
|  | @ -178,25 +192,25 @@ int cSound::Generate(bool on) | |||
| void cSound::writeGenerate(double *buff, int count) | ||||
| { | ||||
| #if USE_SNDFILE | ||||
| 	ofGenerate->writef(buff, count); | ||||
| 	sf_writef_double(ofGenerate, buff, count); | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| void cSound::writeCapture(double *buff, int count) | ||||
| { | ||||
| #if USE_SNDFILE | ||||
| 	ofCapture->writef(buff, count); | ||||
| 	sf_writef_double(ofCapture, buff, count); | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| int  cSound::readPlayback(double *buff, int count) | ||||
| int cSound::readPlayback(double *buff, int count) | ||||
| { | ||||
| #if USE_SNDFILE | ||||
| 	sf_count_t r = ifPlayback->readf(buff, count); | ||||
| 	sf_count_t r = sf_readf_double(ifPlayback, buff, count); | ||||
| 
 | ||||
| 	while (r < count) { | ||||
| 		ifPlayback->seek(0, SEEK_SET); | ||||
| 		r += ifPlayback->readf(buff + r, count - r); | ||||
| 		sf_seek(ifPlayback, 0, SEEK_SET); | ||||
| 		r += sf_readf_double(ifPlayback, buff + r, count - r); | ||||
|                 if (r == 0) | ||||
|                         break; | ||||
|         } | ||||
|  | @ -215,28 +229,32 @@ bool cSound::format_supported(int format) | |||
|         return sf_format_check(&fmt_test); | ||||
| } | ||||
| 
 | ||||
| void cSound::tag_file(SndfileHandle *fh, const char *title) | ||||
| void cSound::tag_file(SNDFILE *sndfile, const char *title) | ||||
| { | ||||
|        if (fh->setString(SF_STR_TITLE, title)) | ||||
|                return; | ||||
| 	int err; | ||||
| 	if ((err = sf_set_string(sndfile, SF_STR_TITLE, title)) != 0) { | ||||
| 		cerr << "sf_set_string STR_TITLE: " << sf_error_number(err) << '\n'; | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
|        fh->setString(SF_STR_COPYRIGHT, progdefaults.myName.c_str()); | ||||
|        fh->setString(SF_STR_SOFTWARE, PACKAGE_NAME "-" PACKAGE_VERSION); | ||||
|        fh->setString(SF_STR_ARTIST, progdefaults.myCall.c_str()); | ||||
| 	sf_set_string(sndfile, SF_STR_COPYRIGHT, progdefaults.myName.c_str()); | ||||
| 	sf_set_string(sndfile, SF_STR_SOFTWARE, PACKAGE_NAME "-" PACKAGE_VERSION); | ||||
| 	sf_set_string(sndfile, SF_STR_ARTIST, progdefaults.myCall.c_str()); | ||||
| 
 | ||||
|        char s[64]; | ||||
|        snprintf(s, sizeof(s), "%s freq=%s", | ||||
|                 active_modem->get_mode_name(), inpFreq->value()); | ||||
|        fh->setString(SF_STR_COMMENT, s); | ||||
| 	char s[64]; | ||||
| 	snprintf(s, sizeof(s), "%s freq=%s", | ||||
| 		 active_modem->get_mode_name(), inpFreq->value()); | ||||
| 	sf_set_string(sndfile, SF_STR_COMMENT, s); | ||||
| 
 | ||||
|        time_t t = time(0); | ||||
|        struct tm zt; | ||||
|        (void)gmtime_r(&t, &zt); | ||||
|        if (strftime(s, sizeof(s), "%F %Tz", &zt) > 0) | ||||
|                fh->setString(SF_STR_DATE, s); | ||||
| 	time_t t = time(0); | ||||
| 	struct tm zt; | ||||
| 	(void)gmtime_r(&t, &zt); | ||||
| 	if (strftime(s, sizeof(s), "%F %Tz", &zt) > 0) | ||||
| 		sf_set_string(sndfile, SF_STR_DATE, s); | ||||
| } | ||||
| #endif // USE_SNDFILE
 | ||||
| 
 | ||||
| 
 | ||||
| cSoundOSS::cSoundOSS(const char *dev ) { | ||||
| 	device			= dev; | ||||
| 	cbuff			= 0; | ||||
|  |  | |||
|  | @ -444,7 +444,7 @@ void throb::rx(complex in) | |||
| 	rxcntr = rxsymlen; | ||||
| 	waitsync = 1; | ||||
| 
 | ||||
| 	sprintf(throbmsg, "S/N: %3d dB", (int)(floor(s2n))); | ||||
| 	snprintf(throbmsg, sizeof(throbmsg), "S/N: %3d dB", (int)(floor(s2n))); | ||||
| 	put_Status1(throbmsg); | ||||
| 	display_metric(metric); | ||||
| 
 | ||||
|  |  | |||
|  | @ -307,7 +307,7 @@ static void macro_timer(void *) | |||
| 		btnMacroTimer->hide(); | ||||
| 		FL_UNLOCK(); | ||||
| 	} else { | ||||
| 		sprintf(timermsg,"Timer: %d", progdefaults.timeout); | ||||
| 		snprintf(timermsg, sizeof(timermsg), "Timer: %d", progdefaults.timeout); | ||||
| 		FL_LOCK(); | ||||
| 		btnMacroTimer->label(timermsg); | ||||
| 		btnMacroTimer->redraw_label(); | ||||
|  | @ -319,7 +319,7 @@ static void macro_timer(void *) | |||
| void trx_start_macro_timer() | ||||
| { | ||||
| 	Fl::add_timeout(1.0, macro_timer); | ||||
| 	sprintf(timermsg,"Timer: %d", progdefaults.timeout); | ||||
| 	snprintf(timermsg, sizeof(timermsg), "Timer: %d", progdefaults.timeout); | ||||
| 	FL_LOCK(); | ||||
| 	btnMacroTimer->label(timermsg); | ||||
| 	btnMacroTimer->redraw_label(); | ||||
|  |  | |||
|  | @ -62,7 +62,14 @@ void loadPalette() | |||
| 	if (!p) return; | ||||
| 	if ((clrfile = fopen(p, "r")) != NULL) { | ||||
| 		for (int i = 0; i < 9; i++) { | ||||
| 			fscanf(clrfile, "%d;%d;%d\n", &r, &g, &b); | ||||
| 			if (fscanf(clrfile, "%d;%d;%d\n", &r, &g, &b) == EOF) { | ||||
| 				if (ferror(clrfile)) | ||||
| 					perror("fscanf"); | ||||
| 				else | ||||
| 					cerr << p << ": unexpected EOF\n"; | ||||
| 				fclose(clrfile); | ||||
| 				return; | ||||
| 			} | ||||
| 			palette[i].R = r; | ||||
| 			palette[i].G = g; | ||||
| 			palette[i].B = b; | ||||
|  |  | |||
|  | @ -458,10 +458,10 @@ void WFdisp::sig_data( double *sig, int len ) { | |||
| 			dfreq = rfc + active_modem->get_txfreq(); | ||||
| 		else	 | ||||
| 			dfreq = rfc - active_modem->get_txfreq(); | ||||
| 		sprintf(szFrequency, "%-.3f", dfreq / 1000.0); | ||||
| 		snprintf(szFrequency, sizeof(szFrequency), "%-.3f", dfreq / 1000.0); | ||||
| 	} else { | ||||
| 		dfreq = active_modem->get_txfreq(); | ||||
| 		sprintf(szFrequency, "%-.0f", dfreq); | ||||
| 		snprintf(szFrequency, sizeof(szFrequency), "%-.0f", dfreq); | ||||
| 	} | ||||
| 	FL_LOCK_D(); | ||||
| 	inpFreq->value(szFrequency); | ||||
|  | @ -595,7 +595,7 @@ void WFdisp::drawScale() { | |||
| 			else | ||||
| 				fr = (rfc - (rfc %500))/1000.0 + 0.5 - 0.5*i; | ||||
| 		} | ||||
| 		sprintf(szFreq,"%7.1f", fr); | ||||
| 		snprintf(szFreq, sizeof(szFreq), "%7.1f", fr); | ||||
| 		fw = (int)fl_width(szFreq); | ||||
| 		if (usb) | ||||
| 			xchar = (int) ( ( (1000.0/step) * i - fw) / 2.0 -  | ||||
|  |  | |||
|  | @ -2294,7 +2294,7 @@ void Fl_Text_Display_mod::draw_line_numbers(bool /*clearAll*/) { | |||
| 	lineStart = textD->lineStarts[visLine]; | ||||
| 	if (lineStart != -1 && (lineStart==0 || | ||||
| 		BufGetCharacter(textD->buffer, lineStart-1)=='\n')) { | ||||
| 	    sprintf(lineNumString, "%*d", nCols, line); | ||||
| 	    snprintf(lineNumString, sizeof(lineNumString), "%*d", nCols, line); | ||||
| 	    XDrawImageString(XtDisplay(textD->w), XtWindow(textD->w), | ||||
| 		    textD->lineNumGC, textD->lineNumLeft, y + textD->ascent, | ||||
| 		    lineNumString, strlen(lineNumString)); | ||||
|  |  | |||
|  | @ -157,9 +157,9 @@ int anal::rx_process(const double *buf, int len) | |||
| // filter using second moving average filter & display the result
 | ||||
| 				fout_2 = favg->run(fout_1); | ||||
| 				if (wf->USB()) | ||||
| 					sprintf(msg1, "Freq: %12.2f", wf->rfcarrier() + frequency + fout_2 );  | ||||
| 					snprintf(msg1, sizeof(msg1), "Freq: %12.2f", wf->rfcarrier() + frequency + fout_2 );  | ||||
| 				else | ||||
| 					sprintf(msg1, "Freq: %12.2f", wf->rfcarrier() - frequency - fout_2 ); | ||||
| 					snprintf(msg1, sizeof(msg1), "Freq: %12.2f", wf->rfcarrier() - frequency - fout_2 ); | ||||
| 				put_status(msg1); | ||||
| 				writeFile(); | ||||
| // reset the display counter & the pipe pointer
 | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Stelios Bounanos
						Stelios Bounanos