zap spice_parse_args + spice_usage_str

First step to throw out the old interface.
This commit is contained in:
Gerd Hoffmann 2010-03-23 15:53:05 +01:00
parent 25bca7a286
commit edc1af5f67
2 changed files with 0 additions and 336 deletions

View File

@ -3728,39 +3728,6 @@ static void reds_do_set_playback_compression_2(const VDICmdArg *args)
reds_do_set_playback_compression(args[0].string_val);
}
static OptionsMap _spice_options[] = {
{"port", SPICE_OPTION_PORT},
{"sport", SPICE_OPTION_SPORT},
{"host", SPICE_OPTION_HOST},
{"ic", SPICE_OPTION_IMAGE_COMPRESSION},
{"password", SPICE_OPTION_PASSWORD},
{"disable-ticketing", SPICE_OPTION_DISABLE_TICKET},
{"renderer", SPICE_OPTION_RENDERER},
{"sslkey", SPICE_OPTION_SSLKEY},
{"sslcert", SPICE_OPTION_SSLCERTS},
{"sslcafile", SPICE_OPTION_SSLCAFILE},
{"ssldhfile", SPICE_OPTION_SSLDHFILE},
{"sslpassword", SPICE_OPTION_SSLPASSWORD},
{"sslciphersuite", SPICE_OPTION_SSLCIPHERSUITE},
{"secure-channels", SPICE_SECURED_CHANNELS},
{"unsecure-channels", SPICE_UNSECURED_CHANNELS},
{"sv", SPICE_OPTION_STREAMING_VIDEO},
{"agent-mouse", SPICE_OPTION_AGENT_MOUSE},
{"playback-compression", SPICE_OPTION_PLAYBACK_COMPRESSION},
{NULL, 0},
};
static OptionsMap _channel_map[] = {
{"all", SPICE_CHANNEL_NAME_ALL},
{"main", SPICE_CHANNEL_NAME_MAIN},
{"display", SPICE_CHANNEL_NAME_DISPLAY},
{"inputs", SPICE_CHANNEL_NAME_INPUTS},
{"cursor", SPICE_CHANNEL_NAME_CURSOR},
{"playback", SPICE_CHANNEL_NAME_PLAYBACK},
{"record", SPICE_CHANNEL_NAME_RECORD},
{NULL, 0},
};
static void set_all_channels_security(uint32_t security)
{
while (channels_security) {
@ -3786,306 +3753,6 @@ static void set_one_channel_security(int id, uint32_t security)
channels_security = security_options;
}
static int set_channels_security(const char *channels, uint32_t security)
{
char *local_str;
int channel_name;
char *str;
char *val;
int all = 0;
int specific = 0;
local_str = spice_strdup(channels);
str = local_str;
do {
switch (channel_name = get_option(&str, &val, _channel_map, '+')) {
case SPICE_CHANNEL_NAME_ALL:
all++;
break;
case SPICE_CHANNEL_NAME_MAIN:
specific++;
set_one_channel_security(SPICE_CHANNEL_MAIN, security);
break;
case SPICE_CHANNEL_NAME_DISPLAY:
specific++;
set_one_channel_security(SPICE_CHANNEL_DISPLAY, security);
break;
case SPICE_CHANNEL_NAME_INPUTS:
specific++;
set_one_channel_security(SPICE_CHANNEL_INPUTS, security);
break;
case SPICE_CHANNEL_NAME_CURSOR:
specific++;
set_one_channel_security(SPICE_CHANNEL_CURSOR, security);
break;
case SPICE_CHANNEL_NAME_PLAYBACK:
specific++;
set_one_channel_security(SPICE_CHANNEL_PLAYBACK, security);
break;
case SPICE_CHANNEL_NAME_RECORD:
specific++;
set_one_channel_security(SPICE_CHANNEL_RECORD, security);
break;
default:
goto error;
}
if (val) {
goto error;
}
} while (str);
if (all) {
if (specific || all > 1) {
goto error;
}
set_all_channels_security(security);
return TRUE;
}
return TRUE;
error:
free(local_str);
return FALSE;
}
int __attribute__ ((visibility ("default"))) spice_parse_args(const char *in_args)
{
char *local_args;
char *args;
int option;
char *val;
int renderers_opt = FALSE;
int ssl_port = FALSE;
int ssl_key = FALSE;
int ssl_certs = FALSE;
int ssl_ciphersuite = FALSE;
int ssl_cafile = FALSE;
int ssl_dhfile = FALSE;
memset(&ssl_parameters, 0, sizeof(ssl_parameters));
local_args = spice_strdup(in_args);
args = local_args;
do {
switch (option = get_option(&args, &val, _spice_options, ',')) {
case SPICE_OPTION_PORT: {
char *endptr;
long int port;
if (!val) {
goto error;
}
port = strtol(val, &endptr, 0);
if (endptr != val + strlen(val) || port < 0 || port > 0xffff) {
goto error;
}
spice_port = port;
break;
}
case SPICE_OPTION_SPORT: {
char *endptr;
long int port;
if (!val) {
goto error;
}
port = strtol(val, &endptr, 0);
if (endptr != val + strlen(val) || port < 0 || port > 0xffff) {
goto error;
}
ssl_port = TRUE;
spice_secure_port = port;
break;
}
case SPICE_OPTION_HOST: {
if (val) {
strncpy(spice_addr, val, sizeof(spice_addr));
/* force ipv4 here for backward compatibility */
spice_family = PF_INET;
}
break;
}
case SPICE_OPTION_IMAGE_COMPRESSION:
if (!val) {
goto error;
}
image_compression = reds_get_image_compression(val);
if (image_compression == SPICE_IMAGE_COMPRESS_INVALID) {
goto error;
}
break;
case SPICE_OPTION_PASSWORD:
ticketing_enabled = 1;
if (val) {
strncpy(taTicket.password, val, sizeof taTicket.password);
//todo: add expiration option
taTicket.expiration_time = INT_MAX;
}
break;
case SPICE_OPTION_DISABLE_TICKET:
ticketing_enabled = 0;
break;
case SPICE_OPTION_RENDERER:
renderers_opt = TRUE;
if (!val) {
goto error;
}
while (val) {
char *now = val;
if ((val = strchr(now, '+'))) {
*val++ = 0;
}
if (!red_dispatcher_add_renderer(now)) {
goto error;
}
}
break;
case SPICE_OPTION_SSLCIPHERSUITE:
ssl_ciphersuite = TRUE;
if (val) {
strncpy(ssl_parameters.ciphersuite, val, sizeof(ssl_parameters.ciphersuite));
}
break;
case SPICE_OPTION_SSLPASSWORD:
if (val) {
strncpy(ssl_parameters.keyfile_password, val,
sizeof(ssl_parameters.keyfile_password));
}
break;
case SPICE_OPTION_SSLKEY:
ssl_key = TRUE;
if (val) {
strncpy(ssl_parameters.private_key_file, val,
sizeof(ssl_parameters.private_key_file));
}
break;
case SPICE_OPTION_SSLCERTS:
ssl_certs = TRUE;
if (val) {
strncpy(ssl_parameters.certs_file, val, sizeof(ssl_parameters.certs_file));
}
break;
case SPICE_OPTION_SSLCAFILE:
ssl_cafile = TRUE;
if (val) {
strncpy(ssl_parameters.ca_certificate_file, val,
sizeof(ssl_parameters.ca_certificate_file));
}
break;
case SPICE_OPTION_SSLDHFILE:
ssl_dhfile = TRUE;
if (val) {
strncpy(ssl_parameters.dh_key_file, val, sizeof(ssl_parameters.dh_key_file));
}
break;
case SPICE_SECURED_CHANNELS:
if (!val || !set_channels_security(val, SPICE_CHANNEL_SECURITY_SSL)) {
goto error;
}
break;
case SPICE_UNSECURED_CHANNELS:
if (!val || !set_channels_security(val, SPICE_CHANNEL_SECURITY_NONE)) {
goto error;
}
break;
case SPICE_OPTION_STREAMING_VIDEO:
if (!val) {
goto error;
}
streaming_video = reds_get_streaming_video(val);
if (streaming_video == STREAM_VIDEO_INVALID) {
goto error;
}
break;
case SPICE_OPTION_PLAYBACK_COMPRESSION:
if (!val) {
goto error;
}
if (strcmp(val, "on") == 0) {
snd_set_playback_compression(TRUE);
} else if (strcmp(val, "off") == 0) {
snd_set_playback_compression(FALSE);
} else {
goto error;
}
break;
case SPICE_OPTION_AGENT_MOUSE:
if (!val) {
goto error;
}
if (strcmp(val, "on") == 0) {
agent_mouse = TRUE;
} else if (strcmp(val, "off") == 0) {
agent_mouse = FALSE;
} else {
goto error;
}
break;
default:
goto error;
}
} while (args);
if (!renderers_opt && !red_dispatcher_add_renderer("sw")) {
goto error;
}
// All SSL parameters should be either on or off.
if (ssl_port != ssl_key || ssl_key != ssl_certs || ssl_certs != ssl_cafile ||
ssl_cafile != ssl_dhfile || ssl_dhfile != ssl_ciphersuite) {
goto error;
}
free(local_args);
return TRUE;
error:
free(local_args);
return FALSE;
}
const char *spice_usage_str[] __attribute__ ((visibility ("default"))) = {
"[port=<port>][,sport=<port>][,host=<host>]",
"[,ic=on|auto_glz|auto_lz|quic|glz|lz|off]",
"[,playback-compression=on|off]",
"[,password=password][,disable-ticketing]",
"[,renderer=oglpbuf+oglpixmap+sw]",
"[,sslkeys=key directory,sslcerts=certs directory,sslpassword=pem password,",
" sslciphersuite=cipher suite]",
"[,secure-channels=all|channel+channel+...]",
"[,unsecure-channels=all|channel+channel+...]",
"[,vs=on|off] [,ac=on|off]",
" listen on interface address <host> port <port> and/or sport <port>",
" setting ticket password using \"ticket\" option",
" setting image compression using \"ic\" option [default=auto_local]",
" setting playback compression using \"playback-compression\" option [default=on]",
" select renderers using \"renderer\" option",
" sslkeys - set directory where ssl key file resides.",
" sslcerts - set directory where ssl cert file resides.",
" sslpassword - set the password to open the private key file.",
" sslciphersuite - set the cipher suite to use.",
" setting streaming video using \"sv\" option [default=on]",
" setting audio compression codec using \"ac\" option [default=off]",
" secure-channels - force secure connection on all/specific chnnels.",
" channels names: main, inputs, display, cursor,",
" playback and record.",
" unsecure-channels - force unsecure connection on all/specific chnnels.",
" channels names as in secure-channels.",
NULL,
};
#define REDS_SAVE_VERSION 1
static OptionsMap spice_mig_options[] = {

View File

@ -22,9 +22,6 @@
#include "vd_interface.h"
/* old interface */
extern const char *spice_usage_str[];
int spice_parse_args(const char *args);
void spice_init(CoreInterface *core);
/* new interface */