Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_sha256.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_sha256.h"
Include dependency graph for ex_sha256.c:

Go to the source code of this file.

Functions

static void expect_true (const char *what, int ok)
 count a failed check
static int hex_is (const void *data, size_t len, const char *want)
 the hex digest of a buffer equals the expected one
int main (int argc, char **argv)
 run the checks
static int process_args (int argc, char **argv)
 read -V

Variables

static int failures = 0
 failed checks
static int log_level = 3
 log level from -V

Function Documentation

◆ expect_true()

void expect_true ( const char * what,
int ok )
static

count a failed check

Parameters
whatthe check
okits result

Definition at line 46 of file ex_sha256.c.

References failures, LOG_ERR, LOG_INFO, and n_log.

◆ hex_is()

int hex_is ( const void * data,
size_t len,
const char * want )
static

the hex digest of a buffer equals the expected one

Parameters
datathe bytes
lenhow many
wantexpected lowercase hex
Returns
non-zero when equal
Examples
ex_sha256.c.

Definition at line 77 of file ex_sha256.c.

References n_sha256(), n_sha256_hex(), N_SHA256_HEX_LEN, and N_SHA256_LEN.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int argc,
char ** argv )

run the checks

Parameters
argcargument count
argvarguments
Returns
0 on success

Definition at line 90 of file ex_sha256.c.

References done, expect_true(), failures, hex_is(), LOG_ERR, log_level, n_sha256(), n_sha256_file(), n_sha256_final(), n_sha256_init(), N_SHA256_LEN, n_sha256_update(), process_args(), and set_log_level().

Here is the call graph for this function:

◆ process_args()

int process_args ( int argc,
char ** argv )
static

read -V

Parameters
argcargument count
argvarguments
Returns
0, or -1 on a bad argument

Definition at line 59 of file ex_sha256.c.

References log_level.

Variable Documentation

◆ failures

int failures = 0
static

failed checks

Definition at line 41 of file ex_sha256.c.

◆ log_level

int log_level = 3
static

log level from -V

Definition at line 39 of file ex_sha256.c.