1 | //roarctl.c: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008 |
---|
5 | * |
---|
6 | * This file is part of roarclients a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * RoarAudio is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
22 | * |
---|
23 | */ |
---|
24 | |
---|
25 | #include <roaraudio.h> |
---|
26 | |
---|
27 | #if defined(ROAR_HAVE_SETGID) && defined(ROAR_HAVE_SETUID) |
---|
28 | #define _POSIX_USERS |
---|
29 | #endif |
---|
30 | |
---|
31 | #ifdef _POSIX_USERS |
---|
32 | #include <pwd.h> |
---|
33 | #include <grp.h> |
---|
34 | #endif |
---|
35 | |
---|
36 | #include <sys/time.h> |
---|
37 | #include <time.h> |
---|
38 | |
---|
39 | #ifdef ROAR_HAVE_LIBM |
---|
40 | #include <math.h> |
---|
41 | #endif |
---|
42 | |
---|
43 | int g_verbose = 0; |
---|
44 | |
---|
45 | int display_mixer (struct roar_connection * con, int stream); |
---|
46 | int show_meta_all (struct roar_connection * con, int id); |
---|
47 | |
---|
48 | void usage (void) { |
---|
49 | printf("roarctl [OPTIONS]... COMMAND [OPTS] [COMMAND [OPTS] [COMMAND [OPTS] [...]]]\n"); |
---|
50 | |
---|
51 | printf("\nOptions:\n\n"); |
---|
52 | |
---|
53 | printf(" --server SERVER - Set server hostname\n" |
---|
54 | " --help - Show this help\n" |
---|
55 | " --verbose -v - Show verbose output\n" |
---|
56 | ); |
---|
57 | |
---|
58 | printf("\nCommands:\n\n"); |
---|
59 | printf( |
---|
60 | " help - Show this help\n" |
---|
61 | " sleep TIME - Sleeps for TIME seconds\n" |
---|
62 | #ifdef ROAR_HAVE_GETTIMEOFDAY |
---|
63 | " ping NUM - Do NUM pings using NOOP commands\n" |
---|
64 | #endif |
---|
65 | " whoami - Get own client ID\n" |
---|
66 | "\n" |
---|
67 | " standby, off - Go into standby mode\n" |
---|
68 | " resume, on - Go into active mode\n" |
---|
69 | " standbymode - Show current standby mode\n" |
---|
70 | " exit - Quits the roard (must be used as last command)\n" |
---|
71 | " terminate - Like exit but let the server up to serve still connected clients,\n" |
---|
72 | " new clients cann't connect and the server terminates after the last\n" |
---|
73 | " client disconnected\n" |
---|
74 | "\n" |
---|
75 | " volume ID CHAN V0 V1... - Sets volume for stream ID\n" |
---|
76 | " CHAN is the number of channels or 'mono' or 'stereo'\n" |
---|
77 | " if mono or stereo is chosen roarctl trys to set\n" |
---|
78 | " sensfull values for all channels even if the output\n" |
---|
79 | " is has more channels.\n" |
---|
80 | " all other args are the volumes of the channels\n" |
---|
81 | " you may use integer or percent values.\n" |
---|
82 | " percent values can flooding points.\n" |
---|
83 | "\n" |
---|
84 | " flag ID FLAGS - Sets flags FLAGS on stream ID. FLAGS may be a comma\n" |
---|
85 | " seperated list of flags.\n" |
---|
86 | " unflag ID FLAGS - Unsets flags on a stream. See flag.\n" |
---|
87 | "\n" |
---|
88 | " kick TYPE ID - Kicks object of TYPE with id ID\n" |
---|
89 | " Types: client stream sample source\n" |
---|
90 | " newvirtual P D E R B C - Adds a new virtual (child) stream\n" |
---|
91 | " Parameters:\n" |
---|
92 | " P: Parent stream ID, D: Direction,\n" |
---|
93 | " E: codEc, R: sample Rate,\n" |
---|
94 | " B: bits per sample, C: nummer of channels\n" |
---|
95 | "\n" |
---|
96 | " metaget ID TYPE - Read meta date of type TYPE from stream ID\n" |
---|
97 | // TODO: document metaset here. |
---|
98 | " metasave ID FILE - Saves meta data of stream ID to file FILE\n" |
---|
99 | " metaload ID FILE - Loads meta data from file FILE and set it on stream ID\n" |
---|
100 | "\n" |
---|
101 | " serveroinfo - Gets Informations about server output\n" |
---|
102 | " listclients - Gets Informations about clients\n" |
---|
103 | " liststreams - Gets Informations about streams\n" |
---|
104 | " allinfo - Get all infos\n" |
---|
105 | ); |
---|
106 | } |
---|
107 | |
---|
108 | #ifdef ROAR_HAVE_GETTIMEOFDAY |
---|
109 | int ping (struct roar_connection * con, int num) { |
---|
110 | struct timeval try, ans; |
---|
111 | struct roar_message m; |
---|
112 | register int ret; |
---|
113 | int i; |
---|
114 | double cur, min = 3600*1000, max = 0, sum = 0; |
---|
115 | |
---|
116 | if ( num == 0 ) |
---|
117 | return 0; |
---|
118 | |
---|
119 | for (i = 0; i < num; i++) { |
---|
120 | m.cmd = ROAR_CMD_NOOP; |
---|
121 | m.datalen = 0; |
---|
122 | |
---|
123 | gettimeofday(&try, NULL); |
---|
124 | ret = roar_req(con, &m, NULL); |
---|
125 | gettimeofday(&ans, NULL); |
---|
126 | |
---|
127 | if ( ret == -1 ) |
---|
128 | return -1; |
---|
129 | |
---|
130 | while (ans.tv_sec > try.tv_sec) { |
---|
131 | ans.tv_sec--; |
---|
132 | ans.tv_usec += 1000000; |
---|
133 | } |
---|
134 | ans.tv_usec -= try.tv_usec; |
---|
135 | |
---|
136 | printf("Pong from server: seq=%i time=%.3fms\n", i, (cur = ans.tv_usec/1000.0)); |
---|
137 | |
---|
138 | sum += cur; |
---|
139 | if ( min > cur ) |
---|
140 | min = cur; |
---|
141 | if ( cur > max ) |
---|
142 | max = cur; |
---|
143 | |
---|
144 | if ( i != (num - 1) ) |
---|
145 | sleep(1); |
---|
146 | } |
---|
147 | |
---|
148 | printf("\n--- ping statistics ---\n"); |
---|
149 | printf("%i packets transmitted\n", i); |
---|
150 | printf("rtt min/avg/max = %.3f/%.3f/%.3f ms\n", min, sum/(double)i, max); |
---|
151 | |
---|
152 | return 0; |
---|
153 | } |
---|
154 | #endif |
---|
155 | |
---|
156 | void server_oinfo (struct roar_connection * con) { |
---|
157 | struct roar_stream s; |
---|
158 | |
---|
159 | if ( roar_server_oinfo(con, &s) == -1 ) { |
---|
160 | fprintf(stderr, "Error: can not get server output info\n"); |
---|
161 | return; |
---|
162 | } |
---|
163 | |
---|
164 | printf("Stream direction : %s\n", roar_dir2str(s.dir)); |
---|
165 | printf("Server Output rate : %i\n", s.info.rate); |
---|
166 | printf("Server Output bits : %i\n", s.info.bits); |
---|
167 | printf("Server Output channels: %i\n", s.info.channels); |
---|
168 | printf("Server Output codec : %i (%s%s)\n", s.info.codec, roar_codec2str(s.info.codec), |
---|
169 | s.info.codec == ROAR_CODEC_DEFAULT ? " native" : ""); |
---|
170 | // printf("Server Output rate: %i", s.info.rate); |
---|
171 | if ( g_verbose > 1 ) |
---|
172 | printf("Server Position : %lu S (%.3fs)\n", (unsigned long int) s.pos, (float)s.pos/(s.info.rate*s.info.channels)); |
---|
173 | } |
---|
174 | |
---|
175 | const char * proc_name (pid_t pid) { |
---|
176 | static char ret[80] = "?"; |
---|
177 | #ifdef __linux__ |
---|
178 | char file[80], buf[80], *r; |
---|
179 | int i; |
---|
180 | |
---|
181 | snprintf(file, 79, "/proc/%i/exe", pid); |
---|
182 | file[79] = 0; |
---|
183 | |
---|
184 | ret[0] = '?'; |
---|
185 | ret[1] = 0; |
---|
186 | |
---|
187 | if ( (i = readlink(file, buf, 79)) != -1 ) { |
---|
188 | buf[i] = 0; |
---|
189 | if ( (r = strrchr(buf, '/')) != NULL ) { |
---|
190 | r++; |
---|
191 | if ( *r != 0 ) |
---|
192 | strcpy(ret, r); |
---|
193 | } |
---|
194 | } |
---|
195 | #endif |
---|
196 | |
---|
197 | return ret; |
---|
198 | } |
---|
199 | |
---|
200 | void list_clients (struct roar_connection * con) { |
---|
201 | int i; |
---|
202 | int num; |
---|
203 | int h; |
---|
204 | int id[ROAR_CLIENTS_MAX]; |
---|
205 | char tmp[80]; |
---|
206 | int self_id; |
---|
207 | struct roar_client self_client; |
---|
208 | struct roar_client c; |
---|
209 | #ifdef _POSIX_USERS |
---|
210 | struct group * grp = NULL; |
---|
211 | struct passwd * pwd = NULL; |
---|
212 | #endif |
---|
213 | |
---|
214 | if ( (self_id = roar_get_clientid(con)) != -1 ) { |
---|
215 | if ( roar_get_client(con, &self_client, self_id) == -1 ) |
---|
216 | self_id = -1; |
---|
217 | } |
---|
218 | |
---|
219 | if ( (num = roar_list_clients(con, id, ROAR_CLIENTS_MAX)) == -1 ) { |
---|
220 | fprintf(stderr, "Error: can not get client list\n"); |
---|
221 | return; |
---|
222 | } |
---|
223 | |
---|
224 | for (i = 0; i < num; i++) { |
---|
225 | printf("client %i:\n", id[i]); |
---|
226 | if ( roar_get_client(con, &c, id[i]) == -1 ) { |
---|
227 | fprintf(stderr, "Error: can not get client info\n"); |
---|
228 | continue; |
---|
229 | } |
---|
230 | printf("Client name : %s\n", c.name); |
---|
231 | |
---|
232 | if ( roar_nnode_get_socktype(&(c.nnode)) != ROAR_SOCKET_TYPE_UNKNOWN ) { |
---|
233 | if ( roar_nnode_to_str(&(c.nnode), tmp, 80) == 0 ) { |
---|
234 | printf("Client network node : %s\n", tmp); |
---|
235 | } |
---|
236 | } |
---|
237 | |
---|
238 | if ( self_id != -1 && roar_nnode_cmp(&(self_client.nnode), &(c.nnode)) == 0 ) { |
---|
239 | printf("Client PID : %i(%s)\n", c.pid, proc_name(c.pid)); |
---|
240 | } else { |
---|
241 | printf("Client PID : %i\n", c.pid); |
---|
242 | } |
---|
243 | if ( c.uid != -1 ) { |
---|
244 | #ifdef _POSIX_USERS |
---|
245 | if ( self_id != -1 && roar_nnode_cmp(&(self_client.nnode), &(c.nnode)) == 0 ) { |
---|
246 | pwd = getpwuid(c.uid); |
---|
247 | grp = getgrgid(c.gid); |
---|
248 | printf("Client UID/GID : %i(%s)/%i(%s)\n", c.uid, pwd ? pwd->pw_name : "?", c.gid, grp ? grp->gr_name : "?"); |
---|
249 | } else { |
---|
250 | #else |
---|
251 | if ( 1 ) { |
---|
252 | #endif |
---|
253 | printf("Client UID/GID : %i/%i\n", c.uid, c.gid); |
---|
254 | } |
---|
255 | } |
---|
256 | |
---|
257 | if ( g_verbose && c.proto != ROAR_PROTO_NONE ) { |
---|
258 | printf("Client Protocol : %s\n", roar_proto2str(c.proto)); |
---|
259 | } |
---|
260 | |
---|
261 | if ( g_verbose && c.byteorder != ROAR_BYTEORDER_UNKNOWN ) { |
---|
262 | if ( c.byteorder == ROAR_BYTEORDER_NETWORK ) { |
---|
263 | strcpy(tmp, " (network byteorder"); |
---|
264 | } else { |
---|
265 | *tmp = 0; |
---|
266 | } |
---|
267 | |
---|
268 | if ( c.byteorder == ROAR_BYTEORDER_NATIVE ) { |
---|
269 | if ( *tmp ) { |
---|
270 | strcat(tmp, ", native"); |
---|
271 | } else { |
---|
272 | strcpy(tmp, " (native"); |
---|
273 | } |
---|
274 | } |
---|
275 | |
---|
276 | if ( *tmp ) |
---|
277 | strcat(tmp, ")"); |
---|
278 | |
---|
279 | printf("Client Byteorder : %s%s\n", roar_byteorder2str(c.byteorder), tmp); |
---|
280 | } |
---|
281 | |
---|
282 | if ( c.execed != -1 ) |
---|
283 | printf("Execed stream : %i\n", c.execed); |
---|
284 | |
---|
285 | for (h = 0; h < ROAR_CLIENTS_MAX_STREAMS_PER_CLIENT; h++) |
---|
286 | if ( c.streams[h] != -1 ) |
---|
287 | printf("stream : %i\n", c.streams[h]); |
---|
288 | } |
---|
289 | |
---|
290 | } |
---|
291 | |
---|
292 | void list_streams (struct roar_connection * con) { |
---|
293 | int i; |
---|
294 | int num; |
---|
295 | int id[ROAR_STREAMS_MAX]; |
---|
296 | struct roar_stream s; |
---|
297 | struct roar_stream_info info; |
---|
298 | char flags[1024]; |
---|
299 | char name[1024]; |
---|
300 | char * infotext; |
---|
301 | |
---|
302 | |
---|
303 | if ( (num = roar_list_streams(con, id, ROAR_STREAMS_MAX)) == -1 ) { |
---|
304 | fprintf(stderr, "Error: can not get stream list\n"); |
---|
305 | return; |
---|
306 | } |
---|
307 | |
---|
308 | for (i = 0; i < num; i++) { |
---|
309 | printf("stream %i:\n", id[i]); |
---|
310 | if ( roar_get_stream(con, &s, id[i]) == -1 ) { |
---|
311 | fprintf(stderr, "Error: can not get stream info\n"); |
---|
312 | continue; |
---|
313 | } |
---|
314 | printf("Stream direction : %s\n", roar_dir2str(s.dir)); |
---|
315 | |
---|
316 | if ( roar_stream_get_name(con, &s, name, 1024) == 0 ) |
---|
317 | printf("Stream name : %s\n", name); |
---|
318 | |
---|
319 | if ( s.pos_rel_id == -1 ) { |
---|
320 | printf("Relativ position id : none (stream not synchronized)\n"); |
---|
321 | } else if ( s.pos_rel_id == id[i] ) { |
---|
322 | printf("Relativ position id : %i (self synchronized)\n", s.pos_rel_id); |
---|
323 | } else { |
---|
324 | printf("Relativ position id : %i (synchronized)\n", s.pos_rel_id); |
---|
325 | } |
---|
326 | if ( g_verbose > 1 ) { |
---|
327 | if ( s.info.rate && s.info.channels ) { |
---|
328 | printf("Position : %lu S (%.3fs)\n", (unsigned long int) s.pos, |
---|
329 | (float)s.pos/(s.info.rate*s.info.channels)); |
---|
330 | } else { |
---|
331 | printf("Position : %lu S\n", (unsigned long int) s.pos); |
---|
332 | } |
---|
333 | } |
---|
334 | |
---|
335 | switch (s.dir) { |
---|
336 | case ROAR_DIR_MIDI_IN: |
---|
337 | case ROAR_DIR_MIDI_OUT: |
---|
338 | infotext = " ticks/s"; |
---|
339 | break; |
---|
340 | case ROAR_DIR_LIGHT_IN: |
---|
341 | case ROAR_DIR_LIGHT_OUT: |
---|
342 | infotext = " updates/s"; |
---|
343 | break; |
---|
344 | default: |
---|
345 | infotext = " Hz"; |
---|
346 | } |
---|
347 | if ( s.info.rate ) |
---|
348 | printf("Stream sample rate : %i%s\n", s.info.rate, infotext); |
---|
349 | if ( s.info.bits ) |
---|
350 | printf("Stream bits : %i\n", s.info.bits); |
---|
351 | if ( s.info.channels ) |
---|
352 | printf("Stream channels : %i\n", s.info.channels); |
---|
353 | |
---|
354 | printf("Stream codec : %2i (%s%s)\n", s.info.codec, roar_codec2str(s.info.codec), |
---|
355 | s.info.codec == ROAR_CODEC_DEFAULT ? " native" : ""); |
---|
356 | if ( roar_stream_get_info(con, &s, &info) != -1 ) { |
---|
357 | if ( info.codec != s.info.codec ) { |
---|
358 | printf("Streamed codec : %2i (%s%s)\n", info.codec, roar_codec2str(info.codec), |
---|
359 | info.codec == ROAR_CODEC_DEFAULT ? " native" : ""); |
---|
360 | } |
---|
361 | |
---|
362 | if ( g_verbose ) { |
---|
363 | if ( info.block_size ) |
---|
364 | printf("Stream block size : %i Byte\n", info.block_size); |
---|
365 | |
---|
366 | printf("Underruns pre/post : %i/%i\n", info.pre_underruns, info.post_underruns); |
---|
367 | if ( g_verbose > 1 ) |
---|
368 | printf("Stream delay : %ims\n", (int)info.delay/1000); |
---|
369 | |
---|
370 | if ( g_verbose > 1 ) |
---|
371 | printf("Stream state : %s\n", roar_streamstate2str(info.state)); |
---|
372 | |
---|
373 | *flags = 0; |
---|
374 | if ( info.flags & ROAR_FLAG_PRIMARY ) |
---|
375 | strcat(flags, "primary "); |
---|
376 | if ( info.flags & ROAR_FLAG_SYNC ) |
---|
377 | strcat(flags, "sync "); |
---|
378 | if ( info.flags & ROAR_FLAG_OUTPUT ) |
---|
379 | strcat(flags, "output "); |
---|
380 | if ( info.flags & ROAR_FLAG_SOURCE ) |
---|
381 | strcat(flags, "source "); |
---|
382 | if ( info.flags & ROAR_FLAG_META ) |
---|
383 | strcat(flags, "meta "); |
---|
384 | if ( info.flags & ROAR_FLAG_AUTOCONF ) |
---|
385 | strcat(flags, "autoconf "); |
---|
386 | if ( info.flags & ROAR_FLAG_CLEANMETA ) |
---|
387 | strcat(flags, "cleanmeta "); |
---|
388 | if ( info.flags & ROAR_FLAG_HWMIXER ) |
---|
389 | strcat(flags, "hwmixer "); |
---|
390 | if ( info.flags & ROAR_FLAG_PAUSE ) |
---|
391 | strcat(flags, "pause "); |
---|
392 | if ( info.flags & ROAR_FLAG_MUTE ) |
---|
393 | strcat(flags, "mute "); |
---|
394 | if ( info.flags & ROAR_FLAG_MMAP ) |
---|
395 | strcat(flags, "mmap "); |
---|
396 | if ( info.flags & ROAR_FLAG_ANTIECHO ) |
---|
397 | strcat(flags, "antiecho "); |
---|
398 | if ( info.flags & ROAR_FLAG_VIRTUAL ) |
---|
399 | strcat(flags, "virtual "); |
---|
400 | if ( info.flags & ROAR_FLAG_RECSOURCE ) |
---|
401 | strcat(flags, "recsource "); |
---|
402 | if ( info.flags & ROAR_FLAG_PASSMIXER ) |
---|
403 | strcat(flags, "passmixer "); |
---|
404 | if ( info.flags & ROAR_FLAG_PRETHRU ) |
---|
405 | strcat(flags, "prethru "); |
---|
406 | if ( info.flags & ROAR_FLAG_IMMUTABLE ) |
---|
407 | strcat(flags, "immutable "); |
---|
408 | if ( info.flags & ROAR_FLAG_ENHANCE ) |
---|
409 | strcat(flags, "enhance "); |
---|
410 | |
---|
411 | printf("Flags : %s\n", flags); |
---|
412 | } |
---|
413 | } |
---|
414 | |
---|
415 | if ( s.dir != ROAR_DIR_THRU ) { |
---|
416 | display_mixer(con, id[i]); |
---|
417 | show_meta_all(con, id[i]); |
---|
418 | } |
---|
419 | } |
---|
420 | |
---|
421 | } |
---|
422 | |
---|
423 | int display_mixer (struct roar_connection * con, int stream) { |
---|
424 | int channels; |
---|
425 | struct roar_mixer_settings mixer; |
---|
426 | int i; |
---|
427 | |
---|
428 | if ( roar_get_vol(con, stream, &mixer, &channels) == -1 ) { |
---|
429 | fprintf(stderr, "Error: can not get stream mixer info\n"); |
---|
430 | return -1; |
---|
431 | } |
---|
432 | |
---|
433 | #ifdef ROAR_HAVE_LIBM |
---|
434 | #define _DB ", %.2fdB" |
---|
435 | #else |
---|
436 | #define _DB "" |
---|
437 | #endif |
---|
438 | |
---|
439 | for (i = 0; i < channels; i++) |
---|
440 | printf("Mixer volume chan %2i : %i (%.2f%%" _DB ")\n", i, mixer.mixer[i], |
---|
441 | (float)mixer.mixer[i]/655.35f |
---|
442 | #ifdef ROAR_HAVE_LIBM |
---|
443 | , 20*log10f((float)mixer.mixer[i]/65535.f) |
---|
444 | #endif |
---|
445 | ); |
---|
446 | |
---|
447 | return 0; |
---|
448 | } |
---|
449 | |
---|
450 | static unsigned int set_mixer_parse_volume (char * k, int len) { |
---|
451 | switch (k[len - 1]) { |
---|
452 | case '%': |
---|
453 | k[len - 1] = 0; |
---|
454 | return (atof(k)*65535.f)/100; |
---|
455 | break; |
---|
456 | #ifdef ROAR_HAVE_LIBM |
---|
457 | case 'b': |
---|
458 | case 'B': |
---|
459 | // TODO: can we hanle the error better? |
---|
460 | if ( len < 2 ) |
---|
461 | return 0; |
---|
462 | |
---|
463 | k[len - 2] = 0; |
---|
464 | return powf(10, atof(k)/20.f)*65535.f; |
---|
465 | break; |
---|
466 | #endif |
---|
467 | } |
---|
468 | |
---|
469 | return atoi(k); |
---|
470 | } |
---|
471 | |
---|
472 | int set_mixer (struct roar_connection * con, int * cur, int max, char * arg[]) { |
---|
473 | int chans = 0; |
---|
474 | int id; |
---|
475 | int i; |
---|
476 | int len; |
---|
477 | int old_chans; |
---|
478 | int vol_l, vol_r, vol_mono; |
---|
479 | char * k; |
---|
480 | struct roar_mixer_settings mixer; |
---|
481 | struct roar_mixer_settings old_mixer; |
---|
482 | |
---|
483 | if (*cur + 2 > max) |
---|
484 | return -1; |
---|
485 | |
---|
486 | id = atoi(arg[++(*cur)]); |
---|
487 | |
---|
488 | k = arg[++(*cur)]; |
---|
489 | |
---|
490 | if ( roar_get_vol(con, id, &old_mixer, &old_chans) == -1 ) { |
---|
491 | fprintf(stderr, "Error: can not get stream mixer info\n"); |
---|
492 | return -1; |
---|
493 | } |
---|
494 | |
---|
495 | |
---|
496 | // TODO: clean up code here as the % vs. abs code is very duplicate... |
---|
497 | |
---|
498 | if ( strcmp(k, "mono") == 0 && old_chans != 1 ) { |
---|
499 | chans = 1; |
---|
500 | |
---|
501 | if ( *cur + 1 > max ) |
---|
502 | return -1; |
---|
503 | |
---|
504 | k = arg[++(*cur)]; |
---|
505 | len = strlen(k); |
---|
506 | |
---|
507 | vol_mono = set_mixer_parse_volume(k, len); |
---|
508 | |
---|
509 | for (i = 0; i < old_chans; i++) |
---|
510 | mixer.mixer[i] = vol_mono; |
---|
511 | |
---|
512 | chans = old_chans; |
---|
513 | |
---|
514 | } else if ( strcmp(k, "stereo") == 0 && old_chans != 2 ) { |
---|
515 | chans = old_chans; |
---|
516 | |
---|
517 | if ( *cur + 2 > max ) |
---|
518 | return -1; |
---|
519 | |
---|
520 | k = arg[++(*cur)]; |
---|
521 | len = strlen(k); |
---|
522 | |
---|
523 | vol_l = set_mixer_parse_volume(k, len); |
---|
524 | |
---|
525 | k = arg[++(*cur)]; |
---|
526 | len = strlen(k); |
---|
527 | |
---|
528 | vol_r = set_mixer_parse_volume(k, len); |
---|
529 | |
---|
530 | vol_mono = (vol_l + vol_r) / 2; |
---|
531 | |
---|
532 | mixer.mixer[0] = vol_l; |
---|
533 | mixer.mixer[1] = vol_r; |
---|
534 | |
---|
535 | switch (chans) { |
---|
536 | case 1: |
---|
537 | mixer.mixer[0] = vol_mono; |
---|
538 | break; |
---|
539 | // case 2: classic stereo... |
---|
540 | case 3: |
---|
541 | mixer.mixer[2] = vol_mono; |
---|
542 | break; |
---|
543 | case 4: |
---|
544 | mixer.mixer[2] = vol_l; |
---|
545 | mixer.mixer[3] = vol_r; |
---|
546 | break; |
---|
547 | case 5: |
---|
548 | mixer.mixer[2] = vol_mono; |
---|
549 | mixer.mixer[3] = vol_l; |
---|
550 | mixer.mixer[4] = vol_r; |
---|
551 | break; |
---|
552 | case 6: |
---|
553 | mixer.mixer[2] = vol_mono; |
---|
554 | mixer.mixer[3] = vol_mono; |
---|
555 | mixer.mixer[4] = vol_l; |
---|
556 | mixer.mixer[5] = vol_r; |
---|
557 | break; |
---|
558 | default: |
---|
559 | ROAR_ERR("mode stereo not supported on stream with %i channels", chans); |
---|
560 | return -1; |
---|
561 | break; |
---|
562 | } |
---|
563 | |
---|
564 | } else { |
---|
565 | if ( strcmp(k, "mono") == 0 ) { |
---|
566 | chans = 1; |
---|
567 | } else if ( strcmp(k, "stereo") == 0 ) { |
---|
568 | chans = 2; |
---|
569 | } else { |
---|
570 | chans = atoi(k); |
---|
571 | } |
---|
572 | |
---|
573 | // printf("mode: int; chans=%i, old_chans=%i\n", chans, old_chans); |
---|
574 | |
---|
575 | if ( *cur + chans > max ) |
---|
576 | return -1; |
---|
577 | |
---|
578 | for (i = 0; i < chans; i++) { |
---|
579 | k = arg[++(*cur)]; |
---|
580 | len = strlen(k); |
---|
581 | |
---|
582 | mixer.mixer[i] = set_mixer_parse_volume(k, len); |
---|
583 | } |
---|
584 | } |
---|
585 | |
---|
586 | mixer.scale = 65535; |
---|
587 | |
---|
588 | return roar_set_vol(con, id, &mixer, chans); |
---|
589 | } |
---|
590 | |
---|
591 | |
---|
592 | int newvirtual (struct roar_connection * con, char *p_s, char *d_s, char *e_s, char *r_s, char *b_s, char *c_s) { |
---|
593 | struct roar_stream s; |
---|
594 | int dir = roar_str2dir(d_s); |
---|
595 | int parent = atoi(p_s); |
---|
596 | |
---|
597 | ROAR_DBG("newvirtual(*): dir=%i, parent=%i", dir, parent); |
---|
598 | |
---|
599 | if ( roar_stream_new(&s, atoi(r_s), atoi(c_s), atoi(b_s), roar_str2codec(e_s)) == -1 ) |
---|
600 | return -1; |
---|
601 | |
---|
602 | return roar_simple_connect_virtual(con, &s, parent, dir); |
---|
603 | } |
---|
604 | |
---|
605 | int set_meta (struct roar_connection * con, int id, char * mode, char * type, char * val) { |
---|
606 | struct roar_meta meta; |
---|
607 | struct roar_stream s; |
---|
608 | int mode_i = ROAR_META_MODE_SET; |
---|
609 | |
---|
610 | memset(&s, 0, sizeof(s)); |
---|
611 | |
---|
612 | s.id = id; |
---|
613 | |
---|
614 | // printf("set_meta(*): mode='%s', type='%s', val='%s'\n", mode, type, val); |
---|
615 | |
---|
616 | if ( strcmp(mode, "add") == 0 ) { |
---|
617 | mode_i = ROAR_META_MODE_ADD; |
---|
618 | } |
---|
619 | |
---|
620 | meta.type = roar_meta_inttype(type); |
---|
621 | meta.value = val; |
---|
622 | meta.key[0] = 0; |
---|
623 | |
---|
624 | if ( meta.type == -1 ) { |
---|
625 | fprintf(stderr, "Error: unknown type: %s\n", type); |
---|
626 | return -1; |
---|
627 | } |
---|
628 | |
---|
629 | // printf("D: type=%i, mode=%i\n", meta.type, mode_i); |
---|
630 | |
---|
631 | if ( roar_stream_meta_set(con, &s, mode_i, &meta) == -1 ) |
---|
632 | return -1; |
---|
633 | |
---|
634 | meta.type = ROAR_META_TYPE_NONE; |
---|
635 | meta.value = NULL; |
---|
636 | |
---|
637 | return roar_stream_meta_set(con, &s, ROAR_META_MODE_FINALIZE, &meta); |
---|
638 | } |
---|
639 | |
---|
640 | int load_meta (struct roar_connection * con, int id, char * file) { |
---|
641 | struct roar_meta meta; |
---|
642 | struct roar_stream s; |
---|
643 | int mode_i = ROAR_META_MODE_SET; |
---|
644 | FILE * in; |
---|
645 | char lion[1024]; |
---|
646 | char * v; |
---|
647 | |
---|
648 | memset(&s, 0, sizeof(s)); |
---|
649 | |
---|
650 | s.id = id; |
---|
651 | |
---|
652 | if ( (in = fopen(file, "r")) == NULL ) |
---|
653 | return -1; |
---|
654 | |
---|
655 | while (fgets(lion, 1024, in) != NULL) { |
---|
656 | if ( (v = strtok(lion, "\r\n")) != NULL ) |
---|
657 | if ( (v = strtok(NULL, "\r\n")) != NULL ) |
---|
658 | *(v-1) = 0; |
---|
659 | |
---|
660 | if ( (v = strstr(lion, "=")) == NULL ) { |
---|
661 | fprintf(stderr, "Error: can not parse meta data lion: %s\n", lion); |
---|
662 | continue; |
---|
663 | } |
---|
664 | |
---|
665 | *v++ = 0; |
---|
666 | |
---|
667 | meta.type = roar_meta_inttype(lion); |
---|
668 | meta.value = v; |
---|
669 | meta.key[0] = 0; |
---|
670 | |
---|
671 | if ( meta.type == -1 ) { |
---|
672 | fprintf(stderr, "Error: unknown type: %s\n", lion); |
---|
673 | continue; |
---|
674 | } |
---|
675 | |
---|
676 | if ( roar_stream_meta_set(con, &s, mode_i, &meta) == -1 ) |
---|
677 | return -1; |
---|
678 | } |
---|
679 | |
---|
680 | fclose(in); |
---|
681 | |
---|
682 | meta.type = ROAR_META_TYPE_NONE; |
---|
683 | meta.value = NULL; |
---|
684 | |
---|
685 | return roar_stream_meta_set(con, &s, ROAR_META_MODE_FINALIZE, &meta); |
---|
686 | } |
---|
687 | |
---|
688 | int show_meta_type (struct roar_connection * con, int id, char * type) { |
---|
689 | struct roar_meta meta; |
---|
690 | struct roar_stream s; |
---|
691 | |
---|
692 | memset(&s, 0, sizeof(s)); |
---|
693 | |
---|
694 | s.id = id; |
---|
695 | |
---|
696 | meta.type = roar_meta_inttype(type); |
---|
697 | |
---|
698 | if ( meta.type == -1 ) { |
---|
699 | fprintf(stderr, "Error: unknown type: %s\n", type); |
---|
700 | return -1; |
---|
701 | } |
---|
702 | |
---|
703 | if ( roar_stream_meta_get(con, &s, &meta) == -1 ) |
---|
704 | return -1; |
---|
705 | |
---|
706 | printf("Meta %-17s: %s\n", roar_meta_strtype(meta.type), meta.value); |
---|
707 | |
---|
708 | roar_meta_free(&meta); |
---|
709 | |
---|
710 | return 0; |
---|
711 | } |
---|
712 | |
---|
713 | int show_meta_all (struct roar_connection * con, int id) { |
---|
714 | struct roar_stream s; |
---|
715 | int types[ROAR_META_MAX_PER_STREAM]; |
---|
716 | int i; |
---|
717 | int len; |
---|
718 | |
---|
719 | memset(&s, 0, sizeof(s)); |
---|
720 | |
---|
721 | s.id = id; |
---|
722 | |
---|
723 | if ( (len = roar_stream_meta_list(con, &s, types, ROAR_META_MAX_PER_STREAM)) == -1 ) |
---|
724 | return -1; |
---|
725 | |
---|
726 | for (i = 0; i < len; i++) |
---|
727 | show_meta_type(con, id, roar_meta_strtype(types[i])); |
---|
728 | |
---|
729 | return 0; |
---|
730 | } |
---|
731 | |
---|
732 | int save_meta (struct roar_connection * con, int id, char * file) { |
---|
733 | struct roar_stream s; |
---|
734 | struct roar_meta meta; |
---|
735 | int types[ROAR_META_MAX_PER_STREAM]; |
---|
736 | int i; |
---|
737 | int len; |
---|
738 | FILE * out; |
---|
739 | |
---|
740 | memset(&s, 0, sizeof(s)); |
---|
741 | |
---|
742 | s.id = id; |
---|
743 | |
---|
744 | if ( (out = fopen(file, "w")) == NULL ) |
---|
745 | return -1; |
---|
746 | |
---|
747 | if ( (len = roar_stream_meta_list(con, &s, types, ROAR_META_MAX_PER_STREAM)) == -1 ) |
---|
748 | return -1; |
---|
749 | |
---|
750 | for (i = 0; i < len; i++) { |
---|
751 | /* |
---|
752 | show_meta_type(con, id, roar_meta_strtype(types[i])); |
---|
753 | */ |
---|
754 | meta.type = types[i]; |
---|
755 | |
---|
756 | if ( roar_stream_meta_get(con, &s, &meta) == -1 ) |
---|
757 | continue; |
---|
758 | |
---|
759 | // printf("Meta %-17s: %s\n", roar_meta_strtype(meta.type), meta.value); |
---|
760 | |
---|
761 | fprintf(out, "%s=%s\n", roar_meta_strtype(meta.type), meta.value); |
---|
762 | |
---|
763 | roar_meta_free(&meta); |
---|
764 | } |
---|
765 | |
---|
766 | fclose(out); |
---|
767 | |
---|
768 | return 0; |
---|
769 | } |
---|
770 | |
---|
771 | int set_flags (struct roar_connection * con, int id, int reset, char * flags) { |
---|
772 | int f = ROAR_FLAG_NONE; |
---|
773 | char * c; |
---|
774 | struct roar_stream s[1]; |
---|
775 | |
---|
776 | memset(s, 0, sizeof(struct roar_stream)); |
---|
777 | |
---|
778 | s->id = id; |
---|
779 | |
---|
780 | c = strtok(flags, ","); |
---|
781 | while (c != NULL) { |
---|
782 | if ( !strcmp(c, "meta") ) { |
---|
783 | f |= ROAR_FLAG_META; |
---|
784 | } else if ( !strcmp(c, "primary") ) { |
---|
785 | f |= ROAR_FLAG_PRIMARY; |
---|
786 | } else if ( !strcmp(c, "sync") ) { |
---|
787 | f |= ROAR_FLAG_SYNC; |
---|
788 | } else if ( !strcmp(c, "cleanmeta") ) { |
---|
789 | f |= ROAR_FLAG_CLEANMETA; |
---|
790 | } else if ( !strcmp(c, "hwmixer") ) { |
---|
791 | f |= ROAR_FLAG_HWMIXER; |
---|
792 | } else if ( !strcmp(c, "pause") ) { |
---|
793 | f |= ROAR_FLAG_PAUSE; |
---|
794 | } else if ( !strcmp(c, "mute") ) { |
---|
795 | f |= ROAR_FLAG_MUTE; |
---|
796 | } else if ( !strcmp(c, "mmap") ) { |
---|
797 | f |= ROAR_FLAG_MMAP; |
---|
798 | } else if ( !strcmp(c, "antiecho") ) { |
---|
799 | f |= ROAR_FLAG_ANTIECHO; |
---|
800 | } else if ( !strcmp(c, "recsource") ) { |
---|
801 | f |= ROAR_FLAG_RECSOURCE; |
---|
802 | } else if ( !strcmp(c, "passmixer") ) { |
---|
803 | f |= ROAR_FLAG_PASSMIXER; |
---|
804 | } else if ( !strcmp(c, "virtual") ) { |
---|
805 | f |= ROAR_FLAG_VIRTUAL; |
---|
806 | } else if ( !strcmp(c, "prethru") ) { |
---|
807 | f |= ROAR_FLAG_PRETHRU; |
---|
808 | } else if ( !strcmp(c, "immutable") ) { |
---|
809 | f |= ROAR_FLAG_IMMUTABLE; |
---|
810 | } else if ( !strcmp(c, "enhance") ) { |
---|
811 | f |= ROAR_FLAG_ENHANCE; |
---|
812 | } else { |
---|
813 | fprintf(stderr, "Error: unknown flag: %s\n", c); |
---|
814 | return -1; |
---|
815 | } |
---|
816 | |
---|
817 | c = strtok(NULL, ","); |
---|
818 | } |
---|
819 | |
---|
820 | return roar_stream_set_flags(con, s, f, reset); |
---|
821 | } |
---|
822 | |
---|
823 | int main (int argc, char * argv[]) { |
---|
824 | struct roar_connection con; |
---|
825 | char * server = NULL; |
---|
826 | char * k = NULL; |
---|
827 | int i; |
---|
828 | int t = 0; |
---|
829 | |
---|
830 | for (i = 1; i < argc; i++) { |
---|
831 | k = argv[i]; |
---|
832 | |
---|
833 | if ( strcmp(k, "--server") == 0 ) { |
---|
834 | server = argv[++i]; |
---|
835 | } else if ( strcmp(k, "-v") == 0 || strcmp(k, "--verbose") == 0 ) { |
---|
836 | g_verbose++; |
---|
837 | } else if ( strcmp(k, "--help") == 0 ) { |
---|
838 | usage(); |
---|
839 | return 0; |
---|
840 | } else if ( *k == '-' ) { |
---|
841 | fprintf(stderr, "Error: unknown argument: %s\n", k); |
---|
842 | usage(); |
---|
843 | return 1; |
---|
844 | } else { |
---|
845 | break; |
---|
846 | } |
---|
847 | } |
---|
848 | |
---|
849 | // connect |
---|
850 | |
---|
851 | if ( roar_connect(&con, server) == -1 ) { |
---|
852 | fprintf(stderr, "Error: Can not connect to server\n"); |
---|
853 | return 1; |
---|
854 | } |
---|
855 | |
---|
856 | if ( roar_identify(&con, "roarctl") == -1 ) { |
---|
857 | fprintf(stderr, "Error: Can not identify to server\n"); |
---|
858 | return 1; |
---|
859 | } |
---|
860 | |
---|
861 | if ( i == argc ) { |
---|
862 | fprintf(stderr, "Error: No Commands given\n"); |
---|
863 | return 0; // this is not a fatal error... |
---|
864 | } |
---|
865 | |
---|
866 | for (; i < argc; i++) { |
---|
867 | k = argv[i]; |
---|
868 | // cmd is in k |
---|
869 | |
---|
870 | printf("--- [ %s ] ---\n", k); |
---|
871 | |
---|
872 | if ( !strcmp(k, "help") ) { |
---|
873 | usage(); |
---|
874 | |
---|
875 | } else if ( !strcmp(k, "sleep") ) { |
---|
876 | sleep(atoi(argv[++i])); |
---|
877 | |
---|
878 | } else if ( !strcmp(k, "ping") ) { |
---|
879 | #ifdef ROAR_HAVE_GETTIMEOFDAY |
---|
880 | if ( ping(&con, atoi(argv[++i])) == -1 ) { |
---|
881 | fprintf(stderr, "Error: can not ping\n"); |
---|
882 | } |
---|
883 | #else |
---|
884 | fprintf(stderr, "Error: ping not supported.\n"); |
---|
885 | i++; |
---|
886 | #endif |
---|
887 | |
---|
888 | } else if ( !strcmp(k, "standby") || !strcmp(k, "off") ) { |
---|
889 | if ( roar_set_standby(&con, ROAR_STANDBY_ACTIVE) == -1 ) { |
---|
890 | fprintf(stderr, "Error: can not set mode to standby\n"); |
---|
891 | } else { |
---|
892 | printf("going into standby\n"); |
---|
893 | } |
---|
894 | } else if ( !strcmp(k, "resume") || !strcmp(k, "on") ) { |
---|
895 | if ( roar_set_standby(&con, ROAR_STANDBY_INACTIVE) == -1 ) { |
---|
896 | fprintf(stderr, "Error: can not set mode to active\n"); |
---|
897 | } else { |
---|
898 | printf("going into active mode\n"); |
---|
899 | } |
---|
900 | |
---|
901 | } else if ( !strcmp(k, "exit") ) { |
---|
902 | if ( roar_exit(&con) == -1 ) { |
---|
903 | fprintf(stderr, "Error: can not quit server\n"); |
---|
904 | } else { |
---|
905 | printf("Server quited\n"); |
---|
906 | break; |
---|
907 | } |
---|
908 | } else if ( !strcmp(k, "terminate") ) { |
---|
909 | if ( roar_terminate(&con, 1) == -1 ) { |
---|
910 | fprintf(stderr, "Error: can not terminate server\n"); |
---|
911 | } else { |
---|
912 | printf("Server got asked to quited\n"); |
---|
913 | break; |
---|
914 | } |
---|
915 | |
---|
916 | } else if ( !strcmp(k, "standbymode") ) { |
---|
917 | t = roar_get_standby(&con); |
---|
918 | if ( t == -1 ) { |
---|
919 | fprintf(stderr, "Error: can not get stanby mode\n"); |
---|
920 | } else if ( t == ROAR_STANDBY_ACTIVE ) { |
---|
921 | printf("Server is in standby\n"); |
---|
922 | } else if ( t == ROAR_STANDBY_INACTIVE ) { |
---|
923 | printf("Server is active\n"); |
---|
924 | } else { |
---|
925 | fprintf(stderr, "Error: unknown standby mode: %i\n", t); |
---|
926 | } |
---|
927 | |
---|
928 | } else if ( !strcmp(k, "whoami") ) { |
---|
929 | printf("My client ID is: %i\n", roar_get_clientid(&con)); |
---|
930 | } else if ( !strcmp(k, "serveroinfo") ) { |
---|
931 | server_oinfo(&con); |
---|
932 | } else if ( !strcmp(k, "listclients") ) { |
---|
933 | list_clients(&con); |
---|
934 | } else if ( !strcmp(k, "liststreams") ) { |
---|
935 | list_streams(&con); |
---|
936 | } else if ( !strcmp(k, "allinfo") ) { |
---|
937 | server_oinfo(&con); |
---|
938 | printf("\n"); |
---|
939 | list_clients(&con); |
---|
940 | printf("\n"); |
---|
941 | list_streams(&con); |
---|
942 | |
---|
943 | } else if ( !strcmp(k, "kick") ) { |
---|
944 | k = argv[++i]; |
---|
945 | if ( !strcmp(k, "client") ) { |
---|
946 | t = ROAR_OT_CLIENT; |
---|
947 | } else if ( !strcmp(k, "stream") ) { |
---|
948 | t = ROAR_OT_STREAM; |
---|
949 | } else if ( !strcmp(k, "sample") ) { |
---|
950 | t = ROAR_OT_SAMPLE; |
---|
951 | } else if ( !strcmp(k, "source") ) { |
---|
952 | t = ROAR_OT_SOURCE; |
---|
953 | } else { |
---|
954 | fprintf(stderr, "Error: unknown type: %s\n", k); |
---|
955 | continue; |
---|
956 | } |
---|
957 | //t = atoi(argv[i++]); |
---|
958 | if ( roar_kick(&con, t, atoi(argv[++i])) == -1 ) { |
---|
959 | fprintf(stderr, "Error: can not kick %s\n", k); |
---|
960 | } else { |
---|
961 | printf("%s kicked\n", k); |
---|
962 | } |
---|
963 | |
---|
964 | } else if ( !strcmp(k, "newvirtual") ) { |
---|
965 | if ( newvirtual(&con, argv[i+1], argv[i+2], argv[i+3], argv[i+4], argv[i+5], argv[i+6]) == -1 ) { |
---|
966 | fprintf(stderr, "Error: can not create new virtual stream\n"); |
---|
967 | } else { |
---|
968 | printf("virtual stream created\n"); |
---|
969 | } |
---|
970 | i += 6; |
---|
971 | |
---|
972 | } else if ( !strcmp(k, "volume") ) { |
---|
973 | if ( set_mixer(&con, &i, argc, argv) == -1 ) { |
---|
974 | fprintf(stderr, "Error: can not set volume\n"); |
---|
975 | } else { |
---|
976 | printf("volume changed\n"); |
---|
977 | } |
---|
978 | |
---|
979 | } else if ( !strcmp(k, "flag") ) { |
---|
980 | i++; |
---|
981 | if ( set_flags(&con, atoi(argv[i]), ROAR_SET_FLAG, argv[i+1]) == -1 ) { |
---|
982 | fprintf(stderr, "Error: can not set flags\n"); |
---|
983 | } else { |
---|
984 | printf("flags changed\n"); |
---|
985 | } |
---|
986 | i++; |
---|
987 | } else if ( !strcmp(k, "unflag") ) { |
---|
988 | i++; |
---|
989 | if ( set_flags(&con, atoi(argv[i]), ROAR_RESET_FLAG, argv[i+1]) == -1 ) { |
---|
990 | fprintf(stderr, "Error: can not reset flags\n"); |
---|
991 | } else { |
---|
992 | printf("flags changed\n"); |
---|
993 | } |
---|
994 | i++; |
---|
995 | } else if ( !strcmp(k, "metaset") ) { |
---|
996 | i++; |
---|
997 | if ( set_meta(&con, atoi(argv[i]), argv[i+1], argv[i+2], argv[i+3]) == -1 ) { |
---|
998 | fprintf(stderr, "Error: can not set meta data\n"); |
---|
999 | } else { |
---|
1000 | printf("meta data changed\n"); |
---|
1001 | } |
---|
1002 | i += 3; |
---|
1003 | } else if ( !strcmp(k, "metaget") ) { |
---|
1004 | i++; |
---|
1005 | if ( show_meta_type(&con, atoi(argv[i]), argv[i+1]) == -1 ) { |
---|
1006 | fprintf(stderr, "Error: can not get meta data\n"); |
---|
1007 | } |
---|
1008 | i++; |
---|
1009 | } else if ( !strcmp(k, "metasave") ) { |
---|
1010 | i++; |
---|
1011 | if ( save_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) { |
---|
1012 | fprintf(stderr, "Error: can not get meta data\n"); |
---|
1013 | } else { |
---|
1014 | printf("meta data saved\n"); |
---|
1015 | } |
---|
1016 | i++; |
---|
1017 | } else if ( !strcmp(k, "metaload") ) { |
---|
1018 | i++; |
---|
1019 | if ( load_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) { |
---|
1020 | fprintf(stderr, "Error: can not set meta data\n"); |
---|
1021 | } else { |
---|
1022 | printf("meta data saved\n"); |
---|
1023 | } |
---|
1024 | i++; |
---|
1025 | |
---|
1026 | } else { |
---|
1027 | fprintf(stderr, "Error: invalid command: %s\n", k); |
---|
1028 | } |
---|
1029 | |
---|
1030 | } |
---|
1031 | |
---|
1032 | roar_disconnect(&con); |
---|
1033 | |
---|
1034 | return 0; |
---|
1035 | } |
---|
1036 | |
---|
1037 | //ll |
---|