Question: Please change/paraphrase the code. The implementation should be the same but the variable names can be changed #include #include #include #include #include #include #include /*

Please change/paraphrase the code. The implementation should be the same but the variable names can be changed  #include   #include   #include   #include   #include   #include   #include     /*   * Constants   */  #define SWITCH '-'  #define CHARS_TO_ADD10U    /*   * Global flags and values   */  unsigned intprng_seed = 0;  unsigned intnumiter = 0;  unsigned longdelay = 0;  int     flag0 = 0;  int     flaga = 1;  int     flagx = 0;  int     flago = 0;  int     flagr = 0;  int     flags = 0;  char*infile, *outfile;  FILE*in, *out;  charseedfilein [255];  void*string_seed = NULL;  unsigned intstring_seed_len = 0;  unsigned char *final_buffer = NULL;  FILE*OUTFUZZ;    /*   * Functions' declarations   */  voidusage();  voidinit();  voidgarbage_collector();  voidreplay();  intrandomstr(void *, size_t);  voidprintfuzz(unsigned int);  voidputstr(unsigned char *, size_t);  voidputch(char);  voidreseed();    /*   * Display usage to the user   */  void usage()  {       puts("Usage: \"seed string\" | fuzz prng_seed num_iter [-0] [-a] [-d delay] [-p]");       puts("            [-o outfile] [-r infile] [-s seed file input]");       exit(1);  }    /*   * main function   */  int main(int argc, char** argv)  {  unsigned intparam_value = 0;    /* By default, file name is "seed" in the current directory */  strcpy (seedfilein, "seed");    #ifdef DEBUG  fprintf(stderr, "[DEBUG] Running in DEBUG mode...\n\n");  #endif  /*  * Parse command line   */      while (*(++argv) != NULL)  if (**argv != SWITCH) {/* Not a switch, must be a value*/  if (sscanf(*argv, "%u", ¶m_value) != 1) {  usage();  return 0;  }  if (prng_seed == 0) {/* first parameter is prng_seed   */  prng_seed = param_value;  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Read PRNG value to: %d\n", prng_seed);  #endif  } else {/* second parameter is iteration number*/  numiter = param_value;  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Read Number Iteration value to: %d\n", numiter);  #endif  }  } else {/* identify switch parameters */  switch ((*argv)[1]) {  case '0':  flag0 = 1;  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Allow NULL values flag set\n");  #endif  break;  case 'a':  flaga = 1;  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Require printable ASCII flag set\n");  #endif  break;  case 'd':  argv++;  if (sscanf(*argv, "%u", ¶m_value) != 1) {  perror ("Error: -d option requires a numeric value (delay)\n");  usage();  garbage_collector();  exit (1);  }  else  delay = param_value * 1000000;  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Set delay to: %d\n", delay);  #endif  break;  case 'o':  flago = 1;  argv++;  outfile = *argv;  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Set output file to: %d\n", outfile);  #endif  break;  case 'p':  flaga = 0;  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Print all ASCII characters:\n");  #endif  break;  case 'r':  flagr = 1;  argv++;  infile = *argv;  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Set input file to: %d\n", infile);  #endif  break;  case 's':  argv++;  if (sscanf(*argv, "%255s", seedfilein) != 1) {  perror ("Error: -s option requires a file name (seed file to read from)\n");  usage();  garbage_collector();  exit (1);  }  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Set output file to: %d\n", outfile);  #endif  break;  default:  usage();  }  }    init();  if (flagr)  replay();  else  printfuzz (numiter);    garbage_collector();  return 0;  }    /*   * Initialize random number generator, open files, print prng_seed   */  void init()  {  unsigned char c;    /*   * Read seed value from STDIN, if piped   */  if (!isatty(fileno(stdin))) {  int i = 0;  string_seed = calloc(BUFSIZ, 1);  do {  c = fgetc(stdin);  if(feof(stdin)) {  break;  }  ((char *)string_seed)[i++] = c;  } while (1 && i <= BUFSIZ);    string_seed_len = i;  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Incoming piped seed from STDIN: %*s\n", string_seed_len-1, string_seed);  #endif  } else {  /*  * The seed value has not been piped, so we retrieve value  * from the seed file.  * Allows arbitrary lenght and stores into string_seed.  */  FILE*sf;  size_tnew_len;  longbufsize;    if ((sf = fopen(seedfilein, "rb")) == NULL) {  char b[BUFSIZ];  sprintf(b, "Cannot open read seed file: %s. Exiting.\n", seedfilein);  perror (b);  garbage_collector();  exit(1);  } else {  if (!fseek(sf, 0L, SEEK_END)) {  /* Get the size of the file */  bufsize = ftell(sf);  if (bufsize == -1) {  char b[BUFSIZ];  sprintf(b, "Cannot seek end of read seed file: %s. Exiting.\n", seedfilein);  perror (b);  garbage_collector();  exit (1);  }    /* Go back to the start of the file */  if (fseek(sf, 0L, SEEK_SET) != 0) {  char b[BUFSIZ];  sprintf(b, "Cannot seek start of read seed file: %s. Exiting.\n", seedfilein);  perror (b);  garbage_collector();  exit (1);  }    /* Allocate our buffer to that size */  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Allocating %d bytes for seed file read buffer\n", (int)(sizeof(char) * (bufsize + 1)));  #endif  string_seed = calloc(sizeof(char), bufsize + 1);  if (string_seed) {  /* Read the seed file into the buffer */  new_len = fread(string_seed, sizeof(char), bufsize, sf);  if (ferror (sf) != 0) {  char b[BUFSIZ];  sprintf(b, "Cannot read seed file input: %s. Exiting.\n", seedfilein);  perror (b);  garbage_collector();  exit (1);  }  //else {  //string_seed[newLen++] = '\0'; /* Forces NULL termination. */  //}  string_seed_len = bufsize;  } else {  perror ("Cannot allocate memory for buffer. Exiting.\n");  garbage_collector();  exit (1);  }  }  fclose(sf);  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Seed file opened: %s\n[DEBUG] Seed read from file: %*s\n", seedfilein, string_seed_len-1, string_seed);  #endif  }  }    /*   * Initialize random numbers generator with prng_seed, if passed   */  if (!prng_seed) {  long now;  /* If no prng_seed is specified, use srand with current time.   * This is cryptographically bad!   */  srand(time(&now));  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Initialized PRNG to current time - value: %ld\n", now);  #endif  } else {  if (prng_seed < 0) {  char b[BUFSIZ];  sprintf(b, "Wrong prng_seed provided: value %d is illegal. Exiting.", prng_seed);  perror (b);  exit(1);  }  srand(prng_seed);  #ifdef DEBUG  fprintf(stderr, "[DEBUG] Initialized PRNG to provided value: %d\n", prng_seed);  #endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!