source: roaraudio/roarclients/roarctl.c @ 1203:3cbf465d9e4e

Last change on this file since 1203:3cbf465d9e4e was 1203:3cbf465d9e4e, checked in by phi, 15 years ago

added support for stereo->quadro channel mapping

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