minor, but important fixes for client part
This commit is contained in:
@@ -41,7 +41,6 @@ enum user_privileges {
|
|||||||
|
|
||||||
enum error_reason {
|
enum error_reason {
|
||||||
NO_REASON,
|
NO_REASON,
|
||||||
LOGIN,
|
|
||||||
EXIT,
|
EXIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ void server_main_loop(server_data_t *s_d) {
|
|||||||
if (line != NULL && res) {
|
if (line != NULL && res) {
|
||||||
perform_session_action(sess, line, s_d);
|
perform_session_action(sess, line, s_d);
|
||||||
free(line);
|
free(line);
|
||||||
if (process_error(sess)) {
|
if (sess->state == ERR) {
|
||||||
close_session(connections, i);
|
close_session(connections, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-23
@@ -76,29 +76,9 @@ int login(session *sess, char *pass) {
|
|||||||
session_send_string(sess, tmp_string);
|
session_send_string(sess, tmp_string);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
sess->state = ERR;
|
sprintf(tmp_string, "login_again>\n");
|
||||||
sess->reason = EXIT;
|
session_send_string(sess, tmp_string);
|
||||||
|
sess->state = OP_LOGIN_USR;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns 1 if session needs to be closed, 0 - in the opposite case */
|
|
||||||
int process_error(session *sess) {
|
|
||||||
if (sess->state == ERR) {
|
|
||||||
switch (sess->reason) {
|
|
||||||
case NO_REASON:
|
|
||||||
case EXIT:
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
case LOGIN:
|
|
||||||
session_send_string(sess,
|
|
||||||
"Can't find the user with such credentials\04\n");
|
|
||||||
sess->state = OP_LOGIN_USR;
|
|
||||||
sess->reason = NO_REASON;
|
|
||||||
session_send_string(sess, "login_again> ");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,6 +3,5 @@
|
|||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
int login(session *sess, char *pass);
|
int login(session *sess, char *pass);
|
||||||
int process_error(session *sess);
|
|
||||||
int process_user_name(char *uname, session *sess);
|
int process_user_name(char *uname, session *sess);
|
||||||
#endif
|
#endif
|
||||||
Reference in New Issue
Block a user