瀏覽代碼

Minor corrections for bc827fcc09ac66b87a6ac052982beda393aeec60

Evgeny Grin (Karlson2k) 2 年之前
父節點
當前提交
3bd6b07fc4
共有 1 個文件被更改,包括 28 次插入3 次删除
  1. 28 3
      src/examples/digest_auth_example_adv.c

+ 28 - 3
src/examples/digest_auth_example_adv.c

@@ -70,6 +70,9 @@ static int allow_rfc2069 = 0;
  */
  */
 static uint16_t daemon_port = 0;
 static uint16_t daemon_port = 0;
 
 
+
+/* *** "Database" of users and "database" functions *** */
+
 /**
 /**
  * User record.
  * User record.
  * This kind of data (or something similar) should be stored in some database
  * 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)
 }
 }
 
 
 
 
+/* *** End of "database" of users and "database" functions *** */
+
+/* *** Requests handling *** */
+
 /**
 /**
  * Send "Requested HTTP method is not supported" page
  * Send "Requested HTTP method is not supported" page
  * @param c the connection structure
  * @param c the connection structure
@@ -427,8 +434,9 @@ get_m_algo (void)
     return MHD_DIGEST_AUTH_MULT_ALGO3_SHA256;
     return MHD_DIGEST_AUTH_MULT_ALGO3_SHA256;
   else if (force_sha512_256)
   else if (force_sha512_256)
     return MHD_DIGEST_AUTH_MULT_ALGO3_SHA512_256;
     return MHD_DIGEST_AUTH_MULT_ALGO3_SHA512_256;
-  else
-    return MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION;
+
+  /* No forced algorithm selection, let MHD to use default */
+  return MHD_DIGEST_AUTH_MULT_ALGO3_ANY_NON_SESSION;
 }
 }
 
 
 
 
@@ -853,6 +861,9 @@ ahc_main (void *cls,
 }
 }
 
 
 
 
+/* *** End of requests handling *** */
+
+
 /**
 /**
  * Add new users to the users "database".
  * Add new users to the users "database".
  *
  *
@@ -886,6 +897,13 @@ add_new_users (void)
 }
 }
 
 
 
 
+/**
+ * Check and apply application parameters
+ * @param argc the argc of the @a main function
+ * @param argv the argv of the @a main function
+ * @return non-zero on success,
+ *         zero in case of any error (like wrong parameters).
+ */
 static int
 static int
 check_params (int argc, char *const *const argv)
 check_params (int argc, char *const *const argv)
 {
 {
@@ -936,10 +954,13 @@ check_params (int argc, char *const *const argv)
 }
 }
 
 
 
 
+/**
+ * The cryptographically secure random data
+ */
 static uint8_t rand_data[8];
 static uint8_t rand_data[8];
 
 
 /**
 /**
- * Initialise random data
+ * Initialise the random data
  * @return non-zero if succeed,
  * @return non-zero if succeed,
  *         zero if failed
  *         zero if failed
  */
  */
@@ -1037,7 +1058,11 @@ main (int argc, char *const *argv)
     MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 180,
     MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 180,
     MHD_OPTION_END);
     MHD_OPTION_END);
   if (d == NULL)
   if (d == NULL)
+  {
+    fprintf (stderr, "Failed to start the server on port %lu.\n",
+             (unsigned long) daemon_port);
     return 1;
     return 1;
+  }
   printf ("Running server on port %lu.\nPress ENTER to stop.\n",
   printf ("Running server on port %lu.\nPress ENTER to stop.\n",
           (unsigned long) daemon_port);
           (unsigned long) daemon_port);
   (void) getc (stdin);
   (void) getc (stdin);