feat(grace): adding a working version
This commit is contained in:
parent
de9fd295d8
commit
4fb3dac7f3
1 changed files with 8 additions and 13 deletions
|
|
@ -1,17 +1,12 @@
|
|||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* Grace - Autoreproduction sans main
|
||||
#define TO_WRITE "#include <stdio.h>%1$c%1$c#define TO_WRITE %3$c%4$s%3$c%1$c#define PROG()int main(void) {%2$cFILE *new_file = fopen(%3$cGrace_kid.c%3$c, %3$cw%3$c);%2$cif (new_file == NULL)%2$c%2$creturn 1;%2$cfprintf(new_file, TO_WRITE, 10, 9, 34, TO_WRITE);%2$cfclose(new_file);%2$creturn 0;}%1$c%1$c/**%1$c * @brief Actually the only is to hide this main on a define%1$c *%1$c * @return 0 on success overwise return 1%1$c */%1$c%1$cPROG()%1$c"
|
||||
#define PROG()int main(void) { FILE *new_file = fopen("Grace_kid.c", "w"); if (new_file == NULL) return 1; fprintf(new_file, TO_WRITE, 10, 9, 34, TO_WRITE); fclose(new_file); return 0;}
|
||||
|
||||
/**
|
||||
* @brief Actually the only is to hide this main on a define
|
||||
*
|
||||
* @return 0 on success overwise return 1
|
||||
*/
|
||||
|
||||
#define OPEN_FILE FILE *kid = fopen("Grace_kid.c", "w"); if (!kid) return;
|
||||
#define WRITE_CODE fprintf(kid, CODE, 10, 9, 34, CODE); fclose(kid);
|
||||
#define CODE "#include <stdio.h>%1$c%1$c/*%1$c * Grace - Autoreproduction sans main%1$c */%1$c%1$c#define OPEN_FILE FILE *kid = fopen(%3$cGrace_kid.c%3$c, %3$cw%3$c); if (!kid) return;%1$c#define WRITE_CODE fprintf(kid, CODE, 10, 9, 34, CODE); fclose(kid);%1$c%1$c#define CODE %3$c%4$s%3$c%1$c%1$c#define MAIN OPEN_FILE WRITE_CODE%1$c%1$cvoid __attribute__((constructor)) grace(void) {%1$c%2$cMAIN%1$c}%1$c%1$cint main(void) { return 0; }%1$c"
|
||||
|
||||
#define MAIN OPEN_FILE WRITE_CODE
|
||||
|
||||
void __attribute__((constructor)) grace(void) {
|
||||
MAIN
|
||||
}
|
||||
|
||||
int main(void) { return 0; }
|
||||
PROG()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue