#include <stdio.h>
#include <conio2.h>
#include <stdlib.h>
int leer_usuarios();
int crear_usuarios();
void pinta_encabezado();
void pinta_piedepagina();
int main(int argc, char *argv[])
{
FILE *datos;
char conf;
datos=fopen("archivos.txt","a+");
conf=fgetc(datos);
pinta_encabezado();
if(conf!='*')
{
printf("%c No existen bases de datos, deseas crear una nueva ? (S/N) %c",186,186);
pinta_piedepagina();
gotoxy(71,6);
conf=getch();
if(conf=='s' || conf=='S')
{
crear_usuarios();
}
else exit(1);
}
system("cls");
leer_usuarios();
fclose(datos);
getch();
return 0;
}
int crear_usuarios()
{
int i,j,k,l,conf,iguales;
iguales=0;
conf=0;
FILE *datos;
FILE *base;
datos=fopen("archivos.txt","a+");
char nombre[30];
char contra[20];
char conf_contra[20];
system("cls");
pinta_encabezado();
printf("%c Introduzca el nombre(max 30 caracteres): %c",186,186);
pinta_piedepagina();
gotoxy(48,6);
textcolor(11);
gets(nombre);
textcolor(15);
while(conf==0)
{
system("cls");
pinta_encabezado();
printf("%c Introduzca la contrase%ca (max 20 caracteres): %c",186,164,186);
pinta_piedepagina();
gotoxy(53,6);
textcolor(11);
gets(contra);
textcolor(15);
system("cls");
pinta_encabezado();
printf("%c Confirma la contrase%ca (max 20 caracteres): %c",186,164,186);
pinta_piedepagina();
gotoxy(51,6);
textcolor(11);
gets(conf_contra);
textcolor(15);
for(i=0; i<30; i++){
if(nombre[i]==0)break;
}
for(j=0; j<20; j++){
if(contra[j]==0)break;
}
for(k=0; k<20; k++){
if(conf_contra[k]==0)break;
}
if(j==k)
{
for(l=0; l<j; l++)
{
if(contra[l]==conf_contra[l])iguales++;
}
if(iguales==j)conf=1;
}
}
fprintf(datos,"*\n");
fputs(nombre,datos);
fprintf(datos,"\n");
base=fopen(nombre,"a+");
fclose(base);
fclose(datos);
return 0;
}
int leer_usuarios()
{
struct usuarios{
char nombre[30];
char contra[20];
} usuarios[10];
FILE* datos;
pinta_encabezado();
pinta_piedepagina();
return 0;
}
void pinta_encabezado()
{
textcolor(15);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",201,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,187);
printf("%c GESTOR DE CONTRASE%CAS %c",186,165,186);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,185);
printf("%c %c",186,186);
printf("%c %c",186,186);
}
void pinta_piedepagina()
{
textcolor(15);
int x,i;
x=wherex();
x=15-x;
for(i=x; i>0; i--){
printf("%c %c",186,186);
}
printf("%c %c",186,186);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",204,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,185);
printf("%c Gestor de contrase%cas v1.1 alpha %c",186,164,186);
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c",200,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,205,188);
}