Advertisement
Guest User

Untitled

a guest
Oct 13th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <openssl/ssl.h>
  3.  
  4. #include <openssl/bio.h>
  5. #include <openssl/err.h>
  6.  
  7. #include "config.h"
  8.  
  9. extern BIO *bio;
  10. extern BIO *out;
  11.  
  12. void get_package(char *package, char *filename)
  13. {
  14. short i;
  15. char *error_code;
  16.  
  17. char contents[1536];
  18.  
  19. /* create GET request */
  20. if (BIO_printf(bio, "GET %s HTTP/1.1\r\nHost: %s\r\n\r\n", package, HOST[0]) == -1)
  21. fprintf(stderr, "could not create get request");
  22.  
  23. BIO_read(bio, contents, sizeof(contents));
  24.  
  25. /* check for 404 error */
  26. for (i = 0; i < 23; i++) {
  27. sprintf(error_code, "%c", contents[i]);
  28. }
  29.  
  30. if (strncmp(error_code, "HTTP/1.1 404 Not Found", 24))
  31. fprintf(stderr, "404 not found\n");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement