source: roaraudio/roarclients/roarctl.c @ 4610:5802dc34dda3

Last change on this file since 4610:5802dc34dda3 was 4603:566ba8970c08, checked in by phi, 14 years ago

print mime-type in addition to codec name

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