Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- telnet 127.0.0.1 30000
- #include "../includes/Main.h"
- void handle_shutdown(int sig){
- if(sock)
- close(sock);
- fclose(lg);
- fclose(usr);
- printf("nInterrupt has been expected!n");
- exit(0);
- }
- void login(int sock){
- char buffer[20];
- say(sock, "Enter your login: ");
- read_in(sock, buffer, sizeof(buffer));
- char temp[20];
- int trash;
- while(fscanf(usr, "%s%i", temp, trash) != EOF){
- if(!strcmp(temp, buffer)){
- say(sock, "User with the same login doesn't exist!n");
- char result[100];
- sprintf(result, "Tried to connect with login %s.", buffer);
- log(result);
- return;
- }
- }
- char result[50];
- sprintf(result, "./users/%s.txt", buffer);
- FILE *cUser = fopen(result, "r");
- char pass[20];
- fscanf(cUser, "%s", pass);
- say(sock, "Enter your password: ");
- char p[20];
- read_in(sock, p, sizeof(p));
- if(!strcmp(pass, p)){
- char result[100];
- sprintf(result, "User with login %s is now online.", buffer);
- log(result);
- say(sock, "Successful!");
- }else{
- char result[100];
- sprintf(result, "Tryed to login with invalide password as %s.", buffer);
- log(result);
- say(sock, "Invalide password!n");
- }
- }
- void reg(int sock){
- char buffer[20];
- say(sock, "Enter your login: ");
- read_in(sock, buffer, sizeof(buffer));
- char temp[20];
- int trash;
- while(fscanf(usr, "%s%i", temp, trash) != EOF){
- say(sock, temp);
- if(!strstr(temp, buffer) || buffer[0] == '