source: roaraudio/roarclients/roarctl.c @ 1585:6072cefe7f97

Last change on this file since 1585:6072cefe7f97 was 1585:6072cefe7f97, checked in by phi, 15 years ago

added flags: hwmixer (still meaning less, roard ignores this flag) and pause which pauses a stream

File size: 20.0 KB
Line 
1//roarctl.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008
5 *
6 *  This file is part of roarclients a part of RoarAudio,
7 *  a cross-platform sound system for both, home and professional use.
8 *  See README for details.
9 *
10 *  This file is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License version 3
12 *  as published by the Free Software Foundation.
13 *
14 *  RoarAudio is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU General Public License for more details.
18 *
19 *  You should have received a copy of the GNU General Public License
20 *  along with this software; see the file COPYING.  If not, write to
21 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25#include <roaraudio.h>
26#include <pwd.h>
27#include <grp.h>
28
29int g_verbose = 0;
30
31int display_mixer (struct roar_connection * con, int stream);
32int show_meta_all (struct roar_connection * con, int id);
33
34void usage (void) {
35 printf("roarctl [OPTIONS]... COMMAND [OPTS] [COMMAND [OPTS] [COMMAND [OPTS] [...]]]\n");
36
37 printf("\nOptions:\n\n");
38
39 printf("  --server SERVER         - Set server hostname\n"
40        "  --help                  - Show this help\n"
41        "  --verbose   -v          - Show verbose output\n"
42       );
43
44 printf("\nCommands:\n\n");
45 printf(
46        "  help                    - Show this help\n"
47        "  sleep TIME              - Sleeps for TIME seconds\n"
48        "\n"
49        "  standby, off            - Go into standby mode\n"
50        "  resume, on              - Go into active mode\n"
51        "  standbymode             - Show current standby mode\n"
52        "  exit                    - Quits the roard (must be used as last command)\n"
53        "  terminate               - Like exit but let the server up to serve still connected clients,\n"
54        "                            new clients cann't connect and the server terminates after the last\n"
55        "                            client disconnected\n"
56        "\n"
57        "  volume ID CHAN V0 V1... - Sets volume for stream ID\n"
58        "                            CHAN is the number of channels or 'mono' or 'stereo'\n"
59        "                            if mono or stereo is chosen roarctl trys to set\n"
60        "                            sensfull values for all channels even if the output\n"
61        "                            is has more channels.\n"
62        "                            all other args are the volumes of the channels\n"
63        "                            you may use integer or percent values.\n"
64        "                            percent values can flooding points.\n"
65        "\n"
66        "  flag   ID FLAGS         - Sets flags FLAGS on stream ID. FLAGS may be a comma\n"
67        "                            seperated list of flags.\n"
68        "  unflag ID FLAGS         - Unsets flags on a stream. See flag.\n"
69        "\n"
70        "  kick TYPE ID            - Kicks object of TYPE with id ID\n"
71        "                            Types: client stream sample source\n"
72        "\n"
73        "  metasave ID FILE        - Saves meta data of stream ID to file FILE\n"
74        "  metaload ID FILE        - Loads meta data from file FILE and set it on stream ID\n"
75        "\n"
76        "  serveroinfo             - Gets Informations about server output\n"
77        "  listclients             - Gets Informations about clients\n"
78        "  liststreams             - Gets Informations about streams\n"
79        "  allinfo                 - Get all infos\n"
80       );
81}
82
83void server_oinfo (struct roar_connection * con) {
84 struct roar_stream s;
85
86 if ( roar_server_oinfo(con, &s) == -1 ) {
87  fprintf(stderr, "Error: can not get server output info\n");
88  return;
89 }
90
91 printf("Stream direction      : %s\n", roar_dir2str(s.dir));
92 printf("Server Output rate    : %i\n", s.info.rate);
93 printf("Server Output bits    : %i\n", s.info.bits);
94 printf("Server Output channels: %i\n", s.info.channels);
95 printf("Server Output codec   : %i (%s%s)\n", s.info.codec, roar_codec2str(s.info.codec),
96                                     s.info.codec == ROAR_CODEC_DEFAULT ? " native" : "");
97// printf("Server Output rate: %i", s.info.rate);
98  if ( g_verbose > 1 )
99   printf("Server Position       : %lu S (%.3fs)\n", (unsigned long int) s.pos, (float)s.pos/(s.info.rate*s.info.channels));
100}
101
102const char * proc_name (pid_t pid) {
103 static char ret[80] = "?";
104#ifdef __linux__
105 char file[80], buf[80], *r;
106 int  i;
107
108 snprintf(file, 79, "/proc/%i/exe", pid);
109 file[79] = 0;
110
111 ret[0] = '?';
112 ret[1] = 0;
113
114 if ( (i = readlink(file, buf, 79)) != -1 ) {
115  buf[i] = 0;
116  if ( (r = strrchr(buf, '/')) != NULL ) {
117   r++;
118   if ( *r != 0 )
119    strcpy(ret, r);
120  }
121 }
122#endif
123
124 return ret;
125}
126
127void list_clients (struct roar_connection * con) {
128 int i;
129 int num;
130 int h;
131 int id[ROAR_CLIENTS_MAX];
132 struct roar_client c;
133 struct group  * grp = NULL;
134 struct passwd * pwd = NULL;
135
136 if ( (num = roar_list_clients(con, id, ROAR_CLIENTS_MAX)) == -1 ) {
137  fprintf(stderr, "Error: can not get client list\n");
138  return;
139 }
140
141 for (i = 0; i < num; i++) {
142  printf("client %i:\n", id[i]);
143  if ( roar_get_client(con, &c, id[i]) == -1 ) {
144   fprintf(stderr, "Error: can not get client info\n");
145   continue;
146  }
147  printf("Player name           : %s\n", c.name);
148  printf("Player PID            : %i(%s)\n", c.pid, proc_name(c.pid));
149  if ( c.uid != -1 ) {
150   pwd = getpwuid(c.uid);
151   grp = getgrgid(c.gid);
152   printf("Player UID/GID        : %i(%s)/%i(%s)\n", c.uid, pwd ? pwd->pw_name : "?", c.gid, grp ? grp->gr_name : "?");
153  }
154  if ( c.execed != -1 )
155   printf("Execed stream         : %i\n", c.execed);
156
157  for (h = 0; h < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; h++)
158   if ( c.streams[h] != -1 )
159    printf("stream                : %i\n", c.streams[h]);
160 }
161
162}
163
164void list_streams (struct roar_connection * con) {
165 int i;
166 int num;
167 int id[ROAR_STREAMS_MAX];
168 struct roar_stream s;
169 struct roar_stream_info info;
170 char flags[1024];
171
172
173 if ( (num = roar_list_streams(con, id, ROAR_STREAMS_MAX)) == -1 ) {
174  fprintf(stderr, "Error: can not get stream list\n");
175  return;
176 }
177
178 for (i = 0; i < num; i++) {
179  printf("stream %i:\n", id[i]);
180  if ( roar_get_stream(con, &s, id[i]) == -1 ) {
181   fprintf(stderr, "Error: can not get stream info\n");
182   continue;
183  }
184  printf("Stream direction      : %s\n", roar_dir2str(s.dir));
185  if ( s.pos_rel_id == -1 ) {
186   printf("Relativ position id   : none (stream not synchronized)\n");
187  } else if ( s.pos_rel_id == id[i] ) {
188   printf("Relativ position id   : %i (self synchronized)\n", s.pos_rel_id);
189  } else {
190   printf("Relativ position id   : %i (synchronized)\n", s.pos_rel_id);
191  }
192  if ( g_verbose > 1 )
193   printf("Position              : %lu S (%.3fs)\n", (unsigned long int) s.pos, (float)s.pos/(s.info.rate*s.info.channels));
194  printf("Input rate            : %i\n", s.info.rate);
195  printf("Input bits            : %i\n", s.info.bits);
196  printf("Input channels        : %i\n", s.info.channels);
197  printf("Input codec           : %2i (%s%s)\n", s.info.codec, roar_codec2str(s.info.codec),
198                                       s.info.codec == ROAR_CODEC_DEFAULT ? " native" : "");
199  if ( roar_stream_get_info(con, &s, &info) != -1 ) {
200   printf("Input codec (streamed): %2i (%s%s)\n", info.codec, roar_codec2str(info.codec),
201                                      info.codec == ROAR_CODEC_DEFAULT ? " native" : "");
202   if ( g_verbose ) {
203    printf("Input block size      : %i Byte\n", info.block_size);
204    printf("Underruns pre/post    : %i/%i\n",   info.pre_underruns, info.post_underruns);
205    if ( g_verbose > 1 )
206     printf("Stream delay          : %ims\n",   (int)info.delay/1000);
207
208    *flags = 0;
209    if ( info.flags & ROAR_FLAG_PRIMARY )
210     strcat(flags, "primary ");
211    if ( info.flags & ROAR_FLAG_SYNC )
212     strcat(flags, "sync ");
213    if ( info.flags & ROAR_FLAG_OUTPUT )
214     strcat(flags, "output ");
215    if ( info.flags & ROAR_FLAG_SOURCE )
216     strcat(flags, "source ");
217    if ( info.flags & ROAR_FLAG_META )
218     strcat(flags, "meta ");
219    if ( info.flags & ROAR_FLAG_AUTOCONF )
220     strcat(flags, "autoconf ");
221    if ( info.flags & ROAR_FLAG_CLEANMETA )
222     strcat(flags, "cleanmeta ");
223    if ( info.flags & ROAR_FLAG_HWMIXER )
224     strcat(flags, "hwmixer ");
225    if ( info.flags & ROAR_FLAG_PAUSE )
226     strcat(flags, "pause ");
227
228    printf("Flags                 : %s\n", flags);
229   }
230  }
231  display_mixer(con, id[i]);
232  show_meta_all(con, id[i]);
233 }
234
235}
236
237int display_mixer (struct roar_connection * con, int stream) {
238 int channels;
239 struct roar_mixer_settings mixer;
240 int i;
241
242 if ( roar_get_vol(con, stream, &mixer, &channels) == -1 ) {
243  fprintf(stderr, "Error: can not get stream mixer info\n");
244  return -1;
245 }
246
247 for (i = 0; i < channels; i++)
248  printf("Mixer volume chan %2i  : %i (%.2f%%)\n", i, mixer.mixer[i], (float)mixer.mixer[i]/655.35);
249
250 return 0;
251}
252
253int set_mixer (struct roar_connection * con, int * cur, int max, char * arg[]) {
254 int chans = 0;
255 int id;
256 int i;
257 int len;
258 int old_chans;
259 int vol_l, vol_r;
260 char * k;
261 struct roar_mixer_settings mixer;
262 struct roar_mixer_settings old_mixer;
263
264 if (*cur + 2 > max)
265  return -1;
266
267 id = atoi(arg[++(*cur)]);
268
269 k = arg[++(*cur)];
270
271 if ( roar_get_vol(con, id, &old_mixer, &old_chans) == -1 ) {
272  fprintf(stderr, "Error: can not get stream mixer info\n");
273  return -1;
274 }
275
276
277// TODO: clean up code here as the % vs. abs code is very duplicate...
278
279 if ( strcmp(k, "mono") == 0 && old_chans != 1 ) {
280  chans = 1;
281
282  if ( *cur + 1 > max )
283   return -1;
284
285  k   = arg[++(*cur)];
286  len = strlen(k);
287
288  if ( k[len - 1] == '%' ) {
289   k[len - 1] = 0;
290   vol_l = (atof(k)*65535)/100;
291  } else {
292   vol_l = atoi(k);
293  }
294
295  for (i = 0; i < old_chans; i++)
296   mixer.mixer[i] = vol_l;
297
298  chans = old_chans;
299
300 } else if ( strcmp(k, "stereo") == 0 && old_chans == 4 ) {
301  chans = 4;
302
303  if ( *cur + 2 > max )
304   return -1;
305
306  k   = arg[++(*cur)];
307  len = strlen(k);
308
309  if ( k[len - 1] == '%' ) {
310   k[len - 1] = 0;
311   vol_l = (atof(k)*65535)/100;
312  } else {
313   vol_l = atoi(k);
314  }
315
316  k   = arg[++(*cur)];
317  len = strlen(k);
318
319  if ( k[len - 1] == '%' ) {
320   k[len - 1] = 0;
321   vol_r = (atof(k)*65535)/100;
322  } else {
323   vol_r = atoi(k);
324  }
325
326  mixer.mixer[0] = vol_l;
327  mixer.mixer[1] = vol_r;
328  mixer.mixer[2] = vol_l;
329  mixer.mixer[3] = vol_r;
330
331 } else if ( strcmp(k, "stereo") == 0 && old_chans != 2 ) {
332  chans = 2;
333//  printf("mode: stereo; chans=%i, old_chans=%i\n", chans, old_chans);
334  ROAR_ERR("mode stereo not supported");
335  return -1;
336 } else {
337  if ( strcmp(k, "mono") == 0 ) {
338   chans = 1;
339  } else if ( strcmp(k, "stereo") == 0 ) {
340   chans = 2;
341  } else {
342   chans = atoi(k);
343  }
344
345//  printf("mode: int; chans=%i, old_chans=%i\n", chans, old_chans);
346
347  if ( *cur + chans > max )
348   return -1;
349
350  for (i = 0; i < chans; i++) {
351   k   = arg[++(*cur)];
352   len = strlen(k);
353
354   if ( k[len - 1] == '%' ) {
355    k[len - 1] = 0;
356    mixer.mixer[i] = (atof(k)*(int)65535)/100;
357   } else {
358    mixer.mixer[i] = atoi(k);
359   }
360  }
361 }
362
363 mixer.scale = 65535;
364
365 return roar_set_vol(con, id, &mixer, chans);
366}
367
368int set_meta (struct roar_connection * con, int id, char * mode, char * type, char * val) {
369 struct roar_meta   meta;
370 struct roar_stream s;
371 int mode_i = ROAR_META_MODE_SET;
372
373 memset(&s, 0, sizeof(s));
374
375 s.id = id;
376
377// printf("set_meta(*): mode='%s', type='%s', val='%s'\n", mode, type, val);
378
379 if ( strcmp(mode, "add") == 0 ) {
380  mode_i = ROAR_META_MODE_ADD;
381 }
382
383 meta.type   = roar_meta_inttype(type);
384 meta.value  = val;
385 meta.key[0] = 0;
386
387 if ( meta.type == -1 ) {
388  fprintf(stderr, "Error: unknown type: %s\n", type);
389  return -1;
390 }
391
392// printf("D: type=%i, mode=%i\n", meta.type, mode_i);
393
394 if ( roar_stream_meta_set(con, &s, mode_i, &meta) == -1 )
395  return -1;
396
397 meta.type  = ROAR_META_TYPE_NONE;
398 meta.value = NULL;
399
400 return roar_stream_meta_set(con, &s, ROAR_META_MODE_FINALIZE, &meta);
401}
402
403int load_meta (struct roar_connection * con, int id, char * file) {
404 struct roar_meta   meta;
405 struct roar_stream s;
406 int mode_i = ROAR_META_MODE_SET;
407 FILE * in;
408 char lion[1024];
409 char * v;
410
411 memset(&s, 0, sizeof(s));
412
413 s.id = id;
414
415 if ( (in = fopen(file, "r")) == NULL )
416  return -1;
417
418 while (fgets(lion, 1024, in) != NULL) {
419  if ( (v = strtok(lion, "\r\n")) != NULL )
420   if ( (v = strtok(NULL, "\r\n")) != NULL )
421    *(v-1) = 0;
422
423  if ( (v = strstr(lion, "=")) == NULL ) {
424   fprintf(stderr, "Error: can not parse meta data lion: %s\n", lion);
425   continue;
426  }
427
428  *v++ = 0;
429
430  meta.type   = roar_meta_inttype(lion);
431  meta.value  = v;
432  meta.key[0] = 0;
433
434  if ( meta.type == -1 ) {
435   fprintf(stderr, "Error: unknown type: %s\n", lion);
436   continue;
437  }
438
439  if ( roar_stream_meta_set(con, &s, mode_i, &meta) == -1 )
440   return -1;
441 }
442
443 fclose(in);
444
445 meta.type  = ROAR_META_TYPE_NONE;
446 meta.value = NULL;
447
448 return roar_stream_meta_set(con, &s, ROAR_META_MODE_FINALIZE, &meta);
449}
450
451int show_meta_type (struct roar_connection * con, int id, char * type) {
452 struct roar_meta   meta;
453 struct roar_stream s;
454
455 memset(&s, 0, sizeof(s));
456
457 s.id = id;
458
459 meta.type  = roar_meta_inttype(type);
460
461 if ( meta.type == -1 ) {
462  fprintf(stderr, "Error: unknown type: %s\n", type);
463  return -1;
464 }
465
466 if ( roar_stream_meta_get(con, &s, &meta) == -1 )
467  return -1;
468
469 printf("Meta %-17s: %s\n", roar_meta_strtype(meta.type), meta.value);
470
471 roar_meta_free(&meta);
472
473 return 0;
474}
475
476int show_meta_all (struct roar_connection * con, int id) {
477 struct roar_stream s;
478 int types[ROAR_META_MAX_PER_STREAM];
479 int i;
480 int len;
481
482 memset(&s, 0, sizeof(s));
483
484 s.id = id;
485
486 if ( (len = roar_stream_meta_list(con, &s, types, ROAR_META_MAX_PER_STREAM)) == -1 )
487  return -1;
488
489 for (i = 0; i < len; i++)
490  show_meta_type(con, id, roar_meta_strtype(types[i]));
491
492 return 0;
493}
494
495int save_meta (struct roar_connection * con, int id, char * file) {
496 struct roar_stream s;
497 struct roar_meta   meta;
498 int types[ROAR_META_MAX_PER_STREAM];
499 int i;
500 int len;
501 FILE * out;
502
503 memset(&s, 0, sizeof(s));
504
505 s.id = id;
506
507 if ( (out = fopen(file, "w")) == NULL )
508  return -1;
509
510 if ( (len = roar_stream_meta_list(con, &s, types, ROAR_META_MAX_PER_STREAM)) == -1 )
511  return -1;
512
513 for (i = 0; i < len; i++) {
514/*
515  show_meta_type(con, id, roar_meta_strtype(types[i]));
516*/
517  meta.type  = types[i];
518
519  if ( roar_stream_meta_get(con, &s, &meta) == -1 )
520   continue;
521
522//  printf("Meta %-17s: %s\n", roar_meta_strtype(meta.type), meta.value);
523
524  fprintf(out, "%s=%s\n", roar_meta_strtype(meta.type), meta.value);
525
526  roar_meta_free(&meta);
527 }
528
529 fclose(out);
530
531 return 0;
532}
533
534int set_flags (struct roar_connection * con, int id, int reset, char * flags) {
535 int f = ROAR_FLAG_NONE;
536 char * c;
537 struct roar_stream s[1];
538
539 memset(s, 0, sizeof(struct roar_stream));
540
541 s->id = id;
542
543 c = strtok(flags, ",");
544 while (c != NULL) {
545  if ( !strcmp(c, "meta") ) {
546   f |= ROAR_FLAG_META;
547  } else if ( !strcmp(c, "primary") ) {
548   f |= ROAR_FLAG_PRIMARY;
549  } else if ( !strcmp(c, "sync") ) {
550   f |= ROAR_FLAG_SYNC;
551  } else if ( !strcmp(c, "cleanmeta") ) {
552   f |= ROAR_FLAG_CLEANMETA;
553  } else if ( !strcmp(c, "hwmixer") ) {
554   f |= ROAR_FLAG_HWMIXER;
555  } else if ( !strcmp(c, "pause") ) {
556   f |= ROAR_FLAG_PAUSE;
557  } else {
558   fprintf(stderr, "Error: unknown flag: %s\n", c);
559   return -1;
560  }
561
562  c = strtok(NULL, ",");
563 }
564
565 return roar_stream_set_flags(con, s, f, reset);
566}
567
568int main (int argc, char * argv[]) {
569 struct roar_connection con;
570 char * server   = NULL;
571 char * k = NULL;
572 int    i;
573 int    t = 0;
574
575 for (i = 1; i < argc; i++) {
576  k = argv[i];
577
578  if ( strcmp(k, "--server") == 0 ) {
579   server = argv[++i];
580  } else if ( strcmp(k, "-v") == 0 || strcmp(k, "--verbose") == 0 ) {
581   g_verbose++;
582  } else if ( strcmp(k, "--help") == 0 ) {
583   usage();
584   return 0;
585  } else if ( *k == '-' ) {
586   fprintf(stderr, "Error: unknown argument: %s\n", k);
587   usage();
588   return 1;
589  } else {
590   break;
591  }
592 }
593
594 // connect
595
596 if ( roar_connect(&con, server) == -1 ) {
597  fprintf(stderr, "Error: Can not connect to server\n");
598  return 1;
599 }
600
601 if ( roar_identify(&con, "roarctl") == -1 ) {
602  fprintf(stderr, "Error: Can not identify to server\n");
603  return 1;
604 }
605
606 if ( i == argc ) {
607  fprintf(stderr, "Error: No Commands given\n");
608  return 0; // this is not a fatal error...
609 }
610
611 for (; i < argc; i++) {
612  k = argv[i];
613  // cmd is in k
614
615  printf("--- [ %s ] ---\n", k);
616
617  if ( !strcmp(k, "help") ) {
618   usage();
619
620  } else if ( !strcmp(k, "sleep") ) {
621   sleep(atoi(argv[++i]));
622
623  } else if ( !strcmp(k, "standby") || !strcmp(k, "off") ) {
624   if ( roar_set_standby(&con, ROAR_STANDBY_ACTIVE) == -1 ) {
625    fprintf(stderr, "Error: can not set mode to standby\n");
626   } else {
627    printf("going into standby\n");
628   }
629  } else if ( !strcmp(k, "resume") || !strcmp(k, "on") ) {
630   if ( roar_set_standby(&con, ROAR_STANDBY_INACTIVE) == -1 ) {
631    fprintf(stderr, "Error: can not set mode to active\n");
632   } else {
633    printf("going into active mode\n");
634   }
635
636  } else if ( !strcmp(k, "exit") ) {
637   if ( roar_exit(&con) == -1 ) {
638    fprintf(stderr, "Error: can not quit server\n");
639   } else {
640    printf("Server quited\n");
641    break;
642   }
643  } else if ( !strcmp(k, "terminate") ) {
644   if ( roar_terminate(&con, 1) == -1 ) {
645    fprintf(stderr, "Error: can not terminate server\n");
646   } else {
647    printf("Server got asked to quited\n");
648    break;
649   }
650
651  } else if ( !strcmp(k, "standbymode") ) {
652   t = roar_get_standby(&con);
653   if ( t == -1 ) {
654    fprintf(stderr, "Error: can not get stanby mode\n");
655   } else if ( t == ROAR_STANDBY_ACTIVE ) {
656    printf("Server is in standby\n");
657   } else if ( t == ROAR_STANDBY_INACTIVE ) {
658    printf("Server is active\n");
659   } else {
660    fprintf(stderr, "Error: unknown standby mode: %i\n", t);
661   }
662
663  } else if ( !strcmp(k, "whoami") ) {
664   printf("My client ID is: %i\n", roar_get_clientid(&con));
665  } else if ( !strcmp(k, "serveroinfo") ) {
666   server_oinfo(&con);
667  } else if ( !strcmp(k, "listclients") ) {
668   list_clients(&con);
669  } else if ( !strcmp(k, "liststreams") ) {
670   list_streams(&con);
671  } else if ( !strcmp(k, "allinfo") ) {
672   server_oinfo(&con);
673   printf("\n");
674   list_clients(&con);
675   printf("\n");
676   list_streams(&con);
677
678  } else if ( !strcmp(k, "kick") ) {
679   k = argv[++i];
680   if ( !strcmp(k, "client") ) {
681    t = ROAR_OT_CLIENT;
682   } else if ( !strcmp(k, "stream") ) {
683    t = ROAR_OT_STREAM;
684   } else if ( !strcmp(k, "sample") ) {
685    t = ROAR_OT_SAMPLE;
686   } else if ( !strcmp(k, "source") ) {
687    t = ROAR_OT_SOURCE;
688   } else {
689    fprintf(stderr, "Error: unknown type: %s\n", k);
690    continue;
691   }
692   //t = atoi(argv[i++]);
693   if ( roar_kick(&con, t, atoi(argv[++i])) == -1 ) {
694    fprintf(stderr, "Error: can not kick %s\n", k);
695   } else {
696    printf("%s kicked\n", k);
697   }
698
699  } else if ( !strcmp(k, "volume") ) {
700   if ( set_mixer(&con, &i, argc, argv) == -1 ) {
701    fprintf(stderr, "Error: can not set volume\n");
702   } else {
703    printf("volume changed\n");
704   }
705
706  } else if ( !strcmp(k, "flag") ) {
707   i++;
708   if ( set_flags(&con, atoi(argv[i]), ROAR_SET_FLAG, argv[i+1]) == -1 ) {
709    fprintf(stderr, "Error: can not set flags\n");
710   } else {
711    printf("flags changed\n");
712   }
713   i++;
714  } else if ( !strcmp(k, "unflag") ) {
715   i++;
716   if ( set_flags(&con, atoi(argv[i]), ROAR_RESET_FLAG, argv[i+1]) == -1 ) {
717    fprintf(stderr, "Error: can not reset flags\n");
718   } else {
719    printf("flags changed\n");
720   }
721   i++;
722  } else if ( !strcmp(k, "metaset") ) {
723   i++;
724   if ( set_meta(&con, atoi(argv[i]), argv[i+1], argv[i+2], argv[i+3]) == -1 ) {
725    fprintf(stderr, "Error: can not set meta data\n");
726   } else {
727    printf("meta data changed\n");
728   }
729   i += 3;
730  } else if ( !strcmp(k, "metaget") ) {
731   i++;
732   if ( show_meta_type(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
733    fprintf(stderr, "Error: can not get meta data\n");
734   }
735   i++;
736  } else if ( !strcmp(k, "metasave") ) {
737   i++;
738   if ( save_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
739    fprintf(stderr, "Error: can not get meta data\n");
740   } else {
741    printf("meta data saved\n");
742   }
743   i++;
744  } else if ( !strcmp(k, "metaload") ) {
745   i++;
746   if ( load_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
747    fprintf(stderr, "Error: can not set meta data\n");
748   } else {
749    printf("meta data saved\n");
750   }
751   i++;
752
753  } else {
754   fprintf(stderr, "Error: invalid command: %s\n", k);
755  }
756
757 }
758
759 roar_disconnect(&con);
760
761 return 0;
762}
763
764//ll
Note: See TracBrowser for help on using the repository browser.