Browse code

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

Jan Janak authored on 03/03/2003 17:45:25
Showing 4 changed files
... ...
@@ -152,6 +152,9 @@ void print_cred(dig_cred_t* _c)
152 152
 	printf("===Digest credentials===\n");
153 153
 	if (_c) {
154 154
 		printf("Username  = \'%.*s\'\n", _c->username.len, _c->username.s);
155
+#ifdef DIGEST_DOMAIN
156
+		printf("Domain    = \'%.*s\'\n", _c->domain.len, _c->domain.s);
157
+#endif
155 158
 		printf("Realm     = \'%.*s\'\n", _c->realm.len, _c->realm.s);
156 159
 		printf("Nonce     = \'%.*s\'\n", _c->nonce.len, _c->nonce.s);
157 160
 		printf("URI       = \'%.*s\'\n", _c->uri.len, _c->uri.s);
... ...
@@ -25,6 +25,10 @@
25 25
  * You should have received a copy of the GNU General Public License 
26 26
  * along with this program; if not, write to the Free Software 
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
+ *
29
+ * History:
30
+ * --------
31
+ * 2003-03-02: Added parse_domain function (janakj)
28 32
  */
29 33
 
30 34
 
... ...
@@ -260,6 +264,29 @@ static inline void parse_algorithm(struct algorithm* _a)
260 264
 	}	
261 265
 }
262 266
 
267
+#ifdef DIGEST_DOMAIN
268
+/*
269
+ * Parse username for domain
270
+ */
271
+static inline void parse_domain(struct dig_cred* _c)
272
+{
273
+	char* d;
274
+
275
+	if (_c->username.len <= 2) return;
276
+
277
+	d = q_memchr(_c->username.s, '@', _c->username.len);
278
+
279
+	if (d) {
280
+		_c->domain.s = d;
281
+		_c->domain.len = _c->username.len - (d - _c->username.s) - 1;
282
+		_c->username.len = d - _c->username.s;
283
+	}
284
+}
285
+
286
+#endif
287
+
288
+
289
+
263 290
 
264 291
 /*
265 292
  * Parse Digest credentials parameter, one by one
... ...
@@ -298,6 +325,10 @@ static inline int parse_digest_params(str* _s, dig_cred_t* _c)
298 325
 		parse_algorithm(&(_c->alg));
299 326
 	}
300 327
 
328
+#ifdef DIGEST_DOMAIN
329
+	parse_domain(_c);
330
+#endif
331
+
301 332
 	return 0;
302 333
 }
303 334
 
... ...
@@ -72,6 +72,9 @@ struct qp {
72 72
  */
73 73
 typedef struct dig_cred {
74 74
 	str username;         /* Username */
75
+#ifdef DIGEST_DOMAIN
76
+	str domain;           /* Domain contained in username */
77
+#endif
75 78
 	str realm;            /* Realm */
76 79
 	str nonce;            /* Nonce value */
77 80
 	str uri;              /* URI */
... ...
@@ -230,4 +230,3 @@ int parse_param_name(str* _s, dig_par_t* _type)
230 230
 		return 0;
231 231
 	}
232 232
 }
233
-