Skip to content

Instantly share code, notes, and snippets.

@xpn
Last active April 15, 2016 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xpn/818cd1ce474e86adc23eb62637d56e6b to your computer and use it in GitHub Desktop.
Save xpn/818cd1ce474e86adc23eb62637d56e6b to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
void print_success(void *input) {
if (*(char *)(input+1) == 'Y') {
printf("GOT: %s\n", input);
return;
}
return;
}
void test(void *input) {
char buffer[1024];
if (*(char *)input == 'Z') {
strcpy(buffer, input);
print_success(buffer);
return;
}
printf("FAIL\n");
return;
}
int main(int argc, char **argv) {
char buffer[9076];
int fd = open(argv[1], O_RDONLY);
read(fd, buffer, 9076);
test(buffer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment