Пример #1
0
/*
 * open & setup audio device
 * return: 1=success 0=fail
 */
static int init(int rate_hz, int channels, int format, int flags) {
 int codec = ROAR_CODEC_DEFAULT;
 int bits  = 16;

 if ( roar_simple_connect(&roar_con, NULL, ROAR_CLIENT_NAME) == -1 )
  return 0;

 switch (format) {
  case AF_FORMAT_S8:
   bits = 8;
   break;
  case AF_FORMAT_U8:
   bits  = 8;
   codec = ROAR_CODEC_PCM_U_LE;
   break;
 }

 if ( (roar_fh = roar_simple_new_stream_obj(&roar_con, &roar_stream, rate_hz, channels, bits, codec, ROAR_DIR_PLAY)) == -1 )
  return 0;

 if ( roar_stream_get_info(&roar_con, &roar_stream, &roar_info) == -1 ) {
  close(roar_fh);
  return 0;
 }

 roar_socket_nonblock(roar_fh, ROAR_SOCKET_NONBLOCK);

 return 1;
}
Пример #2
0
int main (int argc, char * argv[]) {
 int    rate     = 44100;
 int    bits     = 16;
 int    channels = 2;
 int    codec    = ROAR_CODEC_DEFAULT;
 char * server   = NULL;
 char * k;
 int    i;
 int    fh;
 char buf[BUFSIZE];
 struct roar_connection con;


 for (i = 1; i < argc; i++) {
  k = argv[i];

  if ( strcmp(k, "--server") == 0 ) {
   server = argv[++i];
  } else if ( strcmp(k, "--rate") == 0 ) {
   rate = atoi(argv[++i]);
  } else if ( strcmp(k, "--bits") == 0 ) {
   bits = atoi(argv[++i]);
  } else if ( strcmp(k, "--channels") == 0 ) {
   channels = atoi(argv[++i]);
  } else if ( strcmp(k, "--help") == 0 ) {
   usage();
   return 0;
  } else {
   fprintf(stderr, "Error: unknown argument: %s\n", k);
   usage();
   return 1;
  }
 }

 if ( roar_simple_connect(&con, server, "roarcat2sock") == -1 ) {
  ROAR_DBG("roar_simple_play(*): roar_simple_connect() faild!");
  return 1;
 }

 if ( (fh = roar_simple_new_stream(&con, rate, channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) {
  roar_disconnect(&con);
  return 1;
 }

 while((i = read(0, buf, BUFSIZE)))
  write(fh, buf, i);

 close(fh);

 roar_disconnect(&con);

 return 0;
}
Пример #3
0
roar_vs_t * roar_vs_new(const char * server, const char * name, int * error) {
    roar_vs_t * vss = roar_vs_init(error);
    int ret;

    if ( vss == NULL )
        return NULL;

    vss->con = &(vss->con_store);

    _initerr();

    ret = roar_simple_connect(vss->con, (char*)server, (char*)name);

    if ( ret == -1 ) {
        roar_vs_close(vss, ROAR_VS_TRUE, NULL);
        _seterrre();
        return NULL;
    }

    return vss;
}
Пример #4
0
int open_stream (struct roar_vio_calls * vio, char * server, struct roar_audio_info * info) {
 int fh;

 g_cons.svio = vio;

 if ( !(g_cons.state & CON_CON) )
  if ( roar_simple_connect(&(g_cons.con), server, "roarphone") == -1 )
   return -1;

 g_cons.state |= CON_CON;

 if ( (fh = roar_vio_simple_new_stream_obj(vio, &(g_cons.con), &(g_cons.stream),
                                           info->rate, info->channels, info->bits, info->codec,
                                           ROAR_DIR_BIDIR
                                          )) == -1 )
  return -1;

 g_cons.state |= CON_STREAM;

 return 0;
}
Пример #5
0
int main (int argc, char * argv[]) {
 char * server   = NULL;
 char * k;
 int    i;
 struct roar_connection con;

 for (i = 1; i < argc; i++) {
  k = argv[i];

  if ( !strcmp(k, "--server") || !strcmp(k, "-s") ) {
   server = argv[++i];
  } else if ( !strcmp(k, "--codec") ) {

  } else if ( !strcmp(k, "--help") || !strcmp(k, "-h") ) {
   usage();
   return 0;
  } else if ( *k == '-' ) {
   fprintf(stderr, "Error: unknown argument: %s\n", k);
   usage();
   return 1;
  } else {
   break;
  }
 }

 if ( roar_simple_connect(&con, server, "roarlight") == -1 ) {
  fprintf(stderr, "Error: Can not connect to server\n");
  return 1;
 }

 if ( i == argc ) {
  fprintf(stderr, "Error: No Commands given\n");
  return 0; // this is not a fatal error...
 }

 for (; i < argc; i++) {
  k = argv[i];
  // cmd is in k

  printf("--- [ %s ] ---\n", k);

  if ( !strcmp(k, "help") ) {
   usage();

  } else if ( !strcmp(k, "sleep") ) {
   sleep(atoi(argv[++i]));

  } else if ( !strcmp(k, "set") ) {
   i++;
   if ( cmd_set(&con, argv[i]) == -1 ) {
    fprintf(stderr, "Error: can not set channels\n");
   } else {
    printf("channels changed\n");
   }

  } else {
   fprintf(stderr, "Error: invalid command: %s\n", k);
  }
 }

 roar_disconnect(&con);

 return 0;
}
Пример #6
0
int main (int argc, char * argv[]) {
 int    rate     = 44100;
 int    bits     = 16;
 int    channels = 2;
 int    codec    = ROAR_CODEC_OGG_VORBIS;
 char * server   = NULL;
 char * k;
 int    i;
 int    in = -1;
 char * file = NULL;
 char * host;
 int    port;
 FILE * http;
 struct roar_connection con[1];
 struct roar_stream     stream[1];
 char buf0[80], buf1[80];
 int proto = P_UNKNOWN;

 for (i = 1; i < argc; i++) {
  k = argv[i];

  if ( strcmp(k, "--server") == 0 ) {
   server = argv[++i];
  } else if ( strcmp(k, "--rate") == 0 ) {
   rate = atoi(argv[++i]);
  } else if ( strcmp(k, "--bits") == 0 ) {
   bits = atoi(argv[++i]);
  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) {
   channels = atoi(argv[++i]);
  } else if ( strcmp(k, "--codec") == 0 ) {
   codec = roar_str2codec(argv[++i]);
  } else if ( strcmp(k, "--help") == 0 ) {
   usage();
   return 0;
  } else if ( file == NULL ) {
   file = argv[i];
  } else {
   fprintf(stderr, "Error: unknown argument: %s\n", k);
   usage();
   return 1;
  }
 }

 if ( file == NULL ) {
  file = "/dev/stdin";
  in   = ROAR_STDIN;
 } else {
  if ( strncmp(file, "http://", 7) == 0 ) {
   proto = P_HTTP;
   host  = file+7;
   port  = 80;
  } else if ( strncmp(file, "gopher://", 9) == 0 ) {
   proto = P_GOPHER;
   host  = file+9;
   port  = 70;
  } else {
   fprintf(stderr, "Error: unknown protocol: %s\n", file);
   return 20;
  }

  if ( proto == P_HTTP || proto == P_GOPHER ) {
   for (i = 0; host[i] != 0; i++) {
    if ( host[i] == ':' ) {
     port    = atoi(host+i+1); // atoi() ignores the rest after '/'
     host[i] = 0;
    } else if ( host[i] == '/' ) {
     file    = host+i;
     break;
    }
   }

   if ( !*file ) {
    file = "/";

    if ( (in = roar_socket_connect(host, port)) == -1 ) {
     ROAR_ERR("can not connect to remote server %s (port %i): %s", host, port, strerror(errno));
     return 0;
    }
   } else {
    *file = 0;

    if ( (in = roar_socket_connect(host, port)) == -1 ) {
     ROAR_ERR("can not connect to remote server %s (port %i): %s", host, port, strerror(errno));
     return 0;
    }

    *file = '/';
   }

   switch (proto) {
    case P_HTTP:
      if ( (http = fdopen(in, "r+")) == NULL ) {
       ROAR_ERR("can not create FILE* object: %s", strerror(errno));
       return 0;
      }

      fprintf(http, "GET %s HTTP/1.1\r\n", file);
      fprintf(http, "Host: %s\r\n", host);
      fprintf(http, "User-Agent: roarradio $Revision: 1.9 $\r\n");
      fprintf(http, "Connection: close\r\n");
      fprintf(http, "\r\n");
      fflush(http);

      if ( fscanf(http, "%79s %i %79s\n", buf0, &port, buf1) != 3 ) {
       ROAR_ERR("HTTP protocol error!, no initial HTTP/1.x-line!");
       return 1;
      }
      if ( port != 200 ) { // 200 = HTTP OK
       ROAR_ERR("HTTP Error: %i - %s", port, buf1);
       return 1;
      }

      *buf0 = 0;

      while (*buf0 != '\r' && *buf0 != '\n') {
       fgets(buf0, 80, http);
      }

      fflush(http);
     break;
    case P_GOPHER:
      if ( file[0] == 0 ) {
       file[0] = '/';
       file[1] = 0;
      } else if ( file[0] == '/' && file[1] != 0 && file[2] == '/' ) { // strip the type prefix
       file += 2;
      }
      // TODO: do some error checks here
      write(in, file, strlen(file));
      write(in, "\r\n", 2);
      ROAR_SHUTDOWN(in, SHUT_WR);
     break;
   }
  } else {
   if ( (in = open(file, O_RDONLY, 0644)) == -1 ) {
    ROAR_ERR("can not open file: %s: %s", file, strerror(errno));
    return 1;
   }
  }
 }

 if ( in == -1 ) {
  ROAR_ERR("No open file, bad. This should not happen");
  return 1;
 }

 if ( roar_simple_connect(con, server, "roarradio") == -1 ) {
  ROAR_ERR("Can not connect to server");
  return 1;
 }

 if ( roar_stream_new(stream, rate, channels, bits, codec) == -1 ) {
  roar_disconnect(con);
  return 1;
 }

 if ( roar_stream_connect(con, stream, ROAR_DIR_PLAY) == -1 ) {
  roar_disconnect(con);
  return 1;
 }

 if ( roar_stream_passfh(con, stream, in) == -1 ) {
  roar_disconnect(con);
  return 1;
 }

 close(in);

 if ( roar_stream_attach_simple(con, stream, 0) == -1 ) {
  ROAR_ERR("Can not attach stream to server");
 }

 roar_disconnect(con);

 return 0;
}
Пример #7
0
int main (int argc, char * argv[]) {
 struct roar_connection    con;
 struct roar_client        client;
 char * server    = NULL;
 char * k;
 int    i;
 int    clientfh  = -1;
 int    cflags    = 0;
 int    flags     = 0;
 int    proto     = ROAR_PROTO_ROARAUDIO;
 int    byteorder = ROAR_BYTEORDER_NETWORK;
 int    mode      = ROAR_SOCKET_MODE_NONE;
 int    type      = ROAR_SOCKET_TYPE_UNKNOWN;
 char * host      = NULL;
 int    port      = -1;

 for (i = 1; i < argc; i++) {
  k = argv[i];

  if ( !strcmp(k, "--server") || !strcmp(k, "-s") ) {
   server = argv[++i];
  } else if ( !strcmp(k, "--stdin") ) {
   cflags |= F_STDIN;
  } else if ( !strcmp(k, "--stdout") ) {
   cflags |= F_STDOUT;
  } else if ( !strcmp(k, "--stderr") ) {
   cflags |= F_STDERR;
  } else if ( !strcmp(k, "--stdio") ) {
   cflags |= F_STDIN|F_STDOUT;
  } else if ( !strcmp(k, "--client-fh") ) {
   clientfh = atoi(argv[++i]);
  } else if ( !strcmp(k, "--proto") ) {
   proto = roar_str2proto(argv[++i]);
  } else if ( !strcmp(k, "--byteorder") ) {
   byteorder = roar_str2byteorder(argv[++i]);
  } else if ( !strcmp(k, "--listen") ) {
   flags |= ROAR_CLIENTPASS_FLAG_LISTEN;
  } else if ( !strcmp(k, "--mode") ) {
   k = argv[++i];
   if ( !strcasecmp(k, "none") ) {
    mode = ROAR_SOCKET_MODE_NONE;
   } else if ( !strcasecmp(k, "listen") ) {
    mode = ROAR_SOCKET_MODE_LISTEN;
    flags |= ROAR_CLIENTPASS_FLAG_LISTEN;
   } else if ( !strcasecmp(k, "connect") ) {
    mode = ROAR_SOCKET_MODE_CONNECT;
    flags -= ROAR_CLIENTPASS_FLAG_LISTEN;
   } else {
    ROAR_ERR("unknown mode: %s", k);
    return 1;
   }
  } else if ( !strcmp(k, "--bind") ) {
   host = argv[++i];
  } else if ( !strcmp(k, "--port") ) {
   port = atoi(argv[++i]);
  } else if ( !strcmp(k, "--help") || !strcmp(k, "-h") ) {
   usage();
   return 0;
  } else {
   ROAR_ERR("unknown argument: %s", k);
   usage();
   return 1;
  }
 }

 if ( cflags & F_STDERR ) {
#ifdef ROAR_HAVE_SYSLOG
  roar_debug_set_stderr_mode(ROAR_DEBUG_MODE_SYSLOG);
#else
  roar_debug_set_stderr_fh(-1);
#endif
 } else {
  roar_debug_set_stderr_fh(ROAR_STDERR);
 }

 if ( mode != ROAR_SOCKET_MODE_NONE ) {
  if ( clientfh != -1 ) {
   ROAR_ERR("Too may socket types given");
   return 30;
  }

  clientfh = roar_socket_open(mode, type, host, port);

  if ( clientfh == -1 ) {
   ROAR_ERR("Unabled to open socket");
   return 31;
  }
 }

 if ( clientfh == -1 ) {
  if ( cflags & F_STDIN ) {
   clientfh = ROAR_STDIN;
  } else if ( cflags & F_STDOUT ) {
   clientfh = ROAR_STDOUT;
  } else if ( cflags & F_STDERR ) {
   clientfh = ROAR_STDERR;
  } else {
   ROAR_ERR("No client socket given");
   return 32;
  }
 }

 roar_client_new(&client);
 roar_client_set_fh(&client, clientfh);
 roar_client_set_proto(&client, proto, byteorder);

 if ( roar_simple_connect(&con, server, "roarclientpass") == -1 ) {
  ROAR_ERR("Can not connect to server");
  return 10;
 }

 if ( roar_client_pass(&con, &client, flags) == -1 ) {
  ROAR_ERR("Can not pass client fh to server");
  roar_disconnect(&con);
  return 20;
 }

 roar_disconnect(&con);

 return 0;
}
Пример #8
0
static bool
roar_open(void *data, struct audio_format *audio_format, GError **error)
{
	roar_t * self = data;
	g_mutex_lock(self->lock);

	if (roar_simple_connect(&(self->con), self->host, self->name) < 0)
	{
		g_set_error(error, roar_output_quark(), 0,
				"Failed to connect to Roar server");
		g_mutex_unlock(self->lock);
		return false;
	}

	self->vss = roar_vs_new_from_con(&(self->con), &(self->err));

	if (self->vss == NULL || self->err != ROAR_ERROR_NONE)
	{
		g_set_error(error, roar_output_quark(), 0,
				"Failed to connect to server");
		g_mutex_unlock(self->lock);
		return false;
	}

	self->info.rate = audio_format->sample_rate;
	self->info.channels = audio_format->channels;
	self->info.codec = ROAR_CODEC_PCM_S;

	switch (audio_format->format)
	{
		case SAMPLE_FORMAT_S8:
			self->info.bits = 8;
			break;
		case SAMPLE_FORMAT_S16:
			self->info.bits = 16;
			break;
		case SAMPLE_FORMAT_S24:
			self->info.bits = 24;
			break;
		case SAMPLE_FORMAT_S24_P32:
			self->info.bits = 32;
			audio_format->format = SAMPLE_FORMAT_S32;
			break;
		case SAMPLE_FORMAT_S32:
			self->info.bits = 32;
			break;
		default:
			self->info.bits = 16;
			audio_format->format = SAMPLE_FORMAT_S16;
	}
	audio_format->reverse_endian = 0;

	if (roar_vs_stream(self->vss, &(self->info), ROAR_DIR_PLAY,
				&(self->err)) < 0)
	{
		g_set_error(error, roar_output_quark(), 0, "Failed to start stream");
		g_mutex_unlock(self->lock);
		return false;
	}
	roar_vs_role(self->vss, self->role, &(self->err));
	self->alive = true;

	g_mutex_unlock(self->lock);
	return true;
}
Пример #9
0
int main (int argc, char * argv[]) {
 int    rate     = 44100;
 int    bits     = 16;
 int    channels = 2;
 int    codec    = ROAR_CODEC_DEFAULT;
 char * server   = NULL;
 char * k;
 int    i;
 int    in = ROAR_STDIN;
 struct roar_connection con;
 struct roar_stream     s;


 for (i = 1; i < argc; i++) {
  k = argv[i];

  if ( strcmp(k, "--server") == 0 ) {
   server = argv[++i];
  } else if ( strcmp(k, "--rate") == 0 ) {
   rate = atoi(argv[++i]);
  } else if ( strcmp(k, "--bits") == 0 ) {
   bits = atoi(argv[++i]);
  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) {
   channels = atoi(argv[++i]);
  } else if ( strcmp(k, "--codec") == 0 ) {
   codec = roar_str2codec(argv[++i]);
  } else if ( strcmp(k, "--help") == 0 ) {
   usage();
   return 0;
  } else {
   fprintf(stderr, "Error: unknown argument: %s\n", k);
   usage();
   return 1;
  }
 }

 if ( roar_simple_connect(&con, server, "roarcatpassfh") == -1 ) {
  ROAR_DBG("roar_simple_play(*): roar_simple_connect() faild!");
  return 1;
 }

 if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) {
  roar_disconnect(&con);
  return 1;
 }

 if ( roar_stream_connect(&con, &s, ROAR_DIR_PLAY) == -1 ) {
  roar_disconnect(&con);
  return 1;
 }

 if ( roar_stream_passfh(&con, &s, in) == -1 ) {
  roar_disconnect(&con);
  return 1;
 }

 close(in);

 sleep(1000);

 roar_disconnect(&con);

 return 0;
}
Пример #10
0
int main (int argc, char * argv[]) {
 struct roar_connection con;
 char * server   = NULL;
 char * k = NULL;
 int    i;
 int    t = 0;

 for (i = 1; i < argc; i++) {
  k = argv[i];

  if ( strcmp(k, "--server") == 0 ) {
   server = argv[++i];
  } else if ( strcmp(k, "-v") == 0 || strcmp(k, "--verbose") == 0 ) {
   g_verbose++;
  } else if ( strcmp(k, "--help") == 0 ) {
   usage();
   return 0;
  } else if ( strcmp(k, "--list-aiprofiles") == 0 ) {
   list_aiprofiles();
   return 0;
  } else if ( strcmp(k, "--enum-servers") == 0 ) {
   enum_servers();
   return 0;
  } else if ( *k == '-' ) {
   fprintf(stderr, "Error: unknown argument: %s\n", k);
   usage();
   return 1;
  } else {
   break;
  }
 }

 // connect

 if ( roar_simple_connect(&con, server, "roarctl") == -1 ) {
  fprintf(stderr, "Error: Can not connect to server\n");
  return 1;
 }

 if ( i == argc ) {
  fprintf(stderr, "Error: No Commands given\n");
  return 0; // this is not a fatal error...
 }

 for (; i < argc; i++) {
  k = argv[i];
  // cmd is in k

  printf("--- [ %s ] ---\n", k);

  if ( !strcmp(k, "help") ) {
   usage();

  } else if ( !strcmp(k, "sleep") ) {
   sleep(atoi(argv[++i]));

  } else if ( !strcmp(k, "ping") ) {
#ifdef ROAR_HAVE_GETTIMEOFDAY
   if ( ping(&con, atoi(argv[++i])) == -1 ) {
    fprintf(stderr, "Error: can not ping\n");
   }
#else
    fprintf(stderr, "Error: ping not supported.\n");
    i++;
#endif

  } else if ( !strcmp(k, "standby") || !strcmp(k, "off") ) {
   if ( roar_set_standby(&con, ROAR_STANDBY_ACTIVE) == -1 ) {
    fprintf(stderr, "Error: can not set mode to standby\n");
   } else {
    printf("going into standby\n");
   }
  } else if ( !strcmp(k, "resume") || !strcmp(k, "on") ) {
   if ( roar_set_standby(&con, ROAR_STANDBY_INACTIVE) == -1 ) {
    fprintf(stderr, "Error: can not set mode to active\n");
   } else {
    printf("going into active mode\n");
   }

  } else if ( !strcmp(k, "exit") ) {
   if ( roar_terminate(&con, 0) == -1 ) {
    fprintf(stderr, "Error: can not quit server\n");
   } else {
    printf("Server quited\n");
    break;
   }
  } else if ( !strcmp(k, "terminate") ) {
   if ( roar_terminate(&con, 1) == -1 ) {
    fprintf(stderr, "Error: can not terminate server\n");
   } else {
    printf("Server got asked to quited\n");
    break;
   }

  } else if ( !strcmp(k, "standbymode") ) {
   t = roar_get_standby(&con);
   if ( t == -1 ) {
    fprintf(stderr, "Error: can not get stanby mode\n");
   } else if ( t == ROAR_STANDBY_ACTIVE ) {
    printf("Server is in standby\n");
   } else if ( t == ROAR_STANDBY_INACTIVE ) {
    printf("Server is active\n");
   } else {
    fprintf(stderr, "Error: unknown standby mode: %i\n", t);
   }

  } else if ( !strcmp(k, "whoami") ) {
   printf("My client ID is: %i\n", roar_get_clientid(&con));
  } else if ( !strcmp(k, "serverinfo") ) {
   server_info(&con);
  } else if ( !strcmp(k, "serveroinfo") ) {
   server_oinfo(&con);
  } else if ( !strcmp(k, "serverstandards") ) {
   server_standards(&con);
  } else if ( !strcmp(k, "listclients") ) {
   list_clients(&con);
  } else if ( !strcmp(k, "liststreams") ) {
   list_streams(&con);
  } else if ( !strcmp(k, "allinfo") ) {
   server_oinfo(&con);
   printf("\n");
   list_clients(&con);
   printf("\n");
   list_streams(&con);

  } else if ( !strcmp(k, "kick") ) {
   t = roar_str2ot((k = argv[++i]));
   if ( t == -1 ) {
    fprintf(stderr, "Error: unknown type: %s\n", k);
    continue;
   }
   //t = atoi(argv[i++]);
   if ( roar_kick(&con, t, atoi(argv[++i])) == -1 ) {
    fprintf(stderr, "Error: can not kick %s\n", k);
   } else {
    printf("%s kicked\n", k);
   }

  } else if ( !strcmp(k, "newvirtual") ) {
   if ( newvirtual(&con, argv[i+1], argv[i+2], argv[i+3], argv[i+4], argv[i+5], argv[i+6]) == -1 ) {
    fprintf(stderr, "Error: can not create new virtual stream\n");
   } else {
    printf("virtual stream created\n");
   }
   i += 6;

  } else if ( !strcmp(k, "volume") ) {
   if ( set_mixer(&con, &i, argc, argv) == -1 ) {
    fprintf(stderr, "Error: can not set volume\n");
   } else {
    printf("volume changed\n");
   }

  } else if ( !strcmp(k, "flag") ) {
   i++;
   if ( set_flags(&con, atoi(argv[i]), ROAR_SET_FLAG, argv[i+1]) == -1 ) {
    fprintf(stderr, "Error: can not set flags\n");
   } else {
    printf("flags changed\n");
   }
   i++;
  } else if ( !strcmp(k, "unflag") ) {
   i++;
   if ( set_flags(&con, atoi(argv[i]), ROAR_RESET_FLAG, argv[i+1]) == -1 ) {
    fprintf(stderr, "Error: can not reset flags\n");
   } else {
    printf("flags changed\n");
   }
   i++;
  } else if ( !strcmp(k, "metaset") ) {
   i++;
   if ( set_meta(&con, atoi(argv[i]), argv[i+1], argv[i+2], argv[i+3]) == -1 ) {
    fprintf(stderr, "Error: can not set meta data\n");
   } else {
    printf("meta data changed\n");
   }
   i += 3;
  } else if ( !strcmp(k, "metaget") ) {
   i++;
   if ( show_meta_type(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
    fprintf(stderr, "Error: can not get meta data\n");
   }
   i++;
  } else if ( !strcmp(k, "metasave") ) {
   i++;
   if ( save_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
    fprintf(stderr, "Error: can not get meta data\n");
   } else {
    printf("meta data saved\n");
   }
   i++;
  } else if ( !strcmp(k, "metaload") ) {
   i++;
   if ( load_meta(&con, atoi(argv[i]), argv[i+1]) == -1 ) {
    fprintf(stderr, "Error: can not set meta data\n");
   } else {
    printf("meta data saved\n");
   }
   i++;


  } else if ( !strcmp(k, "listaiprofiles") || !strcmp(k, "listprofiles") ) {
   if ( list_aiprofiles() == -1 ) {
    fprintf(stderr, "Error: can not list profiles\n");
   }
  } else if ( !strcmp(k, "aiprofileget") || !strcmp(k, "profileget") ) {
   i++;
   if ( show_aiprofile(argv[i]) == -1 ) {
    fprintf(stderr, "Error: can not get profile data\n");
   }
  } else {
   fprintf(stderr, "Error: invalid command: %s\n", k);
  }

 }

 roar_disconnect(&con);

 return 0;
}