Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char **usernames = {"paul","andrei","cipri","truta"};
- char **passwords = {"1","1","1","1"};
- int userCount = 4;
- while((rlen = read(cli->connfd, buff_in, sizeof(buff_in)-1)) > 0){
- buff_in[rlen] = '\0';
- buff_out[0] = '\0';
- strip_newline(buff_in);
- /* Ignore empty buffer */
- if(!strlen(buff_in)){
- continue;
- }
- /* Special options */
- if(buff_in[0] == '\\'){
- char *command, *username, *password;
- command = strtok(buff_in," ");
- if(!strcmp(command, "\\LOGIN")){
- username = strtok(NULL, " ");
- password = strtok(NULL, " ");
- if(username&&password){
- if(checkLogin(username,password)){
- cli->login=1;
- strcpy(cli->name,username);
- sprintf(buff_out, "<<%s loged in \r\n", cli->name);
- send_message_all(buff_out);
- }else{
- send_message_self("<<WRONG USERNAME/PASSWORD\r\n", cli->connfd);
- }
- }else{
- send_message_self("<<WRONG USERNAME/PASSWORD\r\n", cli->connfd);
- }
- }else{
- send_message_self("<<UNKOWN COMMAND\r\n", cli->connfd);
- }
- }else{
- /* Send message */
- sprintf(buff_out, "[%s] %s\r\n", cli->name, buff_in);
- send_message(buff_out, cli->uid);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement