Enviado em 31/01/2014 - 05:09h
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
FILE *diarie;
char *options[] = {
":changeFile:\n",
":help:\n",
":end:\n"
};
static void fatal(const char *msg) {
fprintf(stderr, msg);
};
static int configure();
static void help();
static void print_usage();
static void ch_file(const char*);
int main(int argc, char *argv[]) {
char usrtyping[200];
if(!argv[1])
print_usage();
if(configure(argv[1])) {
fatal("Error: cannot open, write or the file does not exist.\n");
return 1;
}
printf("Welcome to the Diarie!\n");
printf("Digit all your shit here, digit :end: to exit.\n"
"Digit :help: to get a simple information.\n");
do {
gets(usrtyping);
strcat(usrtyping, "\n");
fprintf(diarie, usrtyping);
if(!strcmp(usrtyping, options[0])) {
char newFile[200];
printf("Ok, now digit the new file:\n");
gets(newFile);
ch_file(newFile);
} else if(!strcmp(usrtyping, options[1])) {
help();
}
fflush(diarie);
} while(strcmp(usrtyping, options[2]));
return 0;
}
static void print_usage() {
printf("diarie <text-file>\n\n");
help();
exit(1);
}
static int configure(const char *text_file) {
diarie = fopen(text_file, "w");
if(diarie == NULL) {
return 1;
}
return 0;
}
static inline void help() {
printf("Diarie is a simple diarie software for you write\n"
"Your bigger secrets, dirty little secrets, conplainings,\n"
"sexual experiencies and so on. Everything in insecure\n"
"text files whose anyone can see. Including your mother,\n"
"father, sons, girlfriend, aunts, etc...\n\n");
printf("Actions for you perform operations while the diarie is\n"
"running are provided typing a word between \"::\".\n"
"This way the sintax is: :<word>:.\n"
"Available words are:\n"
"changeFile -- for change the text file you write.\n"
"help -- display this help message.\n"
"end -- to end the diarie and flush your all secrets.\n\n"
"Security flaws available for exploit:\n"
"Possible buffer overflow in variable usrtyping.\n\n"
"Limitations:\n"
"For a while, Diarie cannot edit an already written file\n"
"because the developer still know not how to implement this.\n"
"And too de developer don't know how to don't print the commands\n"
"like :help: in the diarie.\n"
"(Laught as most you want.)\n\n");
}
static void ch_file(const char *newFile) {
if(configure(newFile))
fatal("File changing failed.\n");
else
printf("Success! Now continue to digit your bigger secrets.\n");
}
Comparação entre os escalonadores BFQ e MQ-Deadline (acesso a disco) no Arch e Debian
Conciliando o uso da ZRAM e SWAP em disco na sua máquina
Servidor de Backup com Ubuntu Server 24.04 LTS, RAID e Duplicati (Dell PowerEdge T420)
Visualizar câmeras IP ONVIF no Linux sem necessidade de instalar aplicativos
Converter os repositórios Debian para o novo formato com as chaves
Instalando Spotify no Debian 13
Realizar overclock no Miyoo Mini (plus ou normal)
Monitoramento pfsense com zabbix (4)
Erro na inicialização do Debian como resolver (5)
Dúvidas sobre a originalidade de conteúdos online (11)
linux mint reconhece microfone de lapela como fone de ouvido sem micro... (4)