PandA-2024.02
generate.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <sys/types.h>
5 #include <sys/stat.h>
6 #include <fcntl.h>
7 #include <unistd.h>
8 #include <assert.h>
9 
10 #include "kmp.h"
11 
12 int main(int argc, char **argv)
13 {
14  struct bench_args_t data;
15  int status, fd, nbytes;
16 
17  // Load string file
18  fd = open("TR.txt", O_RDONLY);
19  assert( fd>=0 && "couldn't open text file" );
20  nbytes = 0;
21  do {
22  status = read(fd, data.input, STRING_SIZE-nbytes);
23  assert(status>=0 && "couldn't read from text file");
24  nbytes+=status;
25  } while( nbytes<STRING_SIZE );
26  close(fd);
27  memcpy(data.pattern, "bull", PATTERN_SIZE);
28 
29  // Open and write
30  fd = open("input.data", O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
31  assert( fd>0 && "Couldn't open input data file" );
32 
33  data_to_input(fd, (void *)(&data));
34 
35  return 0;
36 }
void data_to_input(int fd, void *vdata)
Definition: local_support.c:34
#define STRING_SIZE
Definition: kmp.h:11
#define PATTERN_SIZE
Definition: kmp.h:10
char pattern[PATTERN_SIZE]
Definition: kmp.h:18
int main(int argc, char **argv)
Definition: generate.c:12
char input[STRING_SIZE]
Definition: kmp.h:19
short int read(short int *data)
Definition: read.c:3

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13