From 126fa84b8591c3b285b7f598089451aa22447f10 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Sat, 20 May 2017 13:43:49 +0100 Subject: Moved commands to seperate directory, moved external sources to seperate directory, updated Makefile with auto include and auto compile features --- cmd/cmd_rand_libc.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 cmd/cmd_rand_libc.c (limited to 'cmd/cmd_rand_libc.c') diff --git a/cmd/cmd_rand_libc.c b/cmd/cmd_rand_libc.c new file mode 100644 index 0000000..d72bc45 --- /dev/null +++ b/cmd/cmd_rand_libc.c @@ -0,0 +1,50 @@ +#include "cmd_rand_libc.h" + + +void *cmd_rand_libc(void *data) +{ + char *ret = NULL; + int fret=-1; + + const int buf_size = 128; + char buf[buf_size+1]; + + printf("RAND LIBC\n"); + + int i; + int count; + int rand_val; + sds params; + sds out_result; + sds *tokens; + + if (data == NULL) + { + rand_val = rand(); + snprintf(buf, buf_size, "%d", rand_val); + } else { + //cut output to 512 + char str_integer[16]; + int rand_state; + + params = sdsnew(data); + out_result = sdsempty(); + tokens = sdssplitargs(params, &count); + for (i=0;i