Merge branch 'master' of ssh://www.aleph1.co.uk/home/aleph1/git/yaffs2
[yaffs2.git] / direct / timothy_tests / linux_tests / lib.c
index c5adae72e2d2d71d4e1064684aff17cb86048f23..5f439040e3ee891677bec7cfc7168d759a80e138 100644 (file)
 #include "lib.h"
 static char message[200];
 static int  PRINT_LEVEL = 3;
+static int exit_on_error_val =1;
+char string[FILE_NAME_LENGTH+1];
+
+
+int get_exit_on_error(void)
+{
+       return exit_on_error_val;
+}
+
+void set_exit_on_error(int val)
+{
+       exit_on_error_val=val;
+}
 
 node * linked_list_add_node(int pos,node *head_node)
 {
        node *new_node=NULL;
        if (pos==HEAD){
                new_node=malloc(sizeof(node));
-               memset(new_node, NULL, sizeof(node));
+               memset(new_node, 0, sizeof(node));
                new_node->string=NULL;
                new_node->next=head_node;
                return new_node;
@@ -53,7 +66,7 @@ int delete_linked_list(node *head_node)
 
 char * generate_random_string(unsigned int length)
 {
-       char string[length+1];
+
        unsigned int x;
        for (x=0;x<(length-1);x++)
        {
@@ -62,6 +75,7 @@ char * generate_random_string(unsigned int length)
        string[x]='\0';
        return string;
 }
+
 void set_print_level(int new_level)
 {
        PRINT_LEVEL=new_level;
@@ -73,12 +87,12 @@ int get_print_level(void)
 void print_message(char print_level,char *message)
 {
        if (print_level <= PRINT_LEVEL){
-               printf(message);
+               printf("%s",message);
        }
 }
-unsigned int random_int(void)
+int random_int(void)
 {
-       return (random()%4294967295);
+       return (random()%1000000); 
 }
 
 void check_function(int output)