diff options
Diffstat (limited to 'src/examples/digest_auth_example_adv.c')
-rw-r--r-- | src/examples/digest_auth_example_adv.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/examples/digest_auth_example_adv.c b/src/examples/digest_auth_example_adv.c index 0960a81d..872e302b 100644 --- a/src/examples/digest_auth_example_adv.c +++ b/src/examples/digest_auth_example_adv.c | |||
@@ -70,6 +70,9 @@ static int allow_rfc2069 = 0; | |||
70 | */ | 70 | */ |
71 | static uint16_t daemon_port = 0; | 71 | static uint16_t daemon_port = 0; |
72 | 72 | ||
73 | |||
74 | /* *** "Database" of users and "database" functions *** */ | ||
75 | |||
73 | /** | 76 | /** |
74 | * User record. | 77 | * User record. |
75 | * This kind of data (or something similar) should be stored in some database | 78 | * This kind of data (or something similar) should be stored in some database |
@@ -380,6 +383,10 @@ find_entry_by_userinfo (const struct MHD_DigestAuthUsernameInfo *username_info) | |||
380 | } | 383 | } |
381 | 384 | ||
382 | 385 | ||
386 | /* *** End of "database" of users and "database" functions *** */ | ||
387 | |||
388 | /* *** Requests handling *** */ | ||
389 | |||
383 | /** | 390 | /** |
384 | * Send "Requested HTTP method is not supported" page | 391 | * Send "Requested HTTP method is not supported" page |
385 | * @param c the connection structure | 392 | * @param c the connection structure |
@@ -427,8 +434,9 @@ get_m_algo (void) | |||
427 | return MHD_DIGEST_AUTH_MULT_ALGO3_SHA256; | 434 | return MHD_DIGEST_AUTH_MULT_ALGO3_SHA256; |
428 | else if (force_sha512_256) | 435 | else if (force_sha512_256) |
429 | return MHD_DIGEST_AUTH_MULT_ALGO3_SHA512_256; | 436 | return MHD_DIGEST_AUTH_MULT_ALGO3_SHA512_256; |
430 | else | 437 | |
431 | return MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION; | 438 | /* No forced algorithm selection, let MHD to use default */ |
439 | return MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION; | ||
432 | } | 440 | } |
433 | 441 | ||
434 | 442 | ||
@@ -853,6 +861,9 @@ ahc_main (void *cls, | |||
853 | } | 861 | } |
854 | 862 | ||
855 | 863 | ||
864 | /* *** End of requests handling *** */ | ||
865 | |||
866 | |||
856 | /** | 867 | /** |
857 | * Add new users to the users "database". | 868 | * Add new users to the users "database". |
858 | * | 869 | * |
@@ -886,6 +897,13 @@ add_new_users (void) | |||
886 | } | 897 | } |
887 | 898 | ||
888 | 899 | ||
900 | /** | ||
901 | * Check and apply application parameters | ||
902 | * @param argc the argc of the @a main function | ||
903 | * @param argv the argv of the @a main function | ||
904 | * @return non-zero on success, | ||
905 | * zero in case of any error (like wrong parameters). | ||
906 | */ | ||
889 | static int | 907 | static int |
890 | check_params (int argc, char *const *const argv) | 908 | check_params (int argc, char *const *const argv) |
891 | { | 909 | { |
@@ -936,10 +954,13 @@ check_params (int argc, char *const *const argv) | |||
936 | } | 954 | } |
937 | 955 | ||
938 | 956 | ||
957 | /** | ||
958 | * The cryptographically secure random data | ||
959 | */ | ||
939 | static uint8_t rand_data[8]; | 960 | static uint8_t rand_data[8]; |
940 | 961 | ||
941 | /** | 962 | /** |
942 | * Initialise random data | 963 | * Initialise the random data |
943 | * @return non-zero if succeed, | 964 | * @return non-zero if succeed, |
944 | * zero if failed | 965 | * zero if failed |
945 | */ | 966 | */ |
@@ -1037,7 +1058,11 @@ main (int argc, char *const *argv) | |||
1037 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 180, | 1058 | MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 180, |
1038 | MHD_OPTION_END); | 1059 | MHD_OPTION_END); |
1039 | if (d == NULL) | 1060 | if (d == NULL) |
1061 | { | ||
1062 | fprintf (stderr, "Failed to start the server on port %lu.\n", | ||
1063 | (unsigned long) daemon_port); | ||
1040 | return 1; | 1064 | return 1; |
1065 | } | ||
1041 | printf ("Running server on port %lu.\nPress ENTER to stop.\n", | 1066 | printf ("Running server on port %lu.\nPress ENTER to stop.\n", |
1042 | (unsigned long) daemon_port); | 1067 | (unsigned long) daemon_port); |
1043 | (void) getc (stdin); | 1068 | (void) getc (stdin); |