<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Akihiro,<br>
<br>
The patch looks mostly good now, thanks. I have a few minor
comments.<br>
<br>
On 20.04.2017 13:58, Akihiro Sagawa wrote:<br>
</div>
<blockquote cite="mid:20170420205621.4D9A.375B48EC@gmail.com"
type="cite">+struct schan_alg_id_name {
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 12px;"
lang="x-western">
<pre wrap="">+ ALG_ID alg_id;
+ const char* name;
+ const WCHAR *nameW;
+};</pre>
</div>
</blockquote>
<br>
Using an array here like const WCHAR nameW[8]; would make later
initialization nicer by not requiring multiple string variables.<br>
<br>
<blockquote cite="mid:20170420205621.4D9A.375B48EC@gmail.com"
type="cite">
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 12px;"
lang="x-western">
<pre wrap="">+
+static int comp_alg_id(const void *a, const void *b)
+{
+ const struct schan_alg_id_name *lhs = a;
+ const struct schan_alg_id_name *rhs = b;
+ return (int)lhs->alg_id - (int)rhs->alg_id;
+}
+
+static void* get_alg_name(ALG_ID id, BOOL wide)
+{
+ static const WCHAR ecdsaW[] = {'E','C','D','S','A',0};
+ static const WCHAR rsaW[] = {'R','S','A',0};
+ static const WCHAR desW[] = {'D','E','S',0};
+ static const WCHAR rc2W[] = {'R','C','2',0};
+ static const WCHAR triple_desW[] = {'3','D','E','S',0};
+ static const WCHAR aesW[] = {'A','E','S',0};
+ static const WCHAR rc4W[] = {'R','C','4',0};
+ static const struct schan_alg_id_name alg_name_map[] = {
+ { CALG_ECDSA, "ECDSA", ecdsaW },
+ { CALG_RSA_SIGN, "RSA", rsaW },
+ { CALG_DES, "DES", desW },
+ { CALG_RC2, "RC2", rc2W },
+ { CALG_3DES, "3DES", triple_desW },
+ { CALG_AES_128, "AES", aesW },
+ { CALG_AES_192, "AES", aesW },
+ { CALG_AES_256, "AES", aesW },
+ { CALG_RC4, "RC4", rc4W },
+ };
+ const struct schan_alg_id_name *res;
+ struct schan_alg_id_name key;
+
+ key.alg_id = id;
+ res = bsearch(&key, alg_name_map,
+ sizeof(alg_name_map)/sizeof(alg_name_map[0]), sizeof(alg_name_map[0]),
+ comp_alg_id);
</pre>
</div>
</blockquote>
<br>
You could use id directly as a key. You don't need it to be of
schan_alg_id_name* type, the key may be just ALG_ID.<br>
<br>
Thanks,<br>
Jacek<br>
</body>
</html>