From Dirk via bug 6361:

Use File/Directory Dialog as a field type for UAT preferences.

svn path=/trunk/; revision=39059
This commit is contained in:
Stig Bjørlykke 2011-09-20 10:15:09 +00:00
parent c3cb0e6dd9
commit 0554530407
5 changed files with 15 additions and 18 deletions

View File

@ -2009,7 +2009,7 @@ dtlsdecrypt_copy_cb(void* dest, const void* orig, size_t len _U_)
UAT_CSTRING_CB_DEF(sslkeylist_uats,ipaddr,ssldecrypt_assoc_t)
UAT_CSTRING_CB_DEF(sslkeylist_uats,port,ssldecrypt_assoc_t)
UAT_CSTRING_CB_DEF(sslkeylist_uats,protocol,ssldecrypt_assoc_t)
UAT_CSTRING_CB_DEF(sslkeylist_uats,keyfile,ssldecrypt_assoc_t)
UAT_FILENAME_CB_DEF(sslkeylist_uats,keyfile,ssldecrypt_assoc_t)
UAT_CSTRING_CB_DEF(sslkeylist_uats,password,ssldecrypt_assoc_t)
#endif
@ -2346,7 +2346,7 @@ proto_register_dtls(void)
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, ipaddr, "IP address", ssldecrypt_uat_fld_ip_chk_cb, "IPv4 or IPv6 address"),
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, port, "Port", ssldecrypt_uat_fld_port_chk_cb, "Port Number"),
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, protocol, "Protocol", ssldecrypt_uat_fld_protocol_chk_cb, "Protocol"),
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, keyfile, "Key File", ssldecrypt_uat_fld_fileopen_chk_cb, "Path to the keyfile."),
UAT_FLD_FILENAME_OTHER(sslkeylist_uats, keyfile, "Key File", ssldecrypt_uat_fld_fileopen_chk_cb, "Path to the keyfile."),
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, password," Password (p12 file)", ssldecrypt_uat_fld_password_chk_cb, "Password"),
UAT_END_FIELDS
};

View File

@ -3550,8 +3550,7 @@ ssl_print_string(const gchar* name, const StringInfo* data)
gboolean
ssldecrypt_uat_fld_ip_chk_cb(void* r _U_, const char* p, unsigned len _U_, const void* u1 _U_, const void* u2 _U_, const char** err)
{
if ((gint)strlen(p) == 0) {
if (!p || strlen(p) == 0u) {
*err = ep_strdup_printf("No IP address given.");
return FALSE;
}
@ -3563,16 +3562,14 @@ ssldecrypt_uat_fld_ip_chk_cb(void* r _U_, const char* p, unsigned len _U_, const
gboolean
ssldecrypt_uat_fld_port_chk_cb(void* r _U_, const char* p, unsigned len _U_, const void* u1 _U_, const void* u2 _U_, const char** err)
{
guint i;
if ((gint)strlen(p) == 0) {
if (!p || strlen(p) == 0u) {
*err = ep_strdup_printf("No Port given.");
return FALSE;
}
if (strcmp(p, "start_tls") != 0){
i = atoi(p);
if (i <= 0) {
const gint i = atoi(p);
if (i <= 0 || i > 65535) {
*err = ep_strdup_printf("Invalid port given.");
return FALSE;
}
@ -3585,7 +3582,7 @@ ssldecrypt_uat_fld_port_chk_cb(void* r _U_, const char* p, unsigned len _U_, con
gboolean
ssldecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, unsigned len _U_, const void* u1 _U_, const void* u2 _U_, const char** err)
{
if ((gint)strlen(p) == 0) {
if (!p || strlen(p) == 0u) {
*err = ep_strdup_printf("No protocol given.");
return FALSE;
}
@ -3604,7 +3601,7 @@ ssldecrypt_uat_fld_fileopen_chk_cb(void* r _U_, const char* p, unsigned len _U_,
{
ws_statb64 st;
if ((gint)strlen(p) == 0) {
if (!p || strlen(p) == 0u) {
*err = ep_strdup_printf("No filename given.");
return FALSE;
} else {
@ -3624,7 +3621,7 @@ ssldecrypt_uat_fld_password_chk_cb(void* r _U_, const char* p, unsigned len _U_,
ssldecrypt_assoc_t* f = r;
FILE *fp = NULL;
if ((gint)strlen(p) > 0) {
if (p && strlen(p) > 0u) {
fp = ws_fopen(f->keyfile, "rb");
if (fp) {
if (!ssl_load_pkcs12(fp, p)) {

View File

@ -4390,7 +4390,7 @@ ssldecrypt_copy_cb(void* dest, const void* orig, size_t len _U_)
UAT_CSTRING_CB_DEF(sslkeylist_uats,ipaddr,ssldecrypt_assoc_t)
UAT_CSTRING_CB_DEF(sslkeylist_uats,port,ssldecrypt_assoc_t)
UAT_CSTRING_CB_DEF(sslkeylist_uats,protocol,ssldecrypt_assoc_t)
UAT_CSTRING_CB_DEF(sslkeylist_uats,keyfile,ssldecrypt_assoc_t)
UAT_FILENAME_CB_DEF(sslkeylist_uats,keyfile,ssldecrypt_assoc_t)
UAT_CSTRING_CB_DEF(sslkeylist_uats,password,ssldecrypt_assoc_t)
#endif
@ -4983,7 +4983,7 @@ proto_register_ssl(void)
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, ipaddr, "IP address", ssldecrypt_uat_fld_ip_chk_cb, "IPv4 or IPv6 address"),
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, port, "Port", ssldecrypt_uat_fld_port_chk_cb, "Port Number"),
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, protocol, "Protocol", ssldecrypt_uat_fld_protocol_chk_cb, "Protocol"),
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, keyfile, "Key File", ssldecrypt_uat_fld_fileopen_chk_cb, "Private keyfile."),
UAT_FLD_FILENAME_OTHER(sslkeylist_uats, keyfile, "Key File", ssldecrypt_uat_fld_fileopen_chk_cb, "Private keyfile."),
UAT_FLD_CSTRING_OTHER(sslkeylist_uats, password,"Password", ssldecrypt_uat_fld_password_chk_cb, "Password (for PCKS#12 keyfile)"),
UAT_END_FIELDS
};

View File

@ -80,7 +80,7 @@ typedef struct _geoip_db_path_t {
static geoip_db_path_t *geoip_db_paths = NULL;
static guint num_geoip_db_paths = 0;
static uat_t *geoip_db_paths_uat = NULL;
UAT_CSTRING_CB_DEF(geoip_mod, path, geoip_db_path_t)
UAT_DIRECTORYNAME_CB_DEF(geoip_mod, path, geoip_db_path_t)
/**
@ -132,7 +132,7 @@ void
geoip_db_init(void) {
guint i;
static uat_field_t geoip_db_paths_fields[] = {
UAT_FLD_PATHNAME(geoip_mod, path, "Database pathname", "The database path"),
UAT_FLD_DIRECTORYNAME(geoip_mod, path, "GeoIP Database Directory", "The GeoIP database directory path"),
UAT_END_FIELDS
};
char* geoip_load_error = NULL;

View File

@ -230,7 +230,7 @@ static uat_t* smi_modules_uat = NULL;
static GString* smi_errors;
UAT_CSTRING_CB_DEF(smi_mod,name,smi_module_t)
UAT_DIRECTORYNAME_CB_DEF(smi_mod,name,smi_module_t)
static void smi_error_handler(char *path, int line, int severity, char *msg, char *tag) {
g_string_append_printf(smi_errors,"%s:%d %d %s %s\n",
@ -519,7 +519,7 @@ static void register_mibs(void) {
UAT_END_FIELDS
};
static uat_field_t smi_paths_fields[] = {
UAT_FLD_PATHNAME(smi_mod,name,"Directory path","The directory name"),
UAT_FLD_DIRECTORYNAME(smi_mod,name,"Directory path","The directory name"),
UAT_END_FIELDS
};
char* smi_load_error = NULL;