Index: ChangeLog
===================================================================
--- ChangeLog	(revision 5949)
+++ ChangeLog	(revision 5950)
@@ -3,4 +3,5 @@
 	  (Closes: DEB#716264, DEB#716251, DEB#716245, DEB#716240)
 	* Marked roarcatvio as obsolete. Added all unique features to roarcatplay.
+	* Code cleanup.
 
 v. 1.0beta10 - Tue Oct 15 2013 12:03 CEST
Index: doc/man1/roarcatplay.1
===================================================================
--- doc/man1/roarcatplay.1	(revision 5949)
+++ doc/man1/roarcatplay.1	(revision 5950)
@@ -1,5 +1,5 @@
 .\" roarcatplay.1:
 
-.TH "roarcatplay" "1" "January 2010" "RoarAudio" "System User's Manual: roarcatplay"
+.TH "roarcatplay" "1" "October 2013" "RoarAudio" "System User's Manual: roarcatplay"
 
 .SH NAME
Index: doc/man1/roarcatvio.1
===================================================================
--- doc/man1/roarcatvio.1	(revision 5949)
+++ doc/man1/roarcatvio.1	(revision 5950)
@@ -1,5 +1,5 @@
 .\" roarcatvio.1:
 
-.TH "roarcatvio" "1" "January 2010" "RoarAudio" "System User's Manual: roarcatvio"
+.TH "roarcatvio" "1" "October 2013" "RoarAudio" "System User's Manual: roarcatvio"
 
 .SH NAME
Index: doc/man1/roarfilt.1
===================================================================
--- doc/man1/roarfilt.1	(revision 1625)
+++ doc/man1/roarfilt.1	(revision 5950)
@@ -1,5 +1,5 @@
 .\" roard.1:
 
-.TH "roarfilt" "1" "July 2008" "RoarAudio" "System Manager's Manual: roarfilt"
+.TH "roarfilt" "1" "October 2013" "RoarAudio" "System Manager's Manual: roarfilt"
 
 .SH NAME
@@ -59,14 +59,4 @@
 \fB--div n\fR
 Divide volume by n.
-
-.TP
-\fB--log n\fR
-Does a simple 'gamma correction'.
-This is done by:
- sample = 2^(bits-1) * log(1 + (n - 1)*sample/2^(bits-1)) / log(n).
-
-.TP
-\fB--lowpass freq\fR
-lowpass filter
 
 .SH "FILTER OPTIONS"
Index: roarclients/roarbidir.c
===================================================================
--- roarclients/roarbidir.c	(revision 5823)
+++ roarclients/roarbidir.c	(revision 5950)
@@ -69,14 +69,20 @@
 
   if ( strcmp(k, "--server") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
   } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.rate = roar_str2rate(argv[++i]);
   } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.bits = roar_str2bits(argv[++i]);
   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.channels = roar_str2channels(argv[++i]);
   } else if ( strcmp(k, "--codec") == 0 || strcmp(k, "-E") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.codec = roar_str2codec(argv[++i]);
   } else if ( !strcmp(k, "--aiprofile") ) {
+   ROAR_CKHAVEARGS(1);
    if ( roar_profile2info(&info, argv[++i]) == -1 ) {
     fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
Index: roarclients/roarcat.c
===================================================================
--- roarclients/roarcat.c	(revision 5823)
+++ roarclients/roarcat.c	(revision 5950)
@@ -82,18 +82,24 @@
 
   if ( !strcmp(k, "--server") || !strcmp(k, "-s") ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
   } else if ( !strcmp(k, "-n") ) {
+   ROAR_CKHAVEARGS(1);
    name = argv[++i];
   } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") || !strcmp(k, "-R") ) {
+   ROAR_CKHAVEARGS(1);
    info.rate = roar_str2rate(argv[++i]);
   } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) {
+   ROAR_CKHAVEARGS(1);
    info.bits = roar_str2bits(argv[++i]);
   } else if ( !strcmp(k, "-b") ) {
    info.bits = 8;
   } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") || !strcmp(k, "-C") ) {
+   ROAR_CKHAVEARGS(1);
    info.channels = roar_str2channels(argv[++i]);
   } else if ( !strcmp(k, "-m") ) {
    info.channels = 1;
   } else if ( !strcmp(k, "--codec") || !strcmp(k, "-E") ) {
+   ROAR_CKHAVEARGS(1);
    if ( (info.codec = roar_str2codec(argv[++i])) == ROAR_AUDIO_INFO_INVALID ) {
     fprintf(stderr, "Error: Unknown codec: %s\n", argv[i]);
@@ -101,4 +107,5 @@
    }
   } else if ( !strcmp(k, "--aiprofile") ) {
+   ROAR_CKHAVEARGS(1);
    if ( roar_profile2info(&info, argv[++i]) == -1 ) {
     fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
@@ -120,6 +127,8 @@
 
   } else if ( !strcmp(k, "--rel-id") ) {
+   ROAR_CKHAVEARGS(1);
    rel_id = atoi(argv[++i]);
   } else if ( !strcmp(k, "--role") ) {
+   ROAR_CKHAVEARGS(1);
    role = roar_str2role(argv[++i]);
 
Index: roarclients/roarcatplay.c
===================================================================
--- roarclients/roarcatplay.c	(revision 5949)
+++ roarclients/roarcatplay.c	(revision 5950)
@@ -64,4 +64,5 @@
 
   if ( strcmp(k, "--server") == 0 || strcmp(k, "-s") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
   } else if ( strcmp(k, "--simple") == 0 ) {
@@ -70,18 +71,25 @@
    verbose++;
   } else if ( strcmp(k, "-n") == 0 ) {
+   ROAR_CKHAVEARGS(1);
+   i++;
    roar_debug_option_obsolete(argv[0], "-n", NULL, "Will ignore it for now.");
   } else if ( !strcmp(k, "--rate") || !strcmp(k, "-R") ) {
+   ROAR_CKHAVEARGS(1);
    info.rate = roar_str2rate(argv[++i]);
    auinfo_changed = 1;
   } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) {
+   ROAR_CKHAVEARGS(1);
    info.bits = roar_str2bits(argv[++i]);
    auinfo_changed = 1;
   } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") || !strcmp(k, "-C") ) {
+   ROAR_CKHAVEARGS(1);
    info.channels = roar_str2channels(argv[++i]);
    auinfo_changed = 1;
   } else if ( !strcmp(k, "--codec") || !strcmp(k, "-E") ) {
+   ROAR_CKHAVEARGS(1);
    info.codec = roar_str2codec(argv[++i]);
    auinfo_changed = 1;
   } else if ( !strcmp(k, "--aiprofile") ) {
+   ROAR_CKHAVEARGS(1);
    if ( roar_profile2info(&info, argv[++i]) == -1 ) {
     fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
Index: roarclients/roarctl.c
===================================================================
--- roarclients/roarctl.c	(revision 5853)
+++ roarclients/roarctl.c	(revision 5950)
@@ -1212,4 +1212,5 @@
 
   if ( strcmp(k, "--server") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
   } else if ( strcmp(k, "-v") == 0 || strcmp(k, "--verbose") == 0 ) {
@@ -1262,7 +1263,9 @@
 
   } else if ( !strcmp(k, "sleep") ) {
+   ROAR_CKHAVEARGS(1);
    roar_sleep(atoi(argv[++i]));
 
   } else if ( !strcmp(k, "ping") ) {
+   ROAR_CKHAVEARGS(1);
 #ifdef ROAR_HAVE_GETTIMEOFDAY
    if ( ping(&con, atoi(argv[++i])) == -1 ) {
@@ -1342,8 +1345,10 @@
    list_clients(&con);
   } else if ( !strcmp(k, "clientinfo") ) {
+   ROAR_CKHAVEARGS(1);
    display_client(&con, atoi(argv[++i]));
   } else if ( !strcmp(k, "liststreams") ) {
    list_streams(&con);
   } else if ( !strcmp(k, "streaminfo") ) {
+   ROAR_CKHAVEARGS(1);
    display_stream(&con, atoi(argv[++i]));
   } else if ( !strcmp(k, "allinfo") ) {
@@ -1361,4 +1366,5 @@
 
   } else if ( !strcmp(k, "kick") ) {
+   ROAR_CKHAVEARGS(2);
    t = roar_str2ot((k = argv[++i]));
    if ( t == -1 ) {
@@ -1374,4 +1380,5 @@
 
   } else if ( !strcmp(k, "newvirtual") ) {
+   ROAR_CKHAVEARGS(6);
    if ( newvirtual(&con, argv[i+1], argv[i+2], argv[i+3], argv[i+4], argv[i+5], argv[i+6]) == -1 ) {
     fprintf(stderr, "Error: can not create new virtual stream\n");
@@ -1382,4 +1389,5 @@
 
   } else if ( !strcmp(k, "volume") ) {
+   ROAR_CKHAVEARGS(2); /* we may need more, but this is the minimum */
    if ( set_mixer(&con, &i, argc, argv) == -1 ) {
     fprintf(stderr, "Error: can not set volume\n");
@@ -1389,4 +1397,5 @@
 
   } else if ( !strcmp(k, "flag") ) {
+   ROAR_CKHAVEARGS(2);
    i++;
    if ( set_flags(&con, atoi(argv[i]), ROAR_SET_FLAG, argv[i+1]) == -1 ) {
@@ -1397,4 +1406,5 @@
    i++;
   } else if ( !strcmp(k, "unflag") ) {
+   ROAR_CKHAVEARGS(2);
    i++;
    if ( set_flags(&con, atoi(argv[i]), ROAR_RESET_FLAG, argv[i+1]) == -1 ) {
@@ -1405,4 +1415,5 @@
    i++;
   } else if ( !strcmp(k, "toggleflag") ) {
+   ROAR_CKHAVEARGS(2);
    i++;
    if ( set_flags(&con, atoi(argv[i]), ROAR_TOGGLE_FLAG, argv[i+1]) == -1 ) {
@@ -1413,4 +1424,5 @@
    i++;
   } else if ( !strcmp(k, "protectflag") ) {
+   ROAR_CKHAVEARGS(2);
    i++;
    if ( set_flags(&con, atoi(argv[i]), ROAR_NOOP_FLAG|ROAR_PROTECT_FLAG, argv[i+1]) == -1 ) {
@@ -1422,4 +1434,5 @@
 
   } else if ( !strcmp(k, "role") ) {
+   ROAR_CKHAVEARGS(2);
    i++;
    if ( set_role(&con, atoi(argv[i]), roar_str2role(argv[i+1])) == -1 ) {
@@ -1431,4 +1444,5 @@
 
   } else if ( !strcmp(k, "metaset") ) {
+   ROAR_CKHAVEARGS(4);
    i++;
    if ( set_meta(&con, atoi(argv[i]), argv[i+1], argv[i+2], argv[i+3]) == -1 ) {
@@ -1439,4 +1453,5 @@
    i += 3;
   } else if ( !strcmp(k, "metaget") ) {
+   ROAR_CKHAVEARGS(2);
    i++;
    if ( show_meta_type(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
@@ -1445,4 +1460,5 @@
    i++;
   } else if ( !strcmp(k, "metasave") ) {
+   ROAR_CKHAVEARGS(2);
    i++;
    if ( save_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
@@ -1453,4 +1469,5 @@
    i++;
   } else if ( !strcmp(k, "metaload") ) {
+   ROAR_CKHAVEARGS(2);
    i++;
    if ( load_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
@@ -1467,4 +1484,5 @@
    }
   } else if ( !strcmp(k, "aiprofileget") || !strcmp(k, "profileget") ) {
+   ROAR_CKHAVEARGS(1);
    i++;
    if ( show_aiprofile(argv[i]) == -1 ) {
Index: roarclients/roarfilt.c
===================================================================
--- roarclients/roarfilt.c	(revision 5823)
+++ roarclients/roarfilt.c	(revision 5950)
@@ -32,11 +32,4 @@
 
 #define BUFFERSIZE 1024
-
-#ifdef ROAR_HAVE_LIBM
-struct {
- uint16_t a, b;
- int16_t  old[ROAR_MAX_CHANNELS];
-} g_lowpass;
-#endif
 
 void usage (void) {
@@ -57,7 +50,4 @@
         "  --mul VAL           - Set mul\n"
         "  --div VAL           - Set div\n"
-#ifdef ROAR_HAVE_LIBM
-        "  --lowpass freq      - lowpass filter (obsolete)\n"
-#endif
         "  --filter  name      - add filter name\n"
         "  --ffreq   freq      - set filter freq\n"
@@ -87,53 +77,4 @@
 _volX(32,64,4)
 
-#ifdef ROAR_HAVE_LIBM
-void logs2 (void * data, float scale, int len) {
- int16_t * samples = (int16_t *) data;
- int i;
- float div = logf(scale);
- float scalemul = scale - 1;
- int neg;
-
- len /= 2;
-
- //printf("logs2(data=%p, scale=%f, len=%i): scalemul=%f, div=%f\n", data, scale, len, scalemul, div);
-
- for (i = 0; i < len; i++) {
-  if ( (neg = (samples[i] < 0)) ) 
-   samples[i] = abs(samples[i]);
-
-
-  samples[i] = (neg ? 32768.0 : 32767.0)*logf(1 + (scalemul*(float)samples[i]/(neg ? 32768.0 : 32767.0))) / div;
-
-  if ( neg )
-   samples[i] *= -1;
- }
-}
-
-void lowpass2 (void * data, int len, int channels) {
- int16_t * samples = (int16_t *) data;
- register int32_t s;
- int i, c;
-
- if ( channels > ROAR_MAX_CHANNELS )
-  return;
-
- len /= 2 * channels;
-
-//  *      output[N] = input[N] * A + output[N-1] * B
-
- for (i = 0; i < len; i++) {
-  for (c = 0; c < channels; c++) {
-   s = samples[i*channels + c] * g_lowpass.a + g_lowpass.old[c] * g_lowpass.b;
-
-   s /= 65536;
-
-   samples[i*channels + c] = s;
-   g_lowpass.old[       c] = s;
-  }
- }
-}
-#endif
-
 int main (int argc, char * argv[]) {
  struct roar_audio_info info;
@@ -144,6 +85,5 @@
  int     filter_id;
  int32_t tmp;
- float   logscale = 0;
- float   lp       = 0;
+ float   tmpfp;
  char    buf[BUFFERSIZE];
  struct roardsp_filterchain fc;
@@ -156,8 +96,4 @@
  info.codec = ROAR_CODEC_DEFAULT;
 
-#ifdef ROAR_HAVE_LIBM
- memset(&g_lowpass, 0, sizeof(g_lowpass));
-#endif
-
  roardsp_fchain_init(&fc);
 
@@ -166,10 +102,14 @@
 
   if ( strcmp(k, "--server") == 0 || strcmp(k, "-s") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
   } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 || strcmp(k, "-r") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.rate = roar_str2rate(argv[++i]);
   } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.bits = roar_str2bits(argv[++i]);
   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.channels = roar_str2channels(argv[++i]);
   } else if ( strcmp(k, "-b") == 0 ) {
@@ -178,4 +118,5 @@
    info.channels = 1;
   } else if ( !strcmp(k, "--aiprofile") ) {
+   ROAR_CKHAVEARGS(1);
    if ( roar_profile2info(&info, argv[++i]) == -1 ) {
     fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
@@ -188,21 +129,14 @@
    mul *= 2;
   } else if ( strcmp(k, "--amp") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    mul *= atoi(argv[++i]);
   } else if ( strcmp(k, "--mul") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    mul  = atoi(argv[++i]);
   } else if ( strcmp(k, "--div") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    div  = atoi(argv[++i]);
-  } else if ( strcmp(k, "--log") == 0 ) {
-   ROAR_WARN("The logscaler is obsolete and will be removed soon.");
-   logscale = atof(argv[++i]);
-#ifdef ROAR_HAVE_LIBM
-  } else if ( strcmp(k, "--lowpass") == 0 ) {
-   ROAR_WARN("The builtin lowpass is obsolete and will be removed soon. Use --filter lowpass.");
-   lp = exp(-2 * M_PI * atof(argv[++i]) / info.rate) * 65536;
-   g_lowpass.b = lp;
-   g_lowpass.a = 65536 - lp;
-#endif
-//   printf("lowpass: A=%i, B=%i\n", g_lowpass.a, g_lowpass.b);
   } else if ( strcmp(k, "--filter") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    stream.info = info;
    filter_id = roardsp_filter_str2id(argv[++i]);
@@ -219,22 +153,29 @@
    }
   } else if ( strcmp(k, "--ffreq") == 0 ) {
-   lp = atof(argv[++i]);
-   roardsp_filter_ctl(filter, ROARDSP_FCTL_FREQ, &lp);
+   ROAR_CKHAVEARGS(1);
+   tmpfp = atof(argv[++i]);
+   roardsp_filter_ctl(filter, ROARDSP_FCTL_FREQ, &tmpfp);
   } else if ( strcmp(k, "--fmul") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    tmp = atoi(argv[++i]);
    roardsp_filter_ctl(filter, ROARDSP_FCTL_MUL, &tmp);
   } else if ( strcmp(k, "--fdiv") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    tmp = atoi(argv[++i]);
    roardsp_filter_ctl(filter, ROARDSP_FCTL_DIV, &tmp);
   } else if ( strcmp(k, "--fn") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    tmp = atoi(argv[++i]);
    roardsp_filter_ctl(filter, ROARDSP_FCTL_N, &tmp);
   } else if ( strcmp(k, "--fq") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    tmp = atoi(argv[++i]);
    roardsp_filter_ctl(filter, ROARDSP_FCTL_Q, &tmp);
   } else if ( strcmp(k, "--flimit") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    tmp = atoi(argv[++i]);
    roardsp_filter_ctl(filter, ROARDSP_FCTL_LIMIT, &tmp);
   } else if ( strcmp(k, "--fmode") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    tmp = atoi(argv[++i]);
    roardsp_filter_ctl(filter, ROARDSP_FCTL_MODE, &tmp);
@@ -257,7 +198,4 @@
 
  if ( mul == div &&
-#ifdef ROAR_HAVE_LIBM
-      logscale == 0 && g_lowpass.a == 0 &&
-#endif
       roardsp_fchain_num(&fc) == 0 ) {
   fprintf(stderr, "Error: filter is useless!\n");
@@ -278,10 +216,4 @@
      if ( mul != div )
       vol16((void*)buf, mul, div, i);
-#ifdef ROAR_HAVE_LIBM
-     if ( logscale )
-      logs2((void*)buf, logscale, i);
-     if ( g_lowpass.a )
-      lowpass2((void*)buf, i, info.channels);
-#endif
      roardsp_fchain_calc(&fc, (void*)buf, (8*i)/info.bits);
      if (roar_vio_write(&svio, buf, i) != i)
Index: roarclients/roarmon.c
===================================================================
--- roarclients/roarmon.c	(revision 5823)
+++ roarclients/roarmon.c	(revision 5950)
@@ -84,16 +84,21 @@
 
   if ( !strcmp(k, "--server") || !strcmp(k, "-s") ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
   } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") || !strcmp(k, "-R") ) {
+   ROAR_CKHAVEARGS(1);
    info.rate = roar_str2rate(argv[++i]);
   } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) {
+   ROAR_CKHAVEARGS(1);
    info.bits = roar_str2bits(argv[++i]);
   } else if ( !strcmp(k, "-b") ) {
    info.bits = 8;
   } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") || !strcmp(k, "-C") ) {
+   ROAR_CKHAVEARGS(1);
    info.channels = roar_str2channels(argv[++i]);
   } else if ( !strcmp(k, "-m") ) {
    info.channels = 1;
   } else if ( !strcmp(k, "--codec") || !strcmp(k, "-E") ) {
+   ROAR_CKHAVEARGS(1);
    if ( (info.codec = roar_str2codec(argv[++i])) == ROAR_AUDIO_INFO_INVALID ) {
     fprintf(stderr, "Error: Unknown codec: %s\n", argv[i]);
@@ -102,4 +107,5 @@
 
   } else if ( !strcmp(k, "--aiprofile") ) {
+   ROAR_CKHAVEARGS(1);
    if ( roar_profile2info(&info, argv[++i]) == -1 ) {
     fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
@@ -124,4 +130,5 @@
    dir   = ROAR_DIR_THRU;
   } else if ( !strcmp(k, "--rel-id") ) {
+   ROAR_CKHAVEARGS(1);
    rel_id = atoi(argv[++i]);
 
Index: roarclients/roarmonhttp.c
===================================================================
--- roarclients/roarmonhttp.c	(revision 5823)
+++ roarclients/roarmonhttp.c	(revision 5950)
@@ -268,14 +268,20 @@
 #endif
   } else if ( !strcmp(k, "--server") ) {
+   ROAR_CKHAVEARGS(1);
    roar_libroar_set_server(argv[++i]);
   } else if ( !strcmp(k, "--codec") || !strcmp(k, "-E") ) {
+   ROAR_CKHAVEARGS(1);
    info.codec = roar_str2codec(argv[++i]);
   } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") || !strcmp(k, "-R") ) {
+   ROAR_CKHAVEARGS(1);
    info.rate = roar_str2rate(argv[++i]);
   } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) {
+   ROAR_CKHAVEARGS(1);
    info.bits = roar_str2bits(argv[++i]);
   } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") || !strcmp(k, "-C") ) {
+   ROAR_CKHAVEARGS(1);
    info.channels = roar_str2channels(argv[++i]);
   } else if ( !strcmp(k, "--aiprofile") ) {
+   ROAR_CKHAVEARGS(1);
    if ( roar_profile2info(&info, argv[++i]) == -1 ) {
     fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
@@ -283,4 +289,5 @@
    }
   } else if ( !strcmp(k, "--rel-id") ) {
+   ROAR_CKHAVEARGS(1);
    rel_id = atoi(argv[++i]);
   } else if ( !strcmp(k, "--help") && !strcmp(k, "-h") ) {
Index: roarclients/roarphone.c
===================================================================
--- roarclients/roarphone.c	(revision 5823)
+++ roarclients/roarphone.c	(revision 5950)
@@ -432,16 +432,23 @@
 
   if ( strcmp(k, "--server") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
   } else if ( strcmp(k, "--jumbo-mtu") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    g_conf.jumbo_mtu = atoi(argv[++i]);
   } else if ( strcmp(k, "--io-flush") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    g_conf.ioflush_interval = atoi(argv[++i]);
   } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.rate = roar_str2rate(argv[++i]);
   } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.bits = roar_str2bits(argv[++i]);
   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.channels = roar_str2channels(argv[++i]);
   } else if ( !strcmp(k, "--aiprofile") ) {
+   ROAR_CKHAVEARGS(1);
    if ( roar_profile2info(&info, argv[++i]) == -1 ) {
     fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
@@ -466,11 +473,15 @@
 
   } else if ( strcmp(k, "--codec") == 0 || strcmp(k, "-E") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.codec = roar_str2codec(argv[++i]);
 
   } else if ( strcmp(k, "--driver") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    driver = argv[++i];
   } else if ( strcmp(k, "--device") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    device = argv[++i];
   } else if ( strcmp(k, "--antiecho") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    k = argv[++i];
    if ( !strcmp(k, "none") ) {
@@ -487,4 +498,5 @@
    }
   } else if ( strcmp(k, "--threshold") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    g_conf.dtx_threshold = atol(argv[++i]);
 
@@ -497,16 +509,23 @@
   // META DATA:
   } else if ( strcmp(k, "--m-rn") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    g_meta.rn = argv[++i];
   } else if ( strcmp(k, "--m-nick") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    g_meta.nick = argv[++i];
   } else if ( strcmp(k, "--m-email") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    g_meta.email = argv[++i];
   } else if ( strcmp(k, "--m-hp") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    g_meta.hp = argv[++i];
   } else if ( strcmp(k, "--m-thumbn") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    g_meta.thumbnail = argv[++i];
   } else if ( strcmp(k, "--m-loc") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    g_meta.loc = argv[++i];
   } else if ( strcmp(k, "--m-org") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    g_meta.org = argv[++i];
 
Index: roarclients/roarpluginrunner.c
===================================================================
--- roarclients/roarpluginrunner.c	(revision 5876)
+++ roarclients/roarpluginrunner.c	(revision 5950)
@@ -623,4 +623,5 @@
    g_verbose++;
   } else if ( !strcmp(k, "--server") ) {
+   ROAR_CKHAVEARGS(1);
    roar_libroar_set_server(argv[++i]);
 
@@ -635,10 +636,13 @@
    cpi_touched++;
   } else if ( !strcmp(k, "--port") ) {
+   ROAR_CKHAVEARGS(1);
    cpi_port = atoi(argv[++i]);
    cpi_touched++;
   } else if ( !strcmp(k, "--bind") ) {
+   ROAR_CKHAVEARGS(1);
    cpi_host = argv[++i];
    cpi_touched++;
   } else if ( !strcmp(k, "--proto") ) {
+   ROAR_CKHAVEARGS(1);
    cpi_proto = roar_str2proto(argv[++i]);
    if ( cpi_proto == -1 ) {
@@ -653,4 +657,5 @@
    cpi_touched = 0;
   } else if ( !strcmp(k, "--client-fh") ) {
+   ROAR_CKHAVEARGS(1);
    if ( add_cpi_client(cpi_proto, atoi(argv[++i])) == -1 ) {
     fprintf(stderr, "Can not add CPI client: %s\n", roar_error2str(roar_error));
@@ -671,10 +676,13 @@
 
   } else if ( !strcmp(k, "--appname") ) {
+   ROAR_CKHAVEARGS(1);
    appname = argv[++i];
    _clear_para();
   } else if ( !strcmp(k, "--abiversion") ) {
+   ROAR_CKHAVEARGS(1);
    abiversion = argv[++i];
    _clear_para();
   } else if ( !strcmp(k, "--args") ) {
+   ROAR_CKHAVEARGS(1);
    pluginargs = argv[++i];
    _clear_para();
Index: roarclients/roarradio.c
===================================================================
--- roarclients/roarradio.c	(revision 5823)
+++ roarclients/roarradio.c	(revision 5950)
@@ -76,14 +76,20 @@
 
   if ( strcmp(k, "--server") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
   } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.rate = roar_str2rate(argv[++i]);
   } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.bits = roar_str2bits(argv[++i]);
   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.channels = roar_str2channels(argv[++i]);
   } else if ( strcmp(k, "--codec") == 0 || strcmp(k, "-E") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.codec = roar_str2codec(argv[++i]);
   } else if ( !strcmp(k, "--aiprofile") ) {
+   ROAR_CKHAVEARGS(1);
    if ( roar_profile2info(&info, argv[++i]) == -1 ) {
     fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
Index: roarclients/roarshout.c
===================================================================
--- roarclients/roarshout.c	(revision 5823)
+++ roarclients/roarshout.c	(revision 5950)
@@ -121,14 +121,20 @@
 
   if ( strcmp(k, "--server") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
   } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.rate = roar_str2rate(argv[++i]);
   } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.bits = roar_str2bits(argv[++i]);
   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.channels = roar_str2channels(argv[++i]);
   } else if ( strcmp(k, "--codec") == 0 || strcmp(k, "-E") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.codec = roar_str2codec(argv[++i]);
   } else if ( !strcmp(k, "--aiprofile") ) {
+   ROAR_CKHAVEARGS(1);
    if ( roar_profile2info(&info, argv[++i]) == -1 ) {
     fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
@@ -144,10 +150,14 @@
    s_public = 1;
   } else if ( strcmp(k, "-d") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    s_desc   = argv[++i];
   } else if ( strcmp(k, "-g") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    s_genre  = argv[++i];
   } else if ( strcmp(k, "-n") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    s_name   = argv[++i];
   } else if ( strcmp(k, "-u") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    s_url    = argv[++i];
   } else if ( strcmp(k, "-h") == 0 || strcmp(k, "--help") == 0 ) {
@@ -155,10 +165,14 @@
    return 0;
   } else if ( s_server == NULL ) {
+   ROAR_CKHAVEARGS(1);
    s_server = k;
   } else if ( s_port   == -1 ) {
+   ROAR_CKHAVEARGS(1);
    s_port   = atoi(k);
   } else if ( s_pw     == NULL ) {
+   ROAR_CKHAVEARGS(1);
    s_pw     = argv[i]; // do not use k here so k can be const.
   } else if ( s_mount  == NULL ) {
+   ROAR_CKHAVEARGS(1);
    s_mount  = k;
   } else {
Index: roarclients/roarsin.c
===================================================================
--- roarclients/roarsin.c	(revision 5823)
+++ roarclients/roarsin.c	(revision 5950)
@@ -97,4 +97,5 @@
 
 int main (int argc, char * argv[]) {
+ const char * k;
  const char * server = NULL;
  int rate     = ROAR_RATE_DEFAULT;
@@ -112,25 +113,31 @@
 
  for (i = 1; i < argc; i++) {
-  if ( !strcmp(argv[i], "--freq") ) {
+  k = argv[i];
+  if ( !strcmp(k, "--freq") ) {
+   ROAR_CKHAVEARGS(1);
    freq   = atof(argv[++i]);
-  } else if ( !strcmp(argv[i], "--time") ) {
+  } else if ( !strcmp(k, "--time") ) {
+   ROAR_CKHAVEARGS(1);
    length = atof(argv[++i]);
-  } else if ( !strcmp(argv[i], "--server") ) {
+  } else if ( !strcmp(k, "--server") ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
-  } else if ( !strcmp(argv[i], "--rate") || !strcmp(argv[i], "-R") ) {
+  } else if ( !strcmp(k, "--rate") || !strcmp(k, "-R") ) {
+   ROAR_CKHAVEARGS(1);
    rate = roar_str2rate(argv[++i]);
-  } else if ( !strcmp(argv[i], "--volume") ) {
+  } else if ( !strcmp(k, "--volume") ) {
+   ROAR_CKHAVEARGS(1);
    volume = atof(argv[++i]);
-  } else if ( !strcmp(argv[i], "--sin") ) {
+  } else if ( !strcmp(k, "--sin") ) {
    func   = sin;
-  } else if ( !strcmp(argv[i], "--rect") ) {
+  } else if ( !strcmp(k, "--rect") ) {
    func   = rect;
-  } else if ( !strcmp(argv[i], "--saw") ) {
+  } else if ( !strcmp(k, "--saw") ) {
    func   = saw;
-  } else if ( !strcmp(argv[i], "--tri") ) {
+  } else if ( !strcmp(k, "--tri") ) {
    func   = tri;
-  } else if ( !strcmp(argv[i], "--trap") ) {
+  } else if ( !strcmp(k, "--trap") ) {
    func   = trap;
-  } else if ( !strcmp(argv[i], "--help") ) {
+  } else if ( !strcmp(k, "--help") ) {
    usage(argv[0]);
    return 0;
Index: roarclients/roarvorbis.c
===================================================================
--- roarclients/roarvorbis.c	(revision 5823)
+++ roarclients/roarvorbis.c	(revision 5950)
@@ -309,6 +309,8 @@
 
   if ( strcmp(k, "--server") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    roar_libroar_set_server(argv[++i]);
   } else if ( strcmp(k, "--vclt-out") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    vcltfile = argv[++i];
   } else if ( strcmp(k, "--help") == 0 ) {
Index: roarclients/roarvumeter.c
===================================================================
--- roarclients/roarvumeter.c	(revision 5823)
+++ roarclients/roarvumeter.c	(revision 5950)
@@ -179,12 +179,17 @@
 
   if ( strcmp(k, "--server") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    server = argv[++i];
   } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.rate = roar_str2rate(argv[++i]);
   } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.bits = roar_str2bits(argv[++i]);
   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    info.channels = roar_str2channels(argv[++i]);
   } else if ( !strcmp(k, "--aiprofile") ) {
+   ROAR_CKHAVEARGS(1);
    if ( roar_profile2info(&info, argv[++i]) == -1 ) {
     fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error));
@@ -192,4 +197,5 @@
    }
   } else if ( strcmp(k, "--samples") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    samples = atoi(argv[++i]);
   } else if ( strcmp(k, "--db") == 0 ) {
@@ -204,4 +210,5 @@
    mode |= MODE_BEAT;
   } else if ( strcmp(k, "--lowpass") == 0 ) {
+   ROAR_CKHAVEARGS(1);
    lowpass_freq = atof(argv[++i]);
   } else if ( strcmp(k, "--help") == 0 ) {
