summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-11-02 12:56:20 +0100
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2016-11-04 18:40:34 +0300
commite490ba5226cedf22eb8f9166b5ac9fb5486c65f8 (patch)
tree4dda9dfa83d4051b1faaea8ae48831f01dabe7cc
parentlibguile-ssh/key-type.c: Add mapping for ed25519 keys. (diff)
downloadguile-ssh-e490ba5226cedf22eb8f9166b5ac9fb5486c65f8.tar.gz
libguile-ssh/common.h: 'const'-qualify pointers to 'symbol_mapping'.
* libguile-ssh/common.h (_ssh_const_to_scm): Const-qualify 'types' parameter. (_scm_to_ssh_const): Likewise, and const-qualify return type. * libguile-ssh/common.c (_ssh_const_to_scm): (_scm_to_ssh_const): Adjust accordingly. * libguile-ssh/key-func.c (guile_ssh_string_to_public_key): Adjust accordingly. * libguile-ssh/key-type.c (_scm_to_ssh_key_type, guile_ssh_make_keypair): Likewise. * libguile-ssh/key-type.h (_scm_to_ssh_key_type): Likewise. * libguile-ssh/log.c (guile_ssh_write_log) (guile_ssh_set_log_verbosity_x): Likewise. * libguile-ssh/session-func.c (set_sym_opt): Likewise. (guile_ssh_session_set, guile_ssh_session_get): Likewise. Signed-off-by: Artyom V. Poptsov <poptsov.artyom@gmail.com>
-rw-r--r--libguile-ssh/common.c10
-rw-r--r--libguile-ssh/common.h6
-rw-r--r--libguile-ssh/key-func.c4
-rw-r--r--libguile-ssh/key-type.c4
-rw-r--r--libguile-ssh/key-type.h2
-rw-r--r--libguile-ssh/log.c4
-rw-r--r--libguile-ssh/session-func.c6
7 files changed, 18 insertions, 18 deletions
diff --git a/libguile-ssh/common.c b/libguile-ssh/common.c
index e0b2e27..1311379 100644
--- a/libguile-ssh/common.c
+++ b/libguile-ssh/common.c
@@ -24,9 +24,9 @@
/* Convert the SSH constant VALUE to a Scheme symbol */
SCM
-_ssh_const_to_scm (struct symbol_mapping *types, int value)
+_ssh_const_to_scm (const struct symbol_mapping *types, int value)
{
- struct symbol_mapping *t;
+ const struct symbol_mapping *t;
for (t = types; t->symbol; ++t)
{
if (t->value == value)
@@ -39,10 +39,10 @@ _ssh_const_to_scm (struct symbol_mapping *types, int value)
Return the apropriate structure that contains the needed
constant. */
-struct symbol_mapping *
-_scm_to_ssh_const (struct symbol_mapping *types, SCM value)
+const struct symbol_mapping *
+_scm_to_ssh_const (const struct symbol_mapping *types, SCM value)
{
- struct symbol_mapping *t;
+ const struct symbol_mapping *t;
char *sym = scm_to_locale_string (scm_symbol_to_string (value));
for (t = types; t->symbol; ++t)
{
diff --git a/libguile-ssh/common.h b/libguile-ssh/common.h
index cc848dd..9750b7f 100644
--- a/libguile-ssh/common.h
+++ b/libguile-ssh/common.h
@@ -34,10 +34,10 @@ struct symbol_mapping {
};
extern SCM
-_ssh_const_to_scm (struct symbol_mapping *types, int value);
+_ssh_const_to_scm (const struct symbol_mapping *types, int value);
-extern struct symbol_mapping *
-_scm_to_ssh_const (struct symbol_mapping *types, SCM value);
+extern const struct symbol_mapping *
+_scm_to_ssh_const (const struct symbol_mapping *types, SCM value);
extern SCM
_scm_object_hex_address (SCM obj);
diff --git a/libguile-ssh/key-func.c b/libguile-ssh/key-func.c
index b604517..cfb3026 100644
--- a/libguile-ssh/key-func.c
+++ b/libguile-ssh/key-func.c
@@ -55,7 +55,7 @@ Throw `guile-ssh-error' on error.\
#define FUNC_NAME s_guile_ssh_string_to_public_key
{
char *c_base64_str = NULL;
- struct symbol_mapping *key_type = NULL;
+ const struct symbol_mapping *key_type = NULL;
ssh_key ssh_public_key = NULL;
int res;
@@ -256,7 +256,7 @@ Return a bytevector on success, #f on error.\
size_t hash_len;
int res;
SCM ret;
- struct symbol_mapping *hash_type = NULL;
+ const struct symbol_mapping *hash_type = NULL;
SCM_ASSERT (scm_is_symbol (type), type, SCM_ARG2, FUNC_NAME);
diff --git a/libguile-ssh/key-type.c b/libguile-ssh/key-type.c
index bf0b234..f4ccdd8 100644
--- a/libguile-ssh/key-type.c
+++ b/libguile-ssh/key-type.c
@@ -97,7 +97,7 @@ _ssh_key_type_to_scm (int type)
return _ssh_const_to_scm (key_types, type);
}
-struct symbol_mapping *
+const struct symbol_mapping *
_scm_to_ssh_key_type (SCM type)
{
return _scm_to_ssh_const (key_types, type);
@@ -129,7 +129,7 @@ Return newly generated private key. Throw `guile-ssh-error' on error.\
#define FUNC_NAME s_guile_ssh_make_keypair
{
ssh_key key = NULL;
- struct symbol_mapping *c_type = _scm_to_ssh_key_type (type);
+ const struct symbol_mapping *c_type = _scm_to_ssh_key_type (type);
int c_length;
int res;
diff --git a/libguile-ssh/key-type.h b/libguile-ssh/key-type.h
index bd12cc7..c3de199 100644
--- a/libguile-ssh/key-type.h
+++ b/libguile-ssh/key-type.h
@@ -55,6 +55,6 @@ extern int _private_key_p (struct key_data *key);
extern int _public_key_p (struct key_data *key);
extern SCM _ssh_key_type_to_scm (int arg1);
-extern struct symbol_mapping *_scm_to_ssh_key_type (SCM arg1);
+extern const struct symbol_mapping *_scm_to_ssh_key_type (SCM arg1);
#endif /* ifndef __KEY_TYPE_H__ */
diff --git a/libguile-ssh/log.c b/libguile-ssh/log.c
index 65b0975..28c7c3b 100644
--- a/libguile-ssh/log.c
+++ b/libguile-ssh/log.c
@@ -182,7 +182,7 @@ undefined. \
")
#define FUNC_NAME s_guile_ssh_write_log
{
- struct symbol_mapping *c_priority;
+ const struct symbol_mapping *c_priority;
char *c_function_name;
char *c_message;
@@ -212,7 +212,7 @@ error. Return value is undefined.\
")
#define FUNC_NAME s_guile_ssh_set_log_verbosity_x
{
- struct symbol_mapping *opt = _scm_to_ssh_const (log_verbosity, verbosity);
+ const struct symbol_mapping *opt = _scm_to_ssh_const (log_verbosity, verbosity);
int res;
if (! opt)
diff --git a/libguile-ssh/session-func.c b/libguile-ssh/session-func.c
index 86ee60a..2522517 100644
--- a/libguile-ssh/session-func.c
+++ b/libguile-ssh/session-func.c
@@ -206,7 +206,7 @@ set_port_opt (ssh_session session, int type, SCM value)
static inline int
set_sym_opt (ssh_session session, int type, struct symbol_mapping *sm, SCM value)
{
- struct symbol_mapping *opt = _scm_to_ssh_const (sm, value);
+ const struct symbol_mapping *opt = _scm_to_ssh_const (sm, value);
if (! opt)
guile_ssh_error1 ("session-set!", "Wrong value", value);
return ssh_options_set (session, type, &opt->value);
@@ -390,7 +390,7 @@ Return value is undefined.\
#define FUNC_NAME s_guile_ssh_session_set
{
struct session_data* data = _scm_to_session_data (session);
- struct symbol_mapping *opt; /* Session option */
+ const struct symbol_mapping *opt; /* Session option */
int res; /* Result of a function call */
SCM_ASSERT (scm_is_symbol (option), option, SCM_ARG2, FUNC_NAME);
@@ -430,7 +430,7 @@ Get value of the OPTION. Throw `guile-ssh-error' on an error.\
#define FUNC_NAME s_guile_ssh_session_get
{
struct session_data*sd = _scm_to_session_data (session);
- struct symbol_mapping *opt = NULL;
+ const struct symbol_mapping *opt = NULL;
SCM value; /*Value of the option */
int res;