]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server: Constify return value of lookup_user().
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 12 Aug 2017 23:02:17 +0000 (01:02 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 13 Mar 2018 02:28:10 +0000 (03:28 +0100)
Command handlers only need to read this structure.

command.c
command.h
user_list.c
user_list.h

index a72a524fa179e605e152adc32b6a37305162b70f..74e136355f644721924752ceb61fbfd4ac3693dc 100644 (file)
--- a/command.c
+++ b/command.c
@@ -784,7 +784,7 @@ struct connection_features {
        int dummy; /* none at the moment */
 };
 
        int dummy; /* none at the moment */
 };
 
-static int parse_auth_request(char *buf, int len, struct user **u,
+static int parse_auth_request(char *buf, int len, const struct user **u,
                struct connection_features *cf)
 {
        int ret;
                struct connection_features *cf)
 {
        int ret;
index 0265f056d999ff1322b639493ad5503bc847dd6e..a7fa4673c696fe52f79bcb17dd4ca2a10ae720f9 100644 (file)
--- a/command.h
+++ b/command.h
@@ -3,7 +3,7 @@
 /** Per connection data available to command handlers. */
 struct command_context {
        /** The paraslash user that executes this command. */
 /** Per connection data available to command handlers. */
 struct command_context {
        /** The paraslash user that executes this command. */
-       struct user *u;
+       const struct user *u;
        /** File descriptor and crypto keys. */
        struct stream_cipher_context scc;
 };
        /** File descriptor and crypto keys. */
        struct stream_cipher_context scc;
 };
index e48660299bd9fdff685782930ff7a876d9c061e5..cf53c0fa8e538d3cc9ffd66452beeaf998ffd70d 100644 (file)
@@ -127,9 +127,9 @@ void init_user_list(char *user_list_file)
  * \return A pointer to the corresponding user struct if the user was found, \p
  * NULL otherwise.
  */
  * \return A pointer to the corresponding user struct if the user was found, \p
  * NULL otherwise.
  */
-struct user *lookup_user(const char *name)
+const struct user *lookup_user(const char *name)
 {
 {
-       struct user *u;
+       const struct user *u;
        list_for_each_entry(u, &user_list, node) {
                if (strcmp(u->name, name))
                        continue;
        list_for_each_entry(u, &user_list, node) {
                if (strcmp(u->name, name))
                        continue;
index 41fad16464ae10eaea54f21ef5f2ec5bad6ce6ec..e4fbd46656e289c2f7f27fd9240749ad00d766a6 100644 (file)
@@ -33,4 +33,4 @@ struct user {
 };
 
 void init_user_list(char *user_list_file);
 };
 
 void init_user_list(char *user_list_file);
-struct user *lookup_user(const char *name);
+const struct user *lookup_user(const char *name);