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");
}
Armazenando a senha de sua carteira Bitcoin de forma segura no Linux
Enviar mensagem ao usuário trabalhando com as opções do php.ini
Meu Fork do Plugin de Integração do CVS para o KDevelop
Compartilhando a tela do Computador no Celular via Deskreen
Como Configurar um Túnel SSH Reverso para Acessar Sua Máquina Local a Partir de uma Máquina Remota
Compartilhamento de Rede com samba em modo Público/Anônimo de forma simples, rápido e fácil
Cups: Mapear/listar todas as impressoras de outro Servidor CUPS de forma rápida e fácil
Criando uma VPC na AWS via CLI