Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef HAVE_CONFIG_H
00024 # include "config.h"
00025 #endif
00026
00027
00028 #include "qop.h"
00029
00030 #include "tokens.h"
00031 #include "parser.h"
00032
00033 #include <string.h>
00034 #include <stdlib.h>
00035
00036 int
00037 digest_md5_qopstr2qops (const char *qopstr)
00038 {
00039 int qops = 0;
00040 enum
00041 {
00042
00043 QOP_AUTH = 0,
00044 QOP_AUTH_INT,
00045 QOP_AUTH_CONF
00046 };
00047 const char *const qop_opts[] = {
00048
00049 "qop-auth",
00050 "qop-int",
00051 "qop-conf",
00052 NULL
00053 };
00054 char *subsubopts;
00055 char *val;
00056 char *qopdup;
00057
00058 if (!qopstr)
00059 return 0;
00060
00061 qopdup = strdup (qopstr);
00062 if (!qopdup)
00063 return -1;
00064
00065 subsubopts = qopdup;
00066 while (*subsubopts != '\0')
00067 switch (digest_md5_getsubopt (&subsubopts, qop_opts, &val))
00068 {
00069 case QOP_AUTH:
00070 qops |= DIGEST_MD5_QOP_AUTH;
00071 break;
00072
00073 case QOP_AUTH_INT:
00074 qops |= DIGEST_MD5_QOP_AUTH_INT;
00075 break;
00076
00077 case QOP_AUTH_CONF:
00078 qops |= DIGEST_MD5_QOP_AUTH_CONF;
00079 break;
00080
00081 default:
00082
00083 break;
00084 }
00085
00086 free (qopdup);
00087
00088 return qops;
00089 }
00090
00091 const char *
00092 digest_md5_qops2qopstr (int qops)
00093 {
00094 const char *qopstr[] = {
00095 "qop-auth",
00096 "qop-auth",
00097 "qop-int",
00098 "qop-auth, qop-int",
00099 "qop-conf",
00100 "qop-auth, qop-conf",
00101 "qop-int, qop-conf",
00102 "qop-auth, qop-int, qop-conf"
00103 };
00104
00105 return qopstr[qops & 0x07];
00106 }