source: roaraudio/roarclients/roarctl.c @ 5087:f49298306e63

Last change on this file since 5087:f49298306e63 was 5087:f49298306e63, checked in by phi, 13 years ago

print only subsecs if remote clock provides them

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