- while (!ua.quit) {
- stat = bnet_recv(ua.UA_sock);
- if (stat > 0) {
- strncpy(cmd, ua.UA_sock->msg, sizeof(cmd));
- cmd[sizeof(cmd)-1] = 0; /* ensure it is terminated/trucated */
- parse_command_args(&ua);
- if (ua.argc > 0 && ua.argk[0][0] == '.') {
- do_a_dot_command(&ua, cmd);
- } else {
- do_a_command(&ua, cmd);
- }
- if (!ua.quit) {
- if (ua.auto_display_messages) {
- strcpy(cmd, "messages");
- qmessagescmd(&ua, cmd);
- ua.user_notified_msg_pending = FALSE;
- } else if (!ua.user_notified_msg_pending && console_msg_pending) {
- bsendmsg(&ua, _("You have messages.\n"));
- ua.user_notified_msg_pending = TRUE;
- }
- bnet_sig(ua.UA_sock, BNET_EOD); /* send end of command */
- }
- } else if (stat == 0) {
- if (ua.UA_sock->msglen == BNET_TERMINATE) {
- ua.quit = TRUE;
- break;
- }
- bnet_sig(ua.UA_sock, BNET_POLL);
- } else {
- break; /* error, exit */
+ while (!ua->quit) {
+ if (ua->api) user->signal(BNET_PROMPT);
+ stat = user->recv();
+ if (stat >= 0) {
+ pm_strcpy(ua->cmd, ua->UA_sock->msg);
+ parse_ua_args(ua);
+ if (ua->argc > 0 && ua->argk[0][0] == '.') {
+ do_a_dot_command(ua, ua->cmd);
+ } else {
+ do_a_command(ua, ua->cmd);
+ }
+ if (!ua->quit) {
+ if (console_msg_pending && acl_access_ok(ua, Command_ACL, "messages", 8)) {
+ if (ua->auto_display_messages) {
+ pm_strcpy(ua->cmd, "messages");
+ qmessagescmd(ua, ua->cmd);
+ ua->user_notified_msg_pending = false;
+ } else if (!ua->gui && !ua->user_notified_msg_pending && console_msg_pending) {
+ if (ua->api) {
+ user->signal(BNET_MSGS_PENDING);
+ } else {
+ bsendmsg(ua, _("You have messages.\n"));
+ }
+ ua->user_notified_msg_pending = true;
+ }
+ }
+ if (!ua->api) user->signal(BNET_EOD); /* send end of command */
+ }
+ } else if (is_bnet_stop(user)) {
+ ua->quit = true;
+ } else { /* signal */
+ user->signal(BNET_POLL);