diff --git a/C/colleen b/C/colleen index ba00379..8497f4d 100755 Binary files a/C/colleen and b/C/colleen differ diff --git a/C/colleen.c b/C/colleen.c index 9de23a8..f3317ae 100644 --- a/C/colleen.c +++ b/C/colleen.c @@ -2,7 +2,8 @@ /* Le commentaire en dehores du programme */ void the_fonction_needed(void){ - printf("YO\n"); + //BEGIN + //END return; } diff --git a/REPLICA/replica b/REPLICA/replica index 1e66733..cc869f0 100755 Binary files a/REPLICA/replica and b/REPLICA/replica differ diff --git a/REPLICA/replica.c b/REPLICA/replica.c index 47ede0c..f6ae744 100644 --- a/REPLICA/replica.c +++ b/REPLICA/replica.c @@ -1,12 +1,78 @@ -#include -int main(int argc, char** argv){ - if (argc != 2) - return 0; - int fd = open(argv[1], O_RDONLY); - if (fd == -1) - { - printf("fail opening file\n"); - return 1; - } - return 0; +#include +#include +#include +#include + +static char *escape_str(const char *str) +{ + if (!str || !str[0]) + return NULL; + + size_t size = strlen(str); + char *out = malloc(size * 2 + 1); + if (!out) + return NULL; + + size_t j = 0; + for (size_t i = 0; i < size; i++) + { + if (str[i] == '\n') { out[j++] = '\\'; out[j++] = 'n'; } + else if (str[i] == '\t') { out[j++] = '\\'; out[j++] = 't'; } + else if (str[i] == '\r') { out[j++] = '\\'; out[j++] = 'r'; } + else if (str[i] == '\\') { out[j++] = '\\'; out[j++] = '\\'; } + else if (str[i] == '"') { out[j++] = '\\'; out[j++] = '"'; } + else if (!isprint((unsigned char)str[i])) + out[j++] = '?'; + else + out[j++] = str[i]; + } + out[j] = '\0'; + return out; +} + +static char *escape_double_quote(const char *str) +{ + if (!str || !str[0]) + return NULL; + + size_t size = strlen(str); + char *out = malloc(size * 2 + 1); + if (!out) + return NULL; + + size_t j = 0; + for (size_t i = 0; i < size; i++) + { + if (str[i] == '"') { out[j++] = '\\'; out[j++] = '"'; } + else if (!isprint((unsigned char)str[i])) + out[j++] = '?'; + else + out[j++] = str[i]; + } + out[j] = '\0'; + return out; +} + +static into_insert_section(void) + +int main(int argc, char **argv) +{ + if (argc != 2) + return 1; + + FILE *in = fopen(argv[1], "r+"); + char* line = NULL; + size_t rded = 0; + if (!in) + return 1; + while (1){ + if (getline(&line, &rded, in) == -1) + break; + printf("%s", line); + free(line); + line = NULL; + } + free(line); + fclose(in); + return 0; }