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");
}
Atualizando o Passado: Linux no Lenovo G460 em 2025
aaPanel - Um Painel de Hospedagem Gratuito e Poderoso
O macete do Warsaw no Linux Mint e cia
O que você quer para sua vida ao usar o Linux?
Visualizar arquivos em formato markdown (ex.: README.md) pelo terminal
Dando - teoricamente - um gás no Gnome-Shell do Arch Linux
Audio intermitente xubuntu notebook positivo c14 vision (0)
Encontrar o comando completo de uma janela [RESOLVIDO] (2)
Instalação de Ubuntu em SSD (interno) como se fosse um dispositivo ext... (2)
Zorin OS - Virtual Box não consigo abrir maquinas virtuais (10)