gen_auth: simplified value assignment

This commit is contained in:
Evgeny Grin (Karlson2k)
2022-06-06 19:11:06 +03:00
parent d9ebd051d2
commit 8d5ebaec91
4 changed files with 15 additions and 9 deletions
+1 -1
View File
@@ -37,7 +37,7 @@
struct MHD_RqBAuth
{
struct _MHD_cstr_w_len token68;
struct _MHD_str_w_len token68;
};
#endif /* ! MHD_BASICAUTH_H */
+1 -1
View File
@@ -51,7 +51,7 @@
struct MHD_RqDAuthParam
{
struct _MHD_cstr_w_len value;
struct _MHD_str_w_len value;
bool quoted;
};
+4 -7
View File
@@ -91,8 +91,8 @@ parse_bauth_params (const char *str,
else
{
/* No more data in the string, only single token68. */
const struct _MHD_cstr_w_len tkn = { str + token68_start, token68_len};
memcpy (&pbauth->token68, &tkn, sizeof(tkn));
pbauth->token68.str = str + token68_start;
pbauth->token68.len = token68_len;
}
}
return true;
@@ -251,11 +251,8 @@ parse_dauth_params (const char *str,
/* Have valid parameter name and value */
mhd_assert (! quoted || 0 != value_len);
if (1)
{
const struct _MHD_cstr_w_len val = {str + value_start, value_len};
memcpy (&aparam->param->value, &val, sizeof(val));
}
aparam->param->value.str = str + value_start;
aparam->param->value.len = value_len;
aparam->param->quoted = quoted;
break; /* Found matching parameter name */
+9
View File
@@ -63,6 +63,15 @@ struct _MHD_cstr_w_len
const size_t len;
};
/**
* String with length
*/
struct _MHD_str_w_len
{
const char *str;
size_t len;
};
/**
* Static string initialiser for struct _MHD_str_w_len
*/