aboutsummaryrefslogtreecommitdiff
path: root/src/sha256.c
diff options
context:
space:
mode:
authorscott-linder <scott.b.linder@wmich.edu>2014-02-23 15:34:45 -0500
committerscott-linder <scott.b.linder@wmich.edu>2014-02-24 09:48:18 -0500
commitb76c358f3de9106a4bdbf853b4c4371f6f7a62c2 (patch)
treefef0339611c6e76afc3dc8da4b6bd2ab227e3066 /src/sha256.c
parent1bcbc42330d651f06b8a842e16fe36475afde05d (diff)
downloadrneovim-b76c358f3de9106a4bdbf853b4c4371f6f7a62c2.tar.gz
rneovim-b76c358f3de9106a4bdbf853b4c4371f6f7a62c2.tar.bz2
rneovim-b76c358f3de9106a4bdbf853b4c4371f6f7a62c2.zip
Convert function declarations from K&R to ANSI style.
cproto (http://invisible-island.net/cproto/) was used to do the bulk of the work in batch; even the most recent version had some issues with typedef'd parameters; a quick "patch" was to modify `lex.l` to explicitly include all vim typedefs as known types. One example from `vim.h` is typedef unsigned char char_u; which was added in `lex.l` as <INITIAL>char_u { save_text_offset(); return T_CHAR; } Even with these changes there were some problems: * Two files (`mbyte.c` and `os_unix.c`) were not cleanly converted. * Any function with the `UNUSED` macro in its parameter list was not converted. Rather than spend more time fixing the automated approach, the two files `mbyte.c` and `os_unix.c` were converted by hand. The `UNUSED` macros were compiler specific, and the alternative, generic version would require a different syntax, so in order to simplify the conversion all uses of `UNUSED` were stripped, and then the sources were run back through cproto. It is planned to reconsider each use of `UNUSED` manually using a new macro definition.
Diffstat (limited to 'src/sha256.c')
-rw-r--r--src/sha256.c37
1 files changed, 9 insertions, 28 deletions
diff --git a/src/sha256.c b/src/sha256.c
index 0761987ebe..16ee6cfad0 100644
--- a/src/sha256.c
+++ b/src/sha256.c
@@ -41,8 +41,7 @@ static void sha256_process __ARGS((context_sha256_T *ctx, char_u data[64]));
(b)[(i) + 3] = (char_u)((n) ); \
}
-void sha256_start(ctx)
-context_sha256_T *ctx;
+void sha256_start(context_sha256_T *ctx)
{
ctx->total[0] = 0;
ctx->total[1] = 0;
@@ -57,9 +56,7 @@ context_sha256_T *ctx;
ctx->state[7] = 0x5BE0CD19;
}
-static void sha256_process(ctx, data)
-context_sha256_T *ctx;
-char_u data[64];
+static void sha256_process(context_sha256_T *ctx, char_u data[64])
{
UINT32_T temp1, temp2, W[64];
UINT32_T A, B, C, D, E, F, G, H;
@@ -190,10 +187,7 @@ char_u data[64];
ctx->state[7] += H;
}
-void sha256_update(ctx, input, length)
-context_sha256_T *ctx;
-char_u *input;
-UINT32_T length;
+void sha256_update(context_sha256_T *ctx, char_u *input, UINT32_T length)
{
UINT32_T left, fill;
@@ -234,9 +228,7 @@ static char_u sha256_padding[64] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
-void sha256_finish(ctx, digest)
-context_sha256_T *ctx;
-char_u digest[32];
+void sha256_finish(context_sha256_T *ctx, char_u digest[32])
{
UINT32_T last, padn;
UINT32_T high, low;
@@ -270,11 +262,7 @@ static unsigned int get_some_time __ARGS((void));
* Returns hex digest of "buf[buf_len]" in a static array.
* if "salt" is not NULL also do "salt[salt_len]".
*/
-char_u * sha256_bytes(buf, buf_len, salt, salt_len)
-char_u *buf;
-int buf_len;
-char_u *salt;
-int salt_len;
+char_u *sha256_bytes(char_u *buf, int buf_len, char_u *salt, int salt_len)
{
char_u sha256sum[32];
static char_u hexit[65];
@@ -297,10 +285,7 @@ int salt_len;
/*
* Returns sha256(buf) as 64 hex chars in static array.
*/
-char_u * sha256_key(buf, salt, salt_len)
-char_u *buf;
-char_u *salt;
-int salt_len;
+char_u *sha256_key(char_u *buf, char_u *salt, int salt_len)
{
/* No passwd means don't encrypt */
if (buf == NULL || *buf == NUL)
@@ -332,7 +317,7 @@ static char *sha_self_test_vector[] = {
* Perform a test on the SHA256 algorithm.
* Return FAIL or OK.
*/
-int sha256_self_test() {
+int sha256_self_test(void) {
int i, j;
char output[65];
context_sha256_T ctx;
@@ -370,7 +355,7 @@ int sha256_self_test() {
return failures > 0 ? FAIL : OK;
}
-static unsigned int get_some_time() {
+static unsigned int get_some_time(void) {
# ifdef HAVE_GETTIMEOFDAY
struct timeval tv;
@@ -386,11 +371,7 @@ static unsigned int get_some_time() {
* Fill "header[header_len]" with random_data.
* Also "salt[salt_len]" when "salt" is not NULL.
*/
-void sha2_seed(header, header_len, salt, salt_len)
-char_u *header;
-int header_len;
-char_u *salt;
-int salt_len;
+void sha2_seed(char_u *header, int header_len, char_u *salt, int salt_len)
{
int i;
static char_u random_data[1000];