source: roaraudio/roarclients/roarctl.c @ 5144:9126d33415d7

Last change on this file since 5144:9126d33415d7 was 5144:9126d33415d7, checked in by phi, 13 years ago

corrected stream ID, set it to -1 if unused.

File size: 36.6 KB
Line 
1//roarctl.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011
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, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26/* ckport options:
27 * ckport: ignore-symbol: roar_req of target libroar0 -- Used within ping command.
28 */
29
30#define _UNITS_T_BASE_USEC
31
32#include <roaraudio.h>
33#include <roaraudio/units.h>
34#include <libroardsp/libroardsp.h>
35
36#if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_SETUID)
37#define _POSIX_USERS
38#endif
39
40#ifdef _POSIX_USERS
41#include <pwd.h>
42#include <grp.h>
43#endif
44
45#include <sys/time.h>
46#include <time.h>
47
48#ifdef ROAR_HAVE_LIBM
49#include <math.h>
50#endif
51
52int g_verbose = 0;
53
54void display_client (struct roar_connection * con, int id);
55void display_stream (struct roar_connection * con, int id);
56int display_mixer (struct roar_connection * con, int stream);
57int show_meta_all (struct roar_connection * con, int id);
58
59void usage (void) {
60 printf("roarctl [OPTIONS]... COMMAND [OPTS] [COMMAND [OPTS] [COMMAND [OPTS] [...]]]\n");
61
62 printf("\nOptions:\n\n");
63
64 printf("  --server SERVER         - Set server hostname\n"
65        "  --help                  - Show this help\n"
66        "  --verbose   -v          - Show verbose output\n"
67        "  --list-aiprofiles       - Show audio info profiles and exit\n"
68        "  --enum-servers          - Show a list of possible servers\n"
69       );
70
71 printf("\nCommands:\n\n");
72 printf(
73        "  help                    - Show this help\n"
74        "  sleep TIME              - Sleeps for TIME seconds\n"
75#ifdef ROAR_HAVE_GETTIMEOFDAY
76        "  ping  NUM               - Do NUM pings using NOOP commands\n"
77#endif
78        "  whoami                  - Get own client ID\n"
79        "\n"
80        "  listaiprofiles          - list audio info profiles\n"
81        "  aiprofileget PROFILE    - show audio info profile PROFILE\n"
82        "\n"
83        "  standby, off            - Go into standby mode\n"
84        "  resume, on              - Go into active mode\n"
85        "  standbymode             - Show current standby mode\n"
86        "  exit                    - Quits the roard (must be used as last command)\n"
87        "  terminate               - Like exit but let the server up to serve still connected clients,\n"
88        "                            new clients cann't connect and the server terminates after the last\n"
89        "                            client disconnected\n"
90        "\n"
91        "  volume ID CHAN [scale S] V0 V1...\n"
92        "                          - Sets volume for stream ID\n"
93        "                            CHAN is the number of channels or 'mono' or 'stereo'\n"
94        "                            if mono or stereo is chosen roarctl trys to set\n"
95        "                            sensfull values for all channels even if the output\n"
96        "                            is has more channels.\n"
97        "                            An optional scale can be given using S.\n"
98        "                            all other args are the volumes of the channels\n"
99        "                            you may use integer or percent values.\n"
100        "                            percent values can floating points.\n"
101        "\n"
102        "  flag   ID FLAGS         - Sets flags FLAGS on stream ID. FLAGS may be a comma\n"
103        "                            separated list of flags.\n"
104        "  unflag ID FLAGS         - Unsets flags on a stream. See flag.\n"
105        "  toogleflag ID FLAGS     - Toggels flags on a stream. See flag.\n"
106        "  protectflag ID FLAGS    - Protects flags on a stream. Those flags can not be\n"
107        "                            changed anymore after the they got protected. See flag.\n"
108        "\n"
109        "  role ID ROLE            - Set role ROLE on stream ID.\n"
110        "\n"
111        "  kick TYPE ID            - Kicks object of TYPE with id ID\n"
112        "                            Types: client stream sample source\n"
113        "  newvirtual P D E R B C  - Adds a new virtual (child) stream\n"
114        "                            Parameters:\n"
115        "                             P: Parent stream ID, D: Direction,\n"
116        "                             E: codEc, R: sample Rate,\n"
117        "                             B: bits per sample, C: nummer of channels\n"
118        "\n"
119        "  metaget  ID TYPE        - Read meta date of type TYPE from stream ID\n"
120// TODO: document metaset here.
121        "  metasave ID FILE        - Saves meta data of stream ID to file FILE\n"
122        "  metaload ID FILE        - Loads meta data from file FILE and set it on stream ID\n"
123        "\n"
124        "  serverinfo              - Gets general information about the server\n"
125        "  servertime              - Gets server's time\n"
126        "  serveroinfo             - Gets Information about server output\n"
127        "  serveroinfo2 DIR        - Gets Information about server output for stream direction dir\n"
128        "\n"
129        "  serverstandards         - Gets list of server supported standards\n"
130        "\n"
131        "  listclients             - Gets Information about clients\n"
132        "  clientinfo ID           - Gets Information about client ID\n"
133        "  liststreams             - Gets Information about streams\n"
134        "  streaminfo ID           - Gets Information about stream ID\n"
135        "  allinfo                 - Get all infos\n"
136       );
137}
138
139int enum_servers (void) {
140 struct roar_server * list;
141 struct roar_server * c;
142 int flags    = ROAR_ENUM_FLAG_DESC|ROAR_ENUM_FLAG_LOCATION;
143 int dir      = -1;
144 int socktype = -1;
145 int i;
146
147 if ( (list = roar_enum_servers(flags, dir, socktype)) == NULL )
148  return -1;
149
150 printf("Server           Location         Description\n");
151 printf("----------------------------------------------------------------------\n");
152
153 for (i = 0; ; i++) {
154  c = &(list[i]);
155  printf("%-16s %-16s %s\n",
156             c->server      == NULL ? "(default)" : c->server,
157             c->location    == NULL ? ""          : c->location,
158             c->description == NULL ? ""          : c->description
159        );
160  if ( c->server == NULL )
161   break;
162 }
163
164 roar_enum_servers_free(list);
165
166 return 0;
167}
168
169#ifdef ROAR_HAVE_GETTIMEOFDAY
170int ping (struct roar_connection * con, int num) {
171 struct timeval         try, ans;
172 struct roar_message    m;
173 register int           ret;
174 int                    i;
175 double                 cur, min = 3600*1000, max = 0, sum = 0;
176
177 if ( num == 0 )
178  return 0;
179
180 for (i = 0; i < num; i++) {
181  memset(&m, 0, sizeof(m));
182
183  m.cmd = ROAR_CMD_NOOP;
184  m.stream  = -1;
185  m.datalen =  0;
186
187  // we use roar_req() directly here because of speed.
188  // roar_noop() does basicly the same but is a bit slower.
189
190  gettimeofday(&try, NULL);
191  ret = roar_req(con, &m, NULL);
192  gettimeofday(&ans, NULL);
193
194  if ( ret == -1 )
195   return -1;
196
197  while (ans.tv_sec > try.tv_sec) {
198   ans.tv_sec--;
199   ans.tv_usec += 1000000;
200  }
201  ans.tv_usec -= try.tv_usec;
202
203  printf("Pong from server: seq=%i time=%.3fms\n", i, (cur = ans.tv_usec/1000.0));
204
205  sum += cur;
206  if ( min > cur )
207   min = cur;
208  if ( cur > max )
209   max = cur;
210
211  if ( i != (num - 1) )
212   roar_sleep(1);
213 }
214
215 printf("\n--- ping statistics ---\n");
216 printf("%i packets transmitted\n", i);
217 printf("rtt min/avg/max = %.3f/%.3f/%.3f ms\n", min, sum/(double)i, max);
218
219 return 0;
220}
221#endif
222
223#define _pm(m,n) if ( info->m != NULL ) printf("Server %-15s: %s\n", (n), (info->m));
224void server_info (struct roar_connection * con) {
225 struct roar_server_info * info = roar_server_info(con);
226
227 if ( info == NULL ) {
228  fprintf(stderr, "Error: can not get server info\n");
229  return;
230 }
231
232 _pm(version, "version");
233 _pm(location, "location");
234 _pm(description, "description");
235 _pm(contact, "contact");
236 _pm(serial, "serial");
237 _pm(address, "address");
238 _pm(uiurl, "UI URL");
239 _pm(un.sysname, "System sysname");
240 _pm(un.release, "System release");
241 _pm(un.nodename, "System nodename");
242 _pm(un.machine, "System machine");
243
244 roar_server_info_free(info);
245}
246#undef _pm
247
248void server_time (struct roar_connection * con) {
249 struct roar_time time;
250
251 if ( roar_get_time(con, &time) == -1 ) {
252  fprintf(stderr, "Error: can not get server time: %s\n", roar_error2str(roar_error));
253  return;
254 }
255
256 if ( g_verbose ) {
257  printf("Server time           : %llu.%06llu [+%llu/2^64] sec\n",
258         (long long unsigned int)time.t_sec,
259         (long long unsigned int) time.t_ssec / 18446744073709LLU,
260         (long long unsigned int) time.t_ssec);
261 } else {
262  if ( time.c_freq == 1000000000LL && time.t_ssec == 0 ) {
263   printf("Server time           : %llu sec\n",
264          (long long unsigned int)time.t_sec);
265  } else {
266   printf("Server time           : %llu.%06llu sec\n",
267          (long long unsigned int)time.t_sec,
268          (long long unsigned int) time.t_ssec / 18446744073709LLU);
269  }
270 }
271 if ( time.c_freq )
272  printf("Server clock frequency: %f Hz\n", (float)((double)time.c_freq / (double)1000000000.));
273 if ( time.c_drift )
274  printf("Server clock drift    : %llu:2^64 (~10^%f)\n",
275         (long long unsigned int)time.c_drift, logf((float)time.c_drift)/2.302585f);
276}
277
278void server_oinfo (struct roar_connection * con, int dir) {
279 struct roar_stream s;
280
281 if ( roar_server_oinfo2(con, &s, dir) == -1 ) {
282  fprintf(stderr, "Error: can not get server output info\n");
283  return;
284 }
285
286 printf("Stream direction      : %s\n", roar_dir2str(s.dir));
287 printf("Server Output rate    : %i Hz\n", s.info.rate);
288 printf("Server Output bits    : %i\n", s.info.bits);
289 printf("Server Output channels: %i\n", s.info.channels);
290 printf("Server Output codec   : %i (%s%s)\n", s.info.codec, roar_codec2str(s.info.codec),
291                                     s.info.codec == ROAR_CODEC_DEFAULT ? " native" : "");
292// printf("Server Output rate: %i", s.info.rate);
293  if ( g_verbose > 1 && s.pos != (uint32_t)-1 )
294   printf("Server Position       : %lu S (%.3fs)\n", (unsigned long int) s.pos, (float)s.pos/(s.info.rate*s.info.channels));
295}
296
297void server_standards (struct roar_connection * con) {
298 struct roar_stds * stds;
299 size_t i;
300 int vendor, standard, version;
301 char numbuf[2][8];
302 const char * vendor_name;
303
304 if ( roar_caps_stds(con, &stds, NULL, -1) == -1 ) {
305  fprintf(stderr, "Error: can not get server standards\n");
306  return;
307 }
308
309 for (i = 0; i < stds->stds_len; i++) {
310  vendor   = ROAR_STD_VENDOR(stds->stds[i]);
311  standard = ROAR_STD_STD(stds->stds[i]);
312  version  = ROAR_STD_VERSION(stds->stds[i]);
313
314  if ( (vendor_name = roar_stds_vendor2str(vendor)) == NULL ) {
315   snprintf(numbuf[0], sizeof(numbuf[0]), "%i", vendor);
316   numbuf[0][sizeof(numbuf[0])-1] = 0;
317   vendor_name = numbuf[0];
318  }
319
320  if ( version == 0 ) {
321   numbuf[1][0] = 0;
322  } else {
323   snprintf(numbuf[1], sizeof(numbuf[1]), "-%i", version);
324   numbuf[1][sizeof(numbuf[1])-1] = 0;
325  }
326
327  printf("Server standard       : %s-%i%s\n", vendor_name, standard, numbuf[1]);
328 }
329}
330
331const char * proc_name (pid_t pid) {
332 static char ret[80] = "?";
333#ifdef __linux__
334 char file[80], buf[80], *r;
335 int  i;
336
337 snprintf(file, sizeof(file)-1, "/proc/%i/exe", pid);
338 file[sizeof(file)-1] = 0;
339
340 ret[0] = '?';
341 ret[1] = 0;
342
343 if ( (i = readlink(file, buf, sizeof(buf)-1)) != -1 ) {
344  buf[i] = 0;
345  if ( (r = strrchr(buf, '/')) != NULL ) {
346   r++;
347   if ( *r != 0 ) {
348    strncpy(ret, r, sizeof(ret)-1);
349    ret[sizeof(ret)-1] = 0;
350   }
351  }
352 }
353#else
354 (void)pid;
355#endif
356
357 return ret;
358}
359
360void list_clients (struct roar_connection * con) {
361 int i;
362 int num;
363 int id[ROAR_CLIENTS_MAX];
364
365 if ( (num = roar_list_clients(con, id, ROAR_CLIENTS_MAX)) == -1 ) {
366  fprintf(stderr, "Error: can not get client list\n");
367  return;
368 }
369
370 for (i = 0; i < num; i++) {
371  display_client(con, id[i]);
372 }
373}
374
375void display_client (struct roar_connection * con, int id) {
376 static int self_id = -1;
377 static struct roar_client   self_client_store;
378 static struct roar_client * self_client = NULL;
379 struct roar_client c;
380 char tmp[80];
381 int h;
382#ifdef _POSIX_USERS
383 struct group  * grp = NULL;
384 struct passwd * pwd = NULL;
385#endif
386
387 if ( self_id == -1 ) {
388  if ( (self_id = roar_get_clientid(con)) != -1 ) {
389   if ( roar_get_client(con, &self_client_store, self_id) == -1 ) {
390    self_id = -1;
391   } else {
392    self_client = &self_client_store;
393   }
394  }
395 }
396
397 printf("client %i:\n", id);
398 if ( roar_get_client(con, &c, id) == -1 ) {
399  fprintf(stderr, "Error: can not get client info\n");
400  return;
401 }
402
403 if ( c.name[0] != '\0' )
404  printf("Client name           : %s\n", c.name);
405  if ( roar_nnode_get_socktype(&(c.nnode)) != ROAR_SOCKET_TYPE_UNKNOWN ) {
406  if ( roar_nnode_to_str(&(c.nnode), tmp, sizeof(tmp)) == 0 ) {
407   printf("Client network node   : %s\n", tmp);
408  }
409 }
410
411 if ( c.pid != -1 ) {
412  if ( self_id != -1 && roar_nnode_cmp(&(self_client->nnode), &(c.nnode)) == 0 ) {
413   printf("Client PID            : %i(%s)\n", c.pid, proc_name(c.pid));
414  } else {
415   printf("Client PID            : %i\n", c.pid);
416  }
417 }
418 if ( c.uid != -1 ) {
419#ifdef _POSIX_USERS
420  if ( self_id != -1 && roar_nnode_cmp(&(self_client->nnode), &(c.nnode)) == 0 ) {
421   pwd = getpwuid(c.uid);
422   grp = getgrgid(c.gid);
423   printf("Client UID/GID        : %i(%s)/%i(%s)\n", c.uid, pwd ? pwd->pw_name : "?", c.gid, grp ? grp->gr_name : "?");
424  } else {
425#else
426  if ( 1 ) {
427#endif
428   printf("Client UID/GID        : %i/%i\n", c.uid, c.gid);
429  }
430 }
431
432 if ( g_verbose && c.proto != ROAR_PROTO_NONE ) {
433  printf("Client Protocol       : %s\n", roar_proto2str(c.proto));
434 }
435
436 if ( g_verbose && c.byteorder != ROAR_BYTEORDER_UNKNOWN ) {
437  if ( c.byteorder == ROAR_BYTEORDER_NETWORK ) {
438   roar_mm_strscpy(tmp, " (network byteorder");
439  } else {
440   *tmp = 0;
441  }
442
443  if ( c.byteorder == ROAR_BYTEORDER_NATIVE ) {
444   if ( *tmp ) {
445    roar_mm_strscat(tmp, ", native");
446   } else {
447    roar_mm_strscpy(tmp, " (native");
448   }
449  }
450
451  if ( *tmp )
452   roar_mm_strscat(tmp, ")");
453
454  printf("Client Byteorder      : %s%s\n", roar_byteorder2str(c.byteorder), tmp);
455 }
456
457 if ( c.execed != -1 )
458  printf("Execed stream         : %i\n", c.execed);
459
460 for (h = 0; h < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; h++)
461  if ( c.streams[h] != -1 )
462   printf("stream                : %i\n", c.streams[h]);
463}
464
465void list_streams (struct roar_connection * con) {
466 int i;
467 int num;
468 int id[ROAR_STREAMS_MAX];
469
470 if ( (num = roar_list_streams(con, id, ROAR_STREAMS_MAX)) == -1 ) {
471  fprintf(stderr, "Error: can not get stream list\n");
472  return;
473 }
474
475 for (i = 0; i < num; i++) {
476  display_stream(con, id[i]);
477 }
478}
479
480void display_stream (struct roar_connection * con, int id) {
481 char chanmap[ROAR_MAX_CHANNELS];
482 struct roar_stream s;
483 struct roar_stream_info info;
484 char buffer[1024];
485 char * flags = buffer;
486 char * name  = buffer;
487 char * infotext;
488 const char * mime;
489 size_t len;
490
491 printf("stream %i:\n", id);
492 if ( roar_get_stream(con, &s, id) == -1 ) {
493  fprintf(stderr, "Error: can not get stream info\n");
494  return;
495 }
496 printf("Stream direction      : %s\n", roar_dir2str(s.dir));
497
498 if ( roar_stream_get_name(con, &s, name, sizeof(buffer)) == 0 )
499  printf("Stream name           : %s\n", name);
500
501 if ( (int)s.pos_rel_id == -1 ) {
502  printf("Relativ position id   : none (stream not synchronized)\n");
503 } else if ( (int)s.pos_rel_id == id ) {
504  printf("Relativ position id   : %i (self synchronized)\n", s.pos_rel_id);
505 } else {
506  printf("Relativ position id   : %i (synchronized)\n", s.pos_rel_id);
507 }
508 if ( g_verbose > 1 && s.pos != (uint32_t)-1 ) {
509  if ( s.info.rate && s.info.channels ) {
510   printf("Position              : %lu S (%.3fs)\n", (unsigned long int) s.pos,
511                                   (float)s.pos/(s.info.rate*s.info.channels));
512  } else {
513   printf("Position              : %lu S\n", (unsigned long int) s.pos);
514  }
515 }
516
517 switch (s.dir) {
518  case ROAR_DIR_MIDI_IN:
519  case ROAR_DIR_MIDI_OUT:
520    infotext = " ticks/s";
521   break;
522  case ROAR_DIR_LIGHT_IN:
523  case ROAR_DIR_LIGHT_OUT:
524    infotext = " updates/s";
525   break;
526  default:
527    infotext = " Hz";
528 }
529 if ( s.info.rate )
530  printf("Stream sample rate    : %i%s\n", s.info.rate, infotext);
531 if ( s.info.bits )
532  printf("Stream bits           : %i\n", s.info.bits);
533 if ( s.info.channels )
534  printf("Stream channels       : %i\n", s.info.channels);
535
536 mime = roar_codec2mime(s.info.codec);
537 printf("Stream codec          : %2i (%s%s%s%s)\n", s.info.codec, roar_codec2str(s.info.codec),
538                                      s.info.codec == ROAR_CODEC_DEFAULT ? " native" : "",
539                                      mime == NULL ? "" : " mimetype:",
540                                      mime == NULL ? "" : mime
541                                     );
542 if ( roar_stream_get_info(con, &s, &info) != -1 ) {
543  if ( info.codec != s.info.codec ) {
544   mime = roar_codec2mime(info.codec);
545   printf("Streamed codec        : %2i (%s%s%s%s)\n", info.codec, roar_codec2str(info.codec),
546                                      info.codec == ROAR_CODEC_DEFAULT ? " native" : "",
547                                      mime == NULL ? "" : " mimetype:",
548                                      mime == NULL ? "" : mime
549                                     );
550  }
551
552  if ( g_verbose ) {
553   if ( info.block_size )
554    printf("Stream block size     : %i Byte\n", info.block_size);
555
556   printf("Underruns pre/post    : %i/%i\n",   info.pre_underruns, info.post_underruns);
557   if ( g_verbose > 1 )
558    printf("Stream delay          : %ims (%.2fm)\n",   (int)info.delay/1000, (info.delay*(float)_SPEED_OF_SOUND));
559
560   if ( g_verbose > 1 )
561    printf("Stream mixer          : %i\n",   info.mixer);
562
563   if ( g_verbose > 1 )
564    printf("Stream state          : %s\n",   roar_streamstate2str(info.state));
565
566   if ( g_verbose > 1 )
567    printf("Stream role           : %s\n",   roar_role2str(info.role));
568
569   *flags = 0;
570#define _strcat(dst,src) roar_mm_strlcat((dst),(src), sizeof(buffer))
571   if ( info.flags & ROAR_FLAG_PRIMARY )
572    _strcat(flags, "primary ");
573   if ( info.flags & ROAR_FLAG_SYNC )
574    _strcat(flags, "sync ");
575   if ( info.flags & ROAR_FLAG_OUTPUT )
576    _strcat(flags, "output ");
577   if ( info.flags & ROAR_FLAG_SOURCE )
578    _strcat(flags, "source ");
579   if ( info.flags & ROAR_FLAG_META )
580    _strcat(flags, "meta ");
581   if ( info.flags & ROAR_FLAG_AUTOCONF )
582    _strcat(flags, "autoconf ");
583   if ( info.flags & ROAR_FLAG_CLEANMETA )
584    _strcat(flags, "cleanmeta ");
585   if ( info.flags & ROAR_FLAG_HWMIXER )
586    _strcat(flags, "hwmixer ");
587   if ( info.flags & ROAR_FLAG_PAUSE )
588    _strcat(flags, "pause ");
589   if ( info.flags & ROAR_FLAG_MUTE )
590    _strcat(flags, "mute ");
591   if ( info.flags & ROAR_FLAG_MMAP )
592    _strcat(flags, "mmap ");
593   if ( info.flags & ROAR_FLAG_ANTIECHO )
594    _strcat(flags, "antiecho ");
595   if ( info.flags & ROAR_FLAG_VIRTUAL )
596    _strcat(flags, "virtual ");
597   if ( info.flags & ROAR_FLAG_RECSOURCE )
598    _strcat(flags, "recsource ");
599   if ( info.flags & ROAR_FLAG_PASSMIXER )
600    _strcat(flags, "passmixer ");
601   if ( info.flags & ROAR_FLAG_PRETHRU )
602    _strcat(flags, "prethru ");
603   if ( info.flags & ROAR_FLAG_IMMUTABLE )
604    _strcat(flags, "immutable ");
605   if ( info.flags & ROAR_FLAG_ENHANCE )
606    _strcat(flags, "enhance ");
607   if ( info.flags & ROAR_FLAG_SINGLESINK )
608    _strcat(flags, "singlesink ");
609#undef _strcat
610
611   printf("Flags                 : %s\n", flags);
612  }
613 }
614
615 if ( g_verbose ) {
616  len = ROAR_MAX_CHANNELS;
617  if ( roar_stream_get_chanmap(con, &s, chanmap, &len) == -1 ) {
618   fprintf(stderr, "Error: can not get stream channel map\n");
619  } else {
620   if ( roardsp_chanlist2str(chanmap, len, buffer, 1024) == -1 ) {
621    fprintf(stderr, "Error: can not convert channel map into string\n");
622   } else {
623    printf("Channel Map           : %s\n", buffer);
624   }
625  }
626 }
627
628 if ( s.dir != ROAR_DIR_THRU ) {
629  display_mixer(con, id);
630  show_meta_all(con, id);
631 }
632}
633
634int display_mixer (struct roar_connection * con, int stream) {
635 struct roar_mixer_settings mixer;
636 int channels;
637 int i;
638 float fs;
639
640 if ( roar_get_vol(con, stream, &mixer, &channels) == -1 ) {
641  fprintf(stderr, "Error: can not get stream mixer info for stream %i\n", stream);
642  return -1;
643 }
644
645#ifdef ROAR_HAVE_LIBM
646#define _DB ", %.2fdB"
647#else
648#define _DB ""
649#endif
650
651 fs = (float)mixer.scale / 100.;
652
653 if ( channels ) { // we hide RPG info for zero-channel streams
654  printf("Mixer ReplayGain      : %i/%i (%.2f%%" _DB ")\n", mixer.rpg_mul, mixer.rpg_div,
655                                                          100.*(float)mixer.rpg_mul/((float)mixer.rpg_div)
656#ifdef ROAR_HAVE_LIBM
657                           , 20*log10f((float)mixer.rpg_mul/(float)mixer.rpg_div)
658#endif
659        );
660 }
661
662 for (i = 0; i < channels; i++)
663  printf("Mixer volume chan %2i  : %i/%i (%.2f%%" _DB ")\n", i, mixer.mixer[i], mixer.scale,
664                           (float)mixer.mixer[i]/fs
665#ifdef ROAR_HAVE_LIBM
666                          , 20*log10f((float)mixer.mixer[i]/(float)mixer.scale)
667#endif
668        );
669
670 return 0;
671}
672
673static unsigned int set_mixer_parse_volume (char * k, int len, uint16_t scale) {
674 float fs = scale;
675
676 switch (k[len - 1]) {
677  case '%':
678    k[len - 1] = 0;
679    return (atof(k)*fs)/100.;
680   break;
681#ifdef ROAR_HAVE_LIBM
682  case 'b':
683  case 'B':
684    // TODO: can we hanle the error better?
685    if ( len < 2 )
686     return 0;
687
688    k[len - 2] = 0;
689    return powf(10, atof(k)/20.f)*fs;
690   break;
691#endif
692 }
693
694 return atoi(k);
695}
696
697int set_mixer (struct roar_connection * con, int * cur, int max, char * arg[]) {
698 uint16_t scale = 65535;
699 int chans = 0;
700 int id;
701 int i;
702 int len;
703 int old_chans;
704 char * k;
705 struct roar_mixer_settings mixer;
706 struct roar_mixer_settings old_mixer;
707 int mode = ROAR_SET_VOL_ALL;
708
709 if (*cur + 2 > max)
710  return -1;
711
712 id = atoi(arg[++(*cur)]);
713
714 k = arg[++(*cur)];
715
716 if ( !strcmp(arg[*cur + 1], "scale") ) {
717  (*cur)++; // 'scale'
718  (*cur)++;
719  scale = set_mixer_parse_volume(arg[*cur], strlen(arg[*cur]), 65535);
720 }
721
722 mixer.scale = scale;
723
724 if ( roar_get_vol(con, id, &old_mixer, &old_chans) == -1 ) {
725  fprintf(stderr, "Error: can not get stream mixer info for stream %i\n", id);
726  return -1;
727 }
728
729 if ( strcmp(k, "mono") == 0 ) {
730  chans = 1;
731  mode  = ROAR_SET_VOL_UNMAPPED;
732 } else if ( strcmp(k, "stereo") == 0 ) {
733  chans = 2;
734  mode  = ROAR_SET_VOL_UNMAPPED;
735 } else {
736  chans = atoi(k);
737 }
738
739 // ensure most simple mode:
740 if ( old_chans == chans && mode == ROAR_SET_VOL_UNMAPPED )
741  mode = ROAR_SET_VOL_ALL;
742
743 if ( *cur + chans > max )
744  return -1;
745
746 for (i = 0; i < chans; i++) {
747  k   = arg[++(*cur)];
748  len = strlen(k);
749
750  mixer.mixer[i] = set_mixer_parse_volume(k, len, scale);
751 }
752
753 if ( roar_set_vol2(con, id, &mixer, chans, mode) == 0 )
754  return 0;
755
756 // no fallback if already using ROAR_SET_VOL_ALL:
757 if ( mode == ROAR_SET_VOL_ALL )
758  return -1;
759
760 if ( roar_conv_volume(&mixer, &mixer, old_chans, chans) == -1 )
761  return -1;
762
763 chans = old_chans;
764 mode  = ROAR_SET_VOL_ALL;
765
766 if ( roar_set_vol2(con, id, &mixer, chans, mode) == 0 )
767  return 0;
768
769 return -1;
770}
771
772
773int newvirtual (struct roar_connection * con, char *p_s, char *d_s, char *e_s, char *r_s, char *b_s, char *c_s) {
774 struct roar_stream s;
775 int dir    = roar_str2dir(d_s);
776 int parent = atoi(p_s);
777
778 ROAR_DBG("newvirtual(*): dir=%i, parent=%i", dir, parent);
779
780 if ( roar_stream_new(&s, atoi(r_s), atoi(c_s), atoi(b_s), roar_str2codec(e_s)) == -1 )
781  return -1;
782
783 return roar_simple_connect_virtual(con, &s, parent, dir);
784}
785
786int set_meta (struct roar_connection * con, int id, char * mode, char * type, char * val) {
787 struct roar_meta   meta;
788 struct roar_stream s;
789 int mode_i = ROAR_META_MODE_SET;
790
791 if ( roar_stream_new_by_id(&s, id) == -1 )
792  return -1;
793
794// printf("set_meta(*): mode='%s', type='%s', val='%s'\n", mode, type, val);
795
796 if ( strcmp(mode, "add") == 0 ) {
797  mode_i = ROAR_META_MODE_ADD;
798 }
799
800 meta.type   = roar_meta_inttype(type);
801 meta.value  = val;
802 meta.key[0] = 0;
803
804 if ( meta.type == -1 ) {
805  fprintf(stderr, "Error: unknown type: %s\n", type);
806  return -1;
807 }
808
809// printf("D: type=%i, mode=%i\n", meta.type, mode_i);
810
811 if ( roar_stream_meta_set(con, &s, mode_i, &meta) == -1 )
812  return -1;
813
814 meta.type  = ROAR_META_TYPE_NONE;
815 meta.value = NULL;
816
817 return roar_stream_meta_set(con, &s, ROAR_META_MODE_FINALIZE, &meta);
818}
819
820int load_meta (struct roar_connection * con, int id, char * file) {
821 struct roar_meta   meta;
822 struct roar_stream s;
823 int mode_i = ROAR_META_MODE_SET;
824 FILE * in;
825 char lion[1024];
826 char * v;
827
828 if ( roar_stream_new_by_id(&s, id) == -1 )
829  return -1;
830
831 if ( (in = fopen(file, "r")) == NULL )
832  return -1;
833
834 while (fgets(lion, 1024, in) != NULL) {
835  if ( (v = strtok(lion, "\r\n")) != NULL )
836   if ( (v = strtok(NULL, "\r\n")) != NULL )
837    *(v-1) = 0;
838
839  if ( (v = strstr(lion, "=")) == NULL ) {
840   fprintf(stderr, "Error: can not parse meta data lion: %s\n", lion);
841   continue;
842  }
843
844  *v++ = 0;
845
846  meta.type   = roar_meta_inttype(lion);
847  meta.value  = v;
848  meta.key[0] = 0;
849
850  if ( meta.type == -1 ) {
851   fprintf(stderr, "Error: unknown type: %s\n", lion);
852   continue;
853  }
854
855  if ( roar_stream_meta_set(con, &s, mode_i, &meta) == -1 ) {
856   fclose(in);
857   return -1;
858  }
859 }
860
861 fclose(in);
862
863 meta.type  = ROAR_META_TYPE_NONE;
864 meta.value = NULL;
865
866 return roar_stream_meta_set(con, &s, ROAR_META_MODE_FINALIZE, &meta);
867}
868
869int show_meta_type (struct roar_connection * con, int id, char * type) {
870 struct roar_meta   meta;
871 struct roar_stream s;
872
873 if ( roar_stream_new_by_id(&s, id) == -1 )
874  return -1;
875
876 meta.type  = roar_meta_inttype(type);
877
878 if ( meta.type == -1 ) {
879  fprintf(stderr, "Error: unknown type: %s\n", type);
880  return -1;
881 }
882
883 if ( roar_stream_meta_get(con, &s, &meta) == -1 )
884  return -1;
885
886 printf("Meta %-17s: %s\n", roar_meta_strtype(meta.type), meta.value);
887
888 roar_meta_free(&meta);
889
890 return 0;
891}
892
893int show_meta_all (struct roar_connection * con, int id) {
894 struct roar_stream s;
895 int types[ROAR_META_MAX_PER_STREAM];
896 int i;
897 int len;
898
899 if ( roar_stream_new_by_id(&s, id) == -1 )
900  return -1;
901
902 if ( (len = roar_stream_meta_list(con, &s, types, ROAR_META_MAX_PER_STREAM)) == -1 )
903  return -1;
904
905 for (i = 0; i < len; i++)
906  show_meta_type(con, id, roar_meta_strtype(types[i]));
907
908 return 0;
909}
910
911int save_meta (struct roar_connection * con, int id, char * file) {
912 struct roar_stream s;
913 struct roar_meta   meta;
914 int types[ROAR_META_MAX_PER_STREAM];
915 int i;
916 int len;
917 FILE * out;
918
919 if ( roar_stream_new_by_id(&s, id) == -1 )
920  return -1;
921
922 if ( (len = roar_stream_meta_list(con, &s, types, ROAR_META_MAX_PER_STREAM)) == -1 )
923  return -1;
924
925 if ( (out = fopen(file, "w")) == NULL )
926  return -1;
927
928 for (i = 0; i < len; i++) {
929/*
930  show_meta_type(con, id, roar_meta_strtype(types[i]));
931*/
932  meta.type  = types[i];
933
934  if ( roar_stream_meta_get(con, &s, &meta) == -1 )
935   continue;
936
937//  printf("Meta %-17s: %s\n", roar_meta_strtype(meta.type), meta.value);
938
939  fprintf(out, "%s=%s\n", roar_meta_strtype(meta.type), meta.value);
940
941  roar_meta_free(&meta);
942 }
943
944 fclose(out);
945
946 return 0;
947}
948
949int set_flags (struct roar_connection * con, int id, int action, char * flags) {
950 uint32_t f = ROAR_FLAG_NONE;
951 char * c;
952 struct roar_stream s[1];
953
954 if ( roar_stream_new_by_id(s, id) == -1 )
955  return -1;
956
957 c = strtok(flags, ",");
958 while (c != NULL) {
959  if ( !strcmp(c, "meta") ) {
960   f |= ROAR_FLAG_META;
961  } else if ( !strcmp(c, "primary") ) {
962   f |= ROAR_FLAG_PRIMARY;
963  } else if ( !strcmp(c, "sync") ) {
964   f |= ROAR_FLAG_SYNC;
965  } else if ( !strcmp(c, "cleanmeta") ) {
966   f |= ROAR_FLAG_CLEANMETA;
967  } else if ( !strcmp(c, "hwmixer") ) {
968   f |= ROAR_FLAG_HWMIXER;
969  } else if ( !strcmp(c, "pause") ) {
970   f |= ROAR_FLAG_PAUSE;
971  } else if ( !strcmp(c, "mute") ) {
972   f |= ROAR_FLAG_MUTE;
973  } else if ( !strcmp(c, "mmap") ) {
974   f |= ROAR_FLAG_MMAP;
975  } else if ( !strcmp(c, "antiecho") ) {
976   f |= ROAR_FLAG_ANTIECHO;
977  } else if ( !strcmp(c, "recsource") ) {
978   f |= ROAR_FLAG_RECSOURCE;
979  } else if ( !strcmp(c, "passmixer") ) {
980   f |= ROAR_FLAG_PASSMIXER;
981  } else if ( !strcmp(c, "virtual") ) {
982   f |= ROAR_FLAG_VIRTUAL;
983  } else if ( !strcmp(c, "prethru") ) {
984   f |= ROAR_FLAG_PRETHRU;
985  } else if ( !strcmp(c, "immutable") ) {
986   f |= ROAR_FLAG_IMMUTABLE;
987  } else if ( !strcmp(c, "enhance") ) {
988   f |= ROAR_FLAG_ENHANCE;
989  } else if ( !strcmp(c, "singlesink") ) {
990   f |= ROAR_FLAG_SINGLESINK;
991  } else {
992   fprintf(stderr, "Error: unknown flag: %s\n", c);
993   return -1;
994  }
995
996  c = strtok(NULL, ",");
997 }
998
999 return roar_stream_set_flags2(con, s, f, action);
1000}
1001
1002int set_role (struct roar_connection * con, int id, int role) {
1003 struct roar_stream s;
1004
1005 if ( id == -1 )
1006  return -1;
1007
1008 if ( roar_stream_new_by_id(&s, id) == -1 )
1009  return -1;
1010
1011 if ( roar_stream_set_role(con, &s, role) == -1 )
1012  return -1;
1013
1014 return 0;
1015}
1016
1017int show_aiprofile (const char * profile) {
1018 struct roar_audio_info info;
1019 const char * mime;
1020
1021 if ( roar_profile2info(&info, profile) == -1 ) {
1022  fprintf(stderr, "Error: unknown profile: %s\n", profile);
1023  return -1;
1024 }
1025
1026 mime = roar_codec2mime(info.codec);
1027
1028 printf("Profile Name          : %s\n", profile);
1029
1030 if ( info.rate )
1031  printf("Profile sample rate   : %i\n", info.rate);
1032 if ( info.bits )
1033  printf("Profile bits          : %i\n", info.bits);
1034 if ( info.channels )
1035  printf("Profile channels      : %i\n", info.channels);
1036
1037 printf("Profile codec         : %2i (%s%s%s%s)\n", info.codec, roar_codec2str(info.codec),
1038                                       info.codec == ROAR_CODEC_DEFAULT ? " native" : "",
1039                                       mime == NULL ? "" : " mimetype:",
1040                                       mime == NULL ? "" : mime);
1041
1042 return 0;
1043}
1044
1045int list_aiprofiles (void) {
1046 const char * list[1024];
1047 ssize_t ret;
1048 ssize_t i;
1049
1050 ret = roar_profiles_list(list, 1024, 0);
1051
1052 if ( ret == -1 ) {
1053  fprintf(stderr, "Error: can not read list of profiles\n");
1054  return -1;
1055 }
1056
1057 for (i = 0; i < ret; i++) {
1058  printf("profile %lli:\n", (long long signed int)i);
1059  show_aiprofile(list[i]);
1060 }
1061
1062 return 0;
1063}
1064
1065int main (int argc, char * argv[]) {
1066 struct roar_connection con;
1067 char * server   = NULL;
1068 char * k = NULL;
1069 int    i;
1070 int    t = 0;
1071
1072 for (i = 1; i < argc; i++) {
1073  k = argv[i];
1074
1075  if ( strcmp(k, "--server") == 0 ) {
1076   server = argv[++i];
1077  } else if ( strcmp(k, "-v") == 0 || strcmp(k, "--verbose") == 0 ) {
1078   g_verbose++;
1079  } else if ( strcmp(k, "--help") == 0 ) {
1080   usage();
1081   return 0;
1082  } else if ( strcmp(k, "--list-aiprofiles") == 0 ) {
1083   list_aiprofiles();
1084   return 0;
1085  } else if ( strcmp(k, "--enum-servers") == 0 ) {
1086   enum_servers();
1087   return 0;
1088  } else if ( *k == '-' ) {
1089   fprintf(stderr, "Error: unknown argument: %s\n", k);
1090   usage();
1091   return 1;
1092  } else {
1093   break;
1094  }
1095 }
1096
1097 // connect
1098
1099 if ( roar_simple_connect(&con, server, "roarctl") == -1 ) {
1100  fprintf(stderr, "Error: Can not connect to server\n");
1101  return 1;
1102 }
1103
1104 if ( i == argc ) {
1105  fprintf(stderr, "Error: No Commands given\n");
1106  return 0; // this is not a fatal error...
1107 }
1108
1109 for (; i < argc; i++) {
1110  k = argv[i];
1111  // cmd is in k
1112
1113  printf("--- [ %s ] ---\n", k);
1114
1115  if ( !strcmp(k, "help") ) {
1116   usage();
1117
1118  } else if ( !strcmp(k, "sleep") ) {
1119   roar_sleep(atoi(argv[++i]));
1120
1121  } else if ( !strcmp(k, "ping") ) {
1122#ifdef ROAR_HAVE_GETTIMEOFDAY
1123   if ( ping(&con, atoi(argv[++i])) == -1 ) {
1124    fprintf(stderr, "Error: can not ping\n");
1125   }
1126#else
1127    fprintf(stderr, "Error: ping not supported.\n");
1128    i++;
1129#endif
1130
1131  } else if ( !strcmp(k, "standby") || !strcmp(k, "off") ) {
1132   if ( roar_set_standby(&con, ROAR_STANDBY_ACTIVE) == -1 ) {
1133    fprintf(stderr, "Error: can not set mode to standby\n");
1134   } else {
1135    printf("going into standby\n");
1136   }
1137  } else if ( !strcmp(k, "resume") || !strcmp(k, "on") ) {
1138   if ( roar_set_standby(&con, ROAR_STANDBY_INACTIVE) == -1 ) {
1139    fprintf(stderr, "Error: can not set mode to active\n");
1140   } else {
1141    printf("going into active mode\n");
1142   }
1143
1144  } else if ( !strcmp(k, "exit") ) {
1145   if ( roar_terminate(&con, 0) == -1 ) {
1146    fprintf(stderr, "Error: can not quit server\n");
1147   } else {
1148    printf("Server quited\n");
1149    break;
1150   }
1151  } else if ( !strcmp(k, "terminate") ) {
1152   if ( roar_terminate(&con, 1) == -1 ) {
1153    fprintf(stderr, "Error: can not terminate server\n");
1154   } else {
1155    printf("Server got asked to quited\n");
1156    break;
1157   }
1158
1159  } else if ( !strcmp(k, "standbymode") ) {
1160   t = roar_get_standby(&con);
1161   if ( t == -1 ) {
1162    fprintf(stderr, "Error: can not get stanby mode\n");
1163   } else if ( t == ROAR_STANDBY_ACTIVE ) {
1164    printf("Server is in standby\n");
1165   } else if ( t == ROAR_STANDBY_INACTIVE ) {
1166    printf("Server is active\n");
1167   } else {
1168    fprintf(stderr, "Error: unknown standby mode: %i\n", t);
1169   }
1170
1171  } else if ( !strcmp(k, "whoami") ) {
1172   printf("My client ID is: %i\n", roar_get_clientid(&con));
1173  } else if ( !strcmp(k, "serverinfo") ) {
1174   server_info(&con);
1175  } else if ( !strcmp(k, "servertime") ) {
1176   server_time(&con);
1177  } else if ( !strcmp(k, "serveroinfo") ) {
1178   server_oinfo(&con, -1);
1179  } else if ( !strcmp(k, "serveroinfo2") ) {
1180   t = roar_str2dir(argv[++i]);
1181   if ( t == -1 ) {
1182    fprintf(stderr, "Error: unknown stream direction: %s\n", argv[i]);
1183   } else {
1184    server_oinfo(&con, t);
1185   }
1186  } else if ( !strcmp(k, "serverstandards") ) {
1187   server_standards(&con);
1188  } else if ( !strcmp(k, "listclients") ) {
1189   list_clients(&con);
1190  } else if ( !strcmp(k, "clientinfo") ) {
1191   display_client(&con, atoi(argv[++i]));
1192  } else if ( !strcmp(k, "liststreams") ) {
1193   list_streams(&con);
1194  } else if ( !strcmp(k, "streaminfo") ) {
1195   display_stream(&con, atoi(argv[++i]));
1196  } else if ( !strcmp(k, "allinfo") ) {
1197   server_oinfo(&con, -1);
1198   printf("\n");
1199   list_clients(&con);
1200   printf("\n");
1201   list_streams(&con);
1202
1203  } else if ( !strcmp(k, "kick") ) {
1204   t = roar_str2ot((k = argv[++i]));
1205   if ( t == -1 ) {
1206    fprintf(stderr, "Error: unknown type: %s\n", k);
1207    continue;
1208   }
1209   //t = atoi(argv[i++]);
1210   if ( roar_kick(&con, t, atoi(argv[++i])) == -1 ) {
1211    fprintf(stderr, "Error: can not kick %s\n", k);
1212   } else {
1213    printf("%s kicked\n", k);
1214   }
1215
1216  } else if ( !strcmp(k, "newvirtual") ) {
1217   if ( newvirtual(&con, argv[i+1], argv[i+2], argv[i+3], argv[i+4], argv[i+5], argv[i+6]) == -1 ) {
1218    fprintf(stderr, "Error: can not create new virtual stream\n");
1219   } else {
1220    printf("virtual stream created\n");
1221   }
1222   i += 6;
1223
1224  } else if ( !strcmp(k, "volume") ) {
1225   if ( set_mixer(&con, &i, argc, argv) == -1 ) {
1226    fprintf(stderr, "Error: can not set volume\n");
1227   } else {
1228    printf("volume changed\n");
1229   }
1230
1231  } else if ( !strcmp(k, "flag") ) {
1232   i++;
1233   if ( set_flags(&con, atoi(argv[i]), ROAR_SET_FLAG, argv[i+1]) == -1 ) {
1234    fprintf(stderr, "Error: can not set flags\n");
1235   } else {
1236    printf("flags changed\n");
1237   }
1238   i++;
1239  } else if ( !strcmp(k, "unflag") ) {
1240   i++;
1241   if ( set_flags(&con, atoi(argv[i]), ROAR_RESET_FLAG, argv[i+1]) == -1 ) {
1242    fprintf(stderr, "Error: can not reset flags\n");
1243   } else {
1244    printf("flags changed\n");
1245   }
1246   i++;
1247  } else if ( !strcmp(k, "toggleflag") ) {
1248   i++;
1249   if ( set_flags(&con, atoi(argv[i]), ROAR_TOGGLE_FLAG, argv[i+1]) == -1 ) {
1250    fprintf(stderr, "Error: can not toggle flags\n");
1251   } else {
1252    printf("flags changed\n");
1253   }
1254   i++;
1255  } else if ( !strcmp(k, "protectflag") ) {
1256   i++;
1257   if ( set_flags(&con, atoi(argv[i]), ROAR_NOOP_FLAG|ROAR_PROTECT_FLAG, argv[i+1]) == -1 ) {
1258    fprintf(stderr, "Error: can not protect flags\n");
1259   } else {
1260    printf("flags protected\n");
1261   }
1262   i++;
1263
1264  } else if ( !strcmp(k, "role") ) {
1265   i++;
1266   if ( set_role(&con, atoi(argv[i]), roar_str2role(argv[i+1])) == -1 ) {
1267    fprintf(stderr, "Error: can not set stream role\n");
1268   } else {
1269    printf("stream role set\n");
1270   }
1271   i++;
1272
1273  } else if ( !strcmp(k, "metaset") ) {
1274   i++;
1275   if ( set_meta(&con, atoi(argv[i]), argv[i+1], argv[i+2], argv[i+3]) == -1 ) {
1276    fprintf(stderr, "Error: can not set meta data\n");
1277   } else {
1278    printf("meta data changed\n");
1279   }
1280   i += 3;
1281  } else if ( !strcmp(k, "metaget") ) {
1282   i++;
1283   if ( show_meta_type(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
1284    fprintf(stderr, "Error: can not get meta data\n");
1285   }
1286   i++;
1287  } else if ( !strcmp(k, "metasave") ) {
1288   i++;
1289   if ( save_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
1290    fprintf(stderr, "Error: can not get meta data\n");
1291   } else {
1292    printf("meta data saved\n");
1293   }
1294   i++;
1295  } else if ( !strcmp(k, "metaload") ) {
1296   i++;
1297   if ( load_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
1298    fprintf(stderr, "Error: can not set meta data\n");
1299   } else {
1300    printf("meta data saved\n");
1301   }
1302   i++;
1303
1304
1305  } else if ( !strcmp(k, "listaiprofiles") || !strcmp(k, "listprofiles") ) {
1306   if ( list_aiprofiles() == -1 ) {
1307    fprintf(stderr, "Error: can not list profiles\n");
1308   }
1309  } else if ( !strcmp(k, "aiprofileget") || !strcmp(k, "profileget") ) {
1310   i++;
1311   if ( show_aiprofile(argv[i]) == -1 ) {
1312    fprintf(stderr, "Error: can not get profile data\n");
1313   }
1314  } else {
1315   fprintf(stderr, "Error: invalid command: %s\n", k);
1316  }
1317
1318 }
1319
1320 roar_disconnect(&con);
1321
1322 return 0;
1323}
1324
1325//ll
Note: See TracBrowser for help on using the repository browser.