source: roaraudio/roarclients/roarctl.c @ 1204:73c1941b1c93

Last change on this file since 1204:73c1941b1c93 was 1204:73c1941b1c93, checked in by phi, 15 years ago

updated docs to represent current roarctl.

File size: 19.5 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[80];
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
220    printf("Flags                 : %s\n", flags);
221   }
222  }
223  display_mixer(con, id[i]);
224  show_meta_all(con, id[i]);
225 }
226
227}
228
229int display_mixer (struct roar_connection * con, int stream) {
230 int channels;
231 struct roar_mixer_settings mixer;
232 int i;
233
234 if ( roar_get_vol(con, stream, &mixer, &channels) == -1 ) {
235  fprintf(stderr, "Error: can not get stream mixer info\n");
236  return -1;
237 }
238
239 for (i = 0; i < channels; i++)
240  printf("Mixer volume chan %2i  : %i (%.2f%%)\n", i, mixer.mixer[i], (float)mixer.mixer[i]/655.35);
241
242 return 0;
243}
244
245int set_mixer (struct roar_connection * con, int * cur, int max, char * arg[]) {
246 int chans = 0;
247 int id;
248 int i;
249 int len;
250 int old_chans;
251 int vol_l, vol_r;
252 char * k;
253 struct roar_mixer_settings mixer;
254 struct roar_mixer_settings old_mixer;
255
256 if (*cur + 2 > max)
257  return -1;
258
259 id = atoi(arg[++(*cur)]);
260
261 k = arg[++(*cur)];
262
263 if ( roar_get_vol(con, id, &old_mixer, &old_chans) == -1 ) {
264  fprintf(stderr, "Error: can not get stream mixer info\n");
265  return -1;
266 }
267
268
269// TODO: clean up code here as the % vs. abs code is very duplicate...
270
271 if ( strcmp(k, "mono") == 0 && old_chans != 1 ) {
272  chans = 1;
273
274  if ( *cur + 1 > max )
275   return -1;
276
277  k   = arg[++(*cur)];
278  len = strlen(k);
279
280  if ( k[len - 1] == '%' ) {
281   k[len - 1] = 0;
282   vol_l = (atof(k)*65535)/100;
283  } else {
284   vol_l = atoi(k);
285  }
286
287  for (i = 0; i < old_chans; i++)
288   mixer.mixer[i] = vol_l;
289
290  chans = old_chans;
291
292 } else if ( strcmp(k, "stereo") == 0 && old_chans == 4 ) {
293  chans = 4;
294
295  if ( *cur + 2 > max )
296   return -1;
297
298  k   = arg[++(*cur)];
299  len = strlen(k);
300
301  if ( k[len - 1] == '%' ) {
302   k[len - 1] = 0;
303   vol_l = (atof(k)*65535)/100;
304  } else {
305   vol_l = atoi(k);
306  }
307
308  k   = arg[++(*cur)];
309  len = strlen(k);
310
311  if ( k[len - 1] == '%' ) {
312   k[len - 1] = 0;
313   vol_r = (atof(k)*65535)/100;
314  } else {
315   vol_r = atoi(k);
316  }
317
318  mixer.mixer[0] = vol_l;
319  mixer.mixer[1] = vol_r;
320  mixer.mixer[2] = vol_l;
321  mixer.mixer[3] = vol_r;
322
323 } else if ( strcmp(k, "stereo") == 0 && old_chans != 2 ) {
324  chans = 2;
325//  printf("mode: stereo; chans=%i, old_chans=%i\n", chans, old_chans);
326  ROAR_ERR("mode stereo not supported");
327  return -1;
328 } else {
329  if ( strcmp(k, "mono") == 0 ) {
330   chans = 1;
331  } else if ( strcmp(k, "stereo") == 0 ) {
332   chans = 2;
333  } else {
334   chans = atoi(k);
335  }
336
337//  printf("mode: int; chans=%i, old_chans=%i\n", chans, old_chans);
338
339  if ( *cur + chans > max )
340   return -1;
341
342  for (i = 0; i < chans; i++) {
343   k   = arg[++(*cur)];
344   len = strlen(k);
345
346   if ( k[len - 1] == '%' ) {
347    k[len - 1] = 0;
348    mixer.mixer[i] = (atof(k)*(int)65535)/100;
349   } else {
350    mixer.mixer[i] = atoi(k);
351   }
352  }
353 }
354
355 mixer.scale = 65535;
356
357 return roar_set_vol(con, id, &mixer, chans);
358}
359
360int set_meta (struct roar_connection * con, int id, char * mode, char * type, char * val) {
361 struct roar_meta   meta;
362 struct roar_stream s;
363 int mode_i = ROAR_META_MODE_SET;
364
365 memset(&s, 0, sizeof(s));
366
367 s.id = id;
368
369// printf("set_meta(*): mode='%s', type='%s', val='%s'\n", mode, type, val);
370
371 if ( strcmp(mode, "add") == 0 ) {
372  mode_i = ROAR_META_MODE_ADD;
373 }
374
375 meta.type   = roar_meta_inttype(type);
376 meta.value  = val;
377 meta.key[0] = 0;
378
379 if ( meta.type == -1 ) {
380  fprintf(stderr, "Error: unknown type: %s\n", type);
381  return -1;
382 }
383
384// printf("D: type=%i, mode=%i\n", meta.type, mode_i);
385
386 if ( roar_stream_meta_set(con, &s, mode_i, &meta) == -1 )
387  return -1;
388
389 meta.type  = ROAR_META_TYPE_NONE;
390 meta.value = NULL;
391
392 return roar_stream_meta_set(con, &s, ROAR_META_MODE_FINALIZE, &meta);
393}
394
395int load_meta (struct roar_connection * con, int id, char * file) {
396 struct roar_meta   meta;
397 struct roar_stream s;
398 int mode_i = ROAR_META_MODE_SET;
399 FILE * in;
400 char lion[1024];
401 char * v;
402
403 memset(&s, 0, sizeof(s));
404
405 s.id = id;
406
407 if ( (in = fopen(file, "r")) == NULL )
408  return -1;
409
410 while (fgets(lion, 1024, in) != NULL) {
411  if ( (v = strtok(lion, "\r\n")) != NULL )
412   if ( (v = strtok(NULL, "\r\n")) != NULL )
413    *(v-1) = 0;
414
415  if ( (v = strstr(lion, "=")) == NULL ) {
416   fprintf(stderr, "Error: can not parse meta data lion: %s\n", lion);
417   continue;
418  }
419
420  *v++ = 0;
421
422  meta.type   = roar_meta_inttype(lion);
423  meta.value  = v;
424  meta.key[0] = 0;
425
426  if ( meta.type == -1 ) {
427   fprintf(stderr, "Error: unknown type: %s\n", lion);
428   continue;
429  }
430
431  if ( roar_stream_meta_set(con, &s, mode_i, &meta) == -1 )
432   return -1;
433 }
434
435 fclose(in);
436
437 meta.type  = ROAR_META_TYPE_NONE;
438 meta.value = NULL;
439
440 return roar_stream_meta_set(con, &s, ROAR_META_MODE_FINALIZE, &meta);
441}
442
443int show_meta_type (struct roar_connection * con, int id, char * type) {
444 struct roar_meta   meta;
445 struct roar_stream s;
446
447 memset(&s, 0, sizeof(s));
448
449 s.id = id;
450
451 meta.type  = roar_meta_inttype(type);
452
453 if ( meta.type == -1 ) {
454  fprintf(stderr, "Error: unknown type: %s\n", type);
455  return -1;
456 }
457
458 if ( roar_stream_meta_get(con, &s, &meta) == -1 )
459  return -1;
460
461 printf("Meta %-17s: %s\n", roar_meta_strtype(meta.type), meta.value);
462
463 roar_meta_free(&meta);
464
465 return 0;
466}
467
468int show_meta_all (struct roar_connection * con, int id) {
469 struct roar_stream s;
470 int types[ROAR_META_MAX_PER_STREAM];
471 int i;
472 int len;
473
474 memset(&s, 0, sizeof(s));
475
476 s.id = id;
477
478 if ( (len = roar_stream_meta_list(con, &s, types, ROAR_META_MAX_PER_STREAM)) == -1 )
479  return -1;
480
481 for (i = 0; i < len; i++)
482  show_meta_type(con, id, roar_meta_strtype(types[i]));
483
484 return 0;
485}
486
487int save_meta (struct roar_connection * con, int id, char * file) {
488 struct roar_stream s;
489 struct roar_meta   meta;
490 int types[ROAR_META_MAX_PER_STREAM];
491 int i;
492 int len;
493 FILE * out;
494
495 memset(&s, 0, sizeof(s));
496
497 s.id = id;
498
499 if ( (out = fopen(file, "w")) == NULL )
500  return -1;
501
502 if ( (len = roar_stream_meta_list(con, &s, types, ROAR_META_MAX_PER_STREAM)) == -1 )
503  return -1;
504
505 for (i = 0; i < len; i++) {
506/*
507  show_meta_type(con, id, roar_meta_strtype(types[i]));
508*/
509  meta.type  = types[i];
510
511  if ( roar_stream_meta_get(con, &s, &meta) == -1 )
512   continue;
513
514//  printf("Meta %-17s: %s\n", roar_meta_strtype(meta.type), meta.value);
515
516  fprintf(out, "%s=%s\n", roar_meta_strtype(meta.type), meta.value);
517
518  roar_meta_free(&meta);
519 }
520
521 fclose(out);
522
523 return 0;
524}
525
526int set_flags (struct roar_connection * con, int id, int reset, char * flags) {
527 int f = ROAR_FLAG_NONE;
528 char * c;
529 struct roar_stream s[1];
530
531 memset(s, 0, sizeof(struct roar_stream));
532
533 s->id = id;
534
535 c = strtok(flags, ",");
536 while (c != NULL) {
537  if ( !strcmp(c, "meta") ) {
538   f |= ROAR_FLAG_META;
539  } else if ( !strcmp(c, "primary") ) {
540   f |= ROAR_FLAG_PRIMARY;
541  } else if ( !strcmp(c, "sync") ) {
542   f |= ROAR_FLAG_SYNC;
543  } else {
544   fprintf(stderr, "Error: unknown flag: %s\n", c);
545   return -1;
546  }
547
548  c = strtok(NULL, ",");
549 }
550
551 return roar_stream_set_flags(con, s, f, reset);
552}
553
554int main (int argc, char * argv[]) {
555 struct roar_connection con;
556 char * server   = NULL;
557 char * k = NULL;
558 int    i;
559 int    t = 0;
560
561 for (i = 1; i < argc; i++) {
562  k = argv[i];
563
564  if ( strcmp(k, "--server") == 0 ) {
565   server = argv[++i];
566  } else if ( strcmp(k, "-v") == 0 || strcmp(k, "--verbose") == 0 ) {
567   g_verbose++;
568  } else if ( strcmp(k, "--help") == 0 ) {
569   usage();
570   return 0;
571  } else if ( *k == '-' ) {
572   fprintf(stderr, "Error: unknown argument: %s\n", k);
573   usage();
574   return 1;
575  } else {
576   break;
577  }
578 }
579
580 // connect
581
582 if ( roar_connect(&con, server) == -1 ) {
583  fprintf(stderr, "Error: Can not connect to server\n");
584  return 1;
585 }
586
587 if ( roar_identify(&con, "roarctl") == -1 ) {
588  fprintf(stderr, "Error: Can not identify to server\n");
589  return 1;
590 }
591
592 if ( i == argc ) {
593  fprintf(stderr, "Error: No Commands given\n");
594  return 0; // this is not a fatal error...
595 }
596
597 for (; i < argc; i++) {
598  k = argv[i];
599  // cmd is in k
600
601  printf("--- [ %s ] ---\n", k);
602
603  if ( !strcmp(k, "help") ) {
604   usage();
605
606  } else if ( !strcmp(k, "sleep") ) {
607   sleep(atoi(argv[++i]));
608
609  } else if ( !strcmp(k, "standby") || !strcmp(k, "off") ) {
610   if ( roar_set_standby(&con, ROAR_STANDBY_ACTIVE) == -1 ) {
611    fprintf(stderr, "Error: can not set mode to standby\n");
612   } else {
613    printf("going into standby\n");
614   }
615  } else if ( !strcmp(k, "resume") || !strcmp(k, "on") ) {
616   if ( roar_set_standby(&con, ROAR_STANDBY_INACTIVE) == -1 ) {
617    fprintf(stderr, "Error: can not set mode to active\n");
618   } else {
619    printf("going into active mode\n");
620   }
621
622  } else if ( !strcmp(k, "exit") ) {
623   if ( roar_exit(&con) == -1 ) {
624    fprintf(stderr, "Error: can not quit server\n");
625   } else {
626    printf("Server quited\n");
627    break;
628   }
629  } else if ( !strcmp(k, "terminate") ) {
630   if ( roar_terminate(&con, 1) == -1 ) {
631    fprintf(stderr, "Error: can not terminate server\n");
632   } else {
633    printf("Server got asked to quited\n");
634    break;
635   }
636
637  } else if ( !strcmp(k, "standbymode") ) {
638   t = roar_get_standby(&con);
639   if ( t == -1 ) {
640    fprintf(stderr, "Error: can not get stanby mode\n");
641   } else if ( t == ROAR_STANDBY_ACTIVE ) {
642    printf("Server is in standby\n");
643   } else if ( t == ROAR_STANDBY_INACTIVE ) {
644    printf("Server is active\n");
645   } else {
646    fprintf(stderr, "Error: unknown standby mode: %i\n", t);
647   }
648
649  } else if ( !strcmp(k, "whoami") ) {
650   printf("My client ID is: %i\n", roar_get_clientid(&con));
651  } else if ( !strcmp(k, "serveroinfo") ) {
652   server_oinfo(&con);
653  } else if ( !strcmp(k, "listclients") ) {
654   list_clients(&con);
655  } else if ( !strcmp(k, "liststreams") ) {
656   list_streams(&con);
657  } else if ( !strcmp(k, "allinfo") ) {
658   server_oinfo(&con);
659   printf("\n");
660   list_clients(&con);
661   printf("\n");
662   list_streams(&con);
663
664  } else if ( !strcmp(k, "kick") ) {
665   k = argv[++i];
666   if ( !strcmp(k, "client") ) {
667    t = ROAR_OT_CLIENT;
668   } else if ( !strcmp(k, "stream") ) {
669    t = ROAR_OT_STREAM;
670   } else if ( !strcmp(k, "sample") ) {
671    t = ROAR_OT_SAMPLE;
672   } else if ( !strcmp(k, "source") ) {
673    t = ROAR_OT_SOURCE;
674   } else {
675    fprintf(stderr, "Error: unknown type: %s\n", k);
676    continue;
677   }
678   //t = atoi(argv[i++]);
679   if ( roar_kick(&con, t, atoi(argv[++i])) == -1 ) {
680    fprintf(stderr, "Error: can not kick %s\n", k);
681   } else {
682    printf("%s kicked\n", k);
683   }
684
685  } else if ( !strcmp(k, "volume") ) {
686   if ( set_mixer(&con, &i, argc, argv) == -1 ) {
687    fprintf(stderr, "Error: can not set volume\n");
688   } else {
689    printf("volume changed\n");
690   }
691
692  } else if ( !strcmp(k, "flag") ) {
693   i++;
694   if ( set_flags(&con, atoi(argv[i]), ROAR_SET_FLAG, argv[i+1]) == -1 ) {
695    fprintf(stderr, "Error: can not set flags\n");
696   } else {
697    printf("flags changed\n");
698   }
699   i++;
700  } else if ( !strcmp(k, "unflag") ) {
701   i++;
702   if ( set_flags(&con, atoi(argv[i]), ROAR_RESET_FLAG, argv[i+1]) == -1 ) {
703    fprintf(stderr, "Error: can not reset flags\n");
704   } else {
705    printf("flags changed\n");
706   }
707   i++;
708  } else if ( !strcmp(k, "metaset") ) {
709   i++;
710   if ( set_meta(&con, atoi(argv[i]), argv[i+1], argv[i+2], argv[i+3]) == -1 ) {
711    fprintf(stderr, "Error: can not set meta data\n");
712   } else {
713    printf("meta data changed\n");
714   }
715   i += 3;
716  } else if ( !strcmp(k, "metaget") ) {
717   i++;
718   if ( show_meta_type(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
719    fprintf(stderr, "Error: can not get meta data\n");
720   }
721   i++;
722  } else if ( !strcmp(k, "metasave") ) {
723   i++;
724   if ( save_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
725    fprintf(stderr, "Error: can not get meta data\n");
726   } else {
727    printf("meta data saved\n");
728   }
729   i++;
730  } else if ( !strcmp(k, "metaload") ) {
731   i++;
732   if ( load_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
733    fprintf(stderr, "Error: can not set meta data\n");
734   } else {
735    printf("meta data saved\n");
736   }
737   i++;
738
739  } else {
740   fprintf(stderr, "Error: invalid command: %s\n", k);
741  }
742
743 }
744
745 roar_disconnect(&con);
746
747 return 0;
748}
749
750//ll
Note: See TracBrowser for help on using the repository browser.