ソースを参照

digest parser extended, now supports domain in usernames which is not standard
but widely used.

Jan Janak 22 年 前
コミット
de61e38aef

+ 3 - 0
parser/digest/digest.c

@@ -152,6 +152,9 @@ void print_cred(dig_cred_t* _c)
 	printf("===Digest credentials===\n");
 	if (_c) {
 		printf("Username  = \'%.*s\'\n", _c->username.len, _c->username.s);
+#ifdef DIGEST_DOMAIN
+		printf("Domain    = \'%.*s\'\n", _c->domain.len, _c->domain.s);
+#endif
 		printf("Realm     = \'%.*s\'\n", _c->realm.len, _c->realm.s);
 		printf("Nonce     = \'%.*s\'\n", _c->nonce.len, _c->nonce.s);
 		printf("URI       = \'%.*s\'\n", _c->uri.len, _c->uri.s);

+ 31 - 0
parser/digest/digest_parser.c

@@ -25,6 +25,10 @@
  * You should have received a copy of the GNU General Public License 
  * along with this program; if not, write to the Free Software 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * History:
+ * --------
+ * 2003-03-02: Added parse_domain function (janakj)
  */
 
 
@@ -260,6 +264,29 @@ static inline void parse_algorithm(struct algorithm* _a)
 	}	
 }
 
+#ifdef DIGEST_DOMAIN
+/*
+ * Parse username for domain
+ */
+static inline void parse_domain(struct dig_cred* _c)
+{
+	char* d;
+
+	if (_c->username.len <= 2) return;
+
+	d = q_memchr(_c->username.s, '@', _c->username.len);
+
+	if (d) {
+		_c->domain.s = d;
+		_c->domain.len = _c->username.len - (d - _c->username.s) - 1;
+		_c->username.len = d - _c->username.s;
+	}
+}
+
+#endif
+
+
+
 
 /*
  * Parse Digest credentials parameter, one by one
@@ -298,6 +325,10 @@ static inline int parse_digest_params(str* _s, dig_cred_t* _c)
 		parse_algorithm(&(_c->alg));
 	}
 
+#ifdef DIGEST_DOMAIN
+	parse_domain(_c);
+#endif
+
 	return 0;
 }
 

+ 3 - 0
parser/digest/digest_parser.h

@@ -72,6 +72,9 @@ struct qp {
  */
 typedef struct dig_cred {
 	str username;         /* Username */
+#ifdef DIGEST_DOMAIN
+	str domain;           /* Domain contained in username */
+#endif
 	str realm;            /* Realm */
 	str nonce;            /* Nonce value */
 	str uri;              /* URI */

+ 0 - 1
parser/digest/param_parser.c

@@ -230,4 +230,3 @@ int parse_param_name(str* _s, dig_par_t* _type)
 		return 0;
 	}
 }
-