src/terminal.h File Reference

Go to the source code of this file.

Defines

#define TERMINAL_NICK   "HQ"
#define TERMINAL_USER   "hq"
#define TERMINAL_HANDLE   "HQ"
#define TERMINAL_HOST   "terminal"

Functions

int terminal_init (void)
int terminal_shutdown (int runmode)


Define Documentation

#define TERMINAL_HANDLE   "HQ"

Definition at line 27 of file terminal.h.

Referenced by terminal_init().

#define TERMINAL_HOST   "terminal"

Definition at line 28 of file terminal.h.

Referenced by terminal_init().

#define TERMINAL_NICK   "HQ"

Definition at line 25 of file terminal.h.

Referenced by on_putlog(), party_quit(), and terminal_init().

#define TERMINAL_USER   "hq"

Definition at line 26 of file terminal.h.

Referenced by terminal_init().


Function Documentation

int terminal_init ( void   ) 

Definition at line 63 of file terminal.c.

References _, linemode_on(), LOG_MISC, NULL, partychan_join_name(), partymember_new(), putlog(), SOCKBUF_CLIENT, sockbuf_new(), SOCKBUF_NOREAD, sockbuf_set_handler(), sockbuf_set_sock(), TERMINAL_HANDLE, TERMINAL_HOST, TERMINAL_NICK, terminal_session, TERMINAL_USER, user_lookup_by_handle(), user_new(), and user_set_flags_str().

Referenced by core_init().

00064 {
00065   if (terminal_user == NULL) {
00066     terminal_user = user_lookup_by_handle(TERMINAL_HANDLE);
00067     if (terminal_user == NULL) {
00068       terminal_user = user_new(TERMINAL_HANDLE);
00069       user_set_flags_str(terminal_user, NULL, "n");
00070     }
00071   }
00072 
00073   /* Connect an idx to stdin. */
00074   terminal_session.in_idx = sockbuf_new();
00075   sockbuf_set_sock(terminal_session.in_idx, dup(fileno(stdin)), SOCKBUF_CLIENT);
00076   sockbuf_set_handler(terminal_session.in_idx, &terminal_sockbuf_handler, NULL, NULL);
00077   linemode_on(terminal_session.in_idx);
00078 
00079   /* And one for stdout. */
00080   terminal_session.out_idx = sockbuf_new();
00081   sockbuf_set_sock(terminal_session.out_idx, dup(fileno(stdout)), SOCKBUF_NOREAD);
00082 
00083   putlog(LOG_MISC, "*", _("Entering terminal mode."));
00084 
00085   terminal_session.party = partymember_new(-1,
00086     terminal_user, NULL, TERMINAL_NICK, TERMINAL_USER,
00087       TERMINAL_HOST, &terminal_party_handler, NULL, NULL);
00088 
00089   /* Put them on the main channel. */
00090   partychan_join_name("*", terminal_session.party, 0);
00091 
00092   return (0);
00093 }

int terminal_shutdown ( int  runmode  ) 

Definition at line 97 of file terminal.c.

References _, LOG_MISC, NULL, partymember_delete(), putlog(), RUNMODE_RESTART, sockbuf_delete(), sockbuf_set_sock(), terminal_enabled, terminal_session, and user_delete().

Referenced by core_shutdown_or_restart().

00098 {
00099   if (runmode == RUNMODE_RESTART) {
00100     terminal_user = NULL;
00101     return(0);
00102   }
00103 
00104   if (terminal_session.party) {
00105     partymember_delete(terminal_session.party, NULL, _("Shutdown"));
00106     terminal_session.party = NULL;
00107   }
00108 
00109   if (terminal_session.in_idx != -1) {
00110     sockbuf_set_sock(terminal_session.in_idx, -1, 0);
00111     sockbuf_delete(terminal_session.in_idx);
00112     terminal_session.in_idx = -1;
00113   }
00114 
00115   if (terminal_session.out_idx != -1) {
00116     sockbuf_set_sock(terminal_session.out_idx, -1, 0);
00117     sockbuf_delete(terminal_session.out_idx);
00118     terminal_session.out_idx = -1;
00119   }
00120 
00121   if (terminal_user) {
00122     user_delete(terminal_user);
00123     terminal_user = NULL;
00124   }
00125 
00126   /* let logfile.c know that there's no longer the faked
00127    * stdout sockbuf of our HQ partymember */
00128   terminal_enabled = 0;
00129 
00130   putlog(LOG_MISC, "*", _("Leaving terminal mode."));
00131 
00132   return (0);
00133 }


Generated on Sun Nov 30 18:43:37 2008 for eggdrop1.9 by  doxygen 1.5.6