|
|
@@ -53,6 +53,8 @@ int do_cmd_uinfo(char *);
|
|
|
int do_cmd_lself(char *);
|
|
|
int do_cmd_incr(char *);
|
|
|
int do_cmd_cqd(char *);
|
|
|
+int do_cmd_ban(char *);
|
|
|
+int do_cmd_unban(char *);
|
|
|
|
|
|
int read_msg(struct vcc_request *);
|
|
|
int vcc_create_session(char *name);
|
|
|
@@ -61,6 +63,7 @@ int incr_score(char *username, int incr);
|
|
|
int send_msg(char *msg, char *s);
|
|
|
int encrypt(char *s);
|
|
|
|
|
|
+extern str_t banned_people[BAN_SIZE];
|
|
|
extern char usrname[];
|
|
|
extern int rate;
|
|
|
extern int current_sid;
|
|
|
@@ -87,7 +90,8 @@ struct cmdtable {
|
|
|
{ "-lself", do_cmd_lself, "Reload information of myself. " },
|
|
|
{ "-incr", do_cmd_incr, "Increase one's score (root required). " },
|
|
|
{ "-cqd", do_cmd_cqd, "Raise CQD. " },
|
|
|
-
|
|
|
+ { "-ban", do_cmd_ban, "Don't receive more messages from somebody. " },
|
|
|
+ { "-unban", do_cmd_unban, "Receive more messages from somebody. " },
|
|
|
{ NULL, NULL, NULL }
|
|
|
};
|
|
|
|
|
|
@@ -383,3 +387,49 @@ int do_cmd_cqd(char *s) {
|
|
|
}
|
|
|
|
|
|
|
|
|
+int do_cmd_ban(char *s) {
|
|
|
+ char *people_name;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ (void) s;
|
|
|
+
|
|
|
+ people_name = malloc(USRNAME_SIZE + 1);
|
|
|
+
|
|
|
+ printf("Enter the user to ban: ");
|
|
|
+ scanf("%s", people_name);
|
|
|
+
|
|
|
+ for (i = 0; i < BAN_SIZE; ++i) {
|
|
|
+ if (!banned_people[i]) {
|
|
|
+ banned_people[i] = people_name;
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ else if (!strcmp(people_name, banned_people[i])) {
|
|
|
+ printf("User %s is already banned", people_name);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ printf("Cannot ban the user");
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+int do_cmd_unban(char *s) {
|
|
|
+ char *people_name;
|
|
|
+ int i;
|
|
|
+
|
|
|
+ (void) s;
|
|
|
+
|
|
|
+ people_name = malloc(USRNAME_SIZE + 1);
|
|
|
+
|
|
|
+ printf("Enter the user to unban: ");
|
|
|
+ scanf("%s", people_name);
|
|
|
+
|
|
|
+ for (i = 0; i < BAN_SIZE; ++i) {
|
|
|
+ if (banned_people[i] && !strcmp(people_name, banned_people[i])) {
|
|
|
+ free(banned_people[i]);
|
|
|
+ banned_people[i] = NULL;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ free(people_name);
|
|
|
+ return 0;
|
|
|
+}
|