src/mod/ctcp.mod/ctcp.c File Reference

#include "ctcp.h"
#include "src/mod/module.h"
#include "server.mod/server.h"
#include <netinet/in.h>
#include <arpa/inet.h>
Include dependency graph for ctcp.c:

Go to the source code of this file.

Defines

#define MODULE_NAME   "ctcp"
#define MAKING_CTCP

Functions

static int ctcp_FINGER (char *nick, char *uhost, char *handle, char *object, char *keyword, char *text)
static int ctcp_ECHOERR (char *nick, char *uhost, char *handle, char *object, char *keyword, char *text)
static int ctcp_PING (char *nick, char *uhost, char *handle, char *object, char *keyword, char *text)
static int ctcp_VERSION (char *nick, char *uhost, char *handle, char *object, char *keyword, char *text)
static int ctcp_USERINFO (char *nick, char *uhost, char *handle, char *object, char *keyword, char *text)
static int ctcp_CLIENTINFO (char *nick, char *uhosr, char *handle, char *object, char *keyword, char *msg)
static int ctcp_TIME (char *nick, char *uhost, char *handle, char *object, char *keyword, char *text)
static int ctcp_CHAT (char *nick, char *uhost, char *handle, char *object, char *keyword, char *text)
static char * ctcp_close ()
EXPORT_SCOPE char * ctcp_start ()
char * ctcp_start (Function *global_funcs)

Variables

static Functionglobal = 0
static Functionserver_funcs = 0
static char ctcp_version [121]
static char ctcp_finger [121]
static char ctcp_userinfo [121]
static int ctcp_mode = 0
static cmd_t myctcp []
static tcl_strings mystrings []
static tcl_ints myints []
static Function ctcp_table []

Define Documentation

#define MAKING_CTCP

Definition at line 27 of file ctcp.c.

#define MODULE_NAME   "ctcp"

Definition at line 26 of file ctcp.c.


Function Documentation

static int ctcp_CHAT ( char *  nick,
char *  uhost,
char *  handle,
char *  object,
char *  keyword,
char *  text 
) [static]

Definition at line 143 of file ctcp.c.

References ctcp_reply, dcc, dcc_total, DCT_LISTEN, DP_SERVER, dprintf, userrec::flags, get_user_by_handle, getmyip, iptolong, natip, require_p, simple_sprintf, u_pass_match, USER_OP, USER_PARTY, USER_XFER, and userlist.

00145 {
00146   struct userrec *u = get_user_by_handle(userlist, handle);
00147   int atr = u ? u->flags : 0, i;
00148 
00149   if ((atr & (USER_PARTY | USER_XFER)) || ((atr & USER_OP) && !require_p)) {
00150 
00151     if (u_pass_match(u, "-")) {
00152       simple_sprintf(ctcp_reply, "%s\001ERROR no password set\001",
00153                      ctcp_reply);
00154       return 1;
00155     }
00156 
00157     for (i = 0; i < dcc_total; i++) {
00158       if ((dcc[i].type->flags & DCT_LISTEN) &&
00159           (!strcmp(dcc[i].nick, "(telnet)") ||
00160            !strcmp(dcc[i].nick, "(users)"))) {
00161         /* Do me a favour and don't change this back to a CTCP reply,
00162          * CTCP replies are NOTICE's this has to be a PRIVMSG
00163          * -poptix 5/1/1997 */
00164         dprintf(DP_SERVER, "PRIVMSG %s :\001DCC CHAT chat %lu %u\001\n",
00165                 nick, iptolong(natip[0] ? (IP) inet_addr(natip) : getmyip()),
00166                 dcc[i].port);
00167         return 1;
00168       }
00169     }
00170     simple_sprintf(ctcp_reply, "%s\001ERROR no telnet port\001", ctcp_reply);
00171   }
00172   return 1;
00173 }

static int ctcp_CLIENTINFO ( char *  nick,
char *  uhosr,
char *  handle,
char *  object,
char *  keyword,
char *  msg 
) [static]

Definition at line 88 of file ctcp.c.

References CLIENTINFO, CLIENTINFO_ACTION, CLIENTINFO_CLIENTINFO, CLIENTINFO_DCC, CLIENTINFO_ECHO, CLIENTINFO_ERRMSG, CLIENTINFO_FINGER, CLIENTINFO_PING, CLIENTINFO_SED, CLIENTINFO_TIME, CLIENTINFO_USERINFO, CLIENTINFO_UTC, CLIENTINFO_VERSION, ctcp_mode, ctcp_reply, egg_strcasecmp, NULL, and simple_sprintf.

00090 {
00091   char *p = NULL;
00092 
00093   if (ctcp_mode == 1)
00094     return 1;
00095   else if (!msg[0])
00096     p = CLIENTINFO;
00097   else if (!egg_strcasecmp(msg, "sed"))
00098     p = CLIENTINFO_SED;
00099   else if (!egg_strcasecmp(msg, "version"))
00100     p = CLIENTINFO_VERSION;
00101   else if (!egg_strcasecmp(msg, "clientinfo"))
00102     p = CLIENTINFO_CLIENTINFO;
00103   else if (!egg_strcasecmp(msg, "userinfo"))
00104     p = CLIENTINFO_USERINFO;
00105   else if (!egg_strcasecmp(msg, "errmsg"))
00106     p = CLIENTINFO_ERRMSG;
00107   else if (!egg_strcasecmp(msg, "finger"))
00108     p = CLIENTINFO_FINGER;
00109   else if (!egg_strcasecmp(msg, "time"))
00110     p = CLIENTINFO_TIME;
00111   else if (!egg_strcasecmp(msg, "action"))
00112     p = CLIENTINFO_ACTION;
00113   else if (!egg_strcasecmp(msg, "dcc"))
00114     p = CLIENTINFO_DCC;
00115   else if (!egg_strcasecmp(msg, "utc"))
00116     p = CLIENTINFO_UTC;
00117   else if (!egg_strcasecmp(msg, "ping"))
00118     p = CLIENTINFO_PING;
00119   else if (!egg_strcasecmp(msg, "echo"))
00120     p = CLIENTINFO_ECHO;
00121   if (p == NULL) {
00122     simple_sprintf(ctcp_reply,
00123                    "%s\001ERRMSG CLIENTINFO: %s is not a valid function\001",
00124                    ctcp_reply, msg);
00125   } else
00126     simple_sprintf(ctcp_reply, "%s\001CLIENTINFO %s\001", ctcp_reply, p);
00127   return 1;
00128 }

static char* ctcp_close (  )  [static]

Definition at line 200 of file ctcp.c.

References H_ctcp, MODULE_NAME, module_undepend, NULL, rem_builtins, rem_help_reference, rem_tcl_ints, and rem_tcl_strings.

00201 {
00202   rem_tcl_strings(mystrings);
00203   rem_tcl_ints(myints);
00204   rem_builtins(H_ctcp, myctcp);
00205   rem_help_reference("ctcp.help");
00206   module_undepend(MODULE_NAME);
00207   return NULL;
00208 }

static int ctcp_ECHOERR ( char *  nick,
char *  uhost,
char *  handle,
char *  object,
char *  keyword,
char *  text 
) [static]

Definition at line 51 of file ctcp.c.

References ctcp_mode, ctcp_reply, and simple_sprintf.

00053 {
00054   if (ctcp_mode != 1 && strlen(text) <= 80)
00055     simple_sprintf(ctcp_reply, "%s\001%s %s\001", ctcp_reply, keyword, text);
00056   return 1;
00057 }

static int ctcp_FINGER ( char *  nick,
char *  uhost,
char *  handle,
char *  object,
char *  keyword,
char *  text 
) [static]

Definition at line 43 of file ctcp.c.

References ctcp_finger, ctcp_mode, ctcp_reply, and simple_sprintf.

00045 {
00046   if (ctcp_mode != 1 && ctcp_finger[0])
00047     simple_sprintf(ctcp_reply, "%s\001FINGER %s\001", ctcp_reply, ctcp_finger);
00048   return 1;
00049 }

static int ctcp_PING ( char *  nick,
char *  uhost,
char *  handle,
char *  object,
char *  keyword,
char *  text 
) [static]

Definition at line 59 of file ctcp.c.

References ctcp_mode, ctcp_reply, userrec::flags, get_user_by_handle, simple_sprintf, USER_OP, and userlist.

00061 {
00062   struct userrec *u = get_user_by_handle(userlist, handle);
00063   int atr = u ? u->flags : 0;
00064 
00065   if ((ctcp_mode != 1 || (atr & USER_OP)) && strlen(text) <= 80)
00066     simple_sprintf(ctcp_reply, "%s\001%s %s\001", ctcp_reply, keyword, text);
00067   return 1;
00068 }

char* ctcp_start ( Function global_funcs  ) 

Definition at line 219 of file ctcp.c.

References add_builtins, add_help_reference, add_tcl_ints, add_tcl_strings, ctcp_finger, ctcp_table, ctcp_userinfo, ctcp_version, global, H_ctcp, module_depend, MODULE_NAME, module_register, module_undepend, NULL, server_funcs, and ver.

00220 {
00221   global = global_funcs;
00222 
00223   module_register(MODULE_NAME, ctcp_table, 1, 0);
00224   if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) {
00225     module_undepend(MODULE_NAME);
00226     return "This module requires Eggdrop 1.6.0 or later.";
00227   }
00228   if (!(server_funcs = module_depend(MODULE_NAME, "server", 1, 0))) {
00229     module_undepend(MODULE_NAME);
00230     return "This module requires server module 1.0 or later.";
00231   }
00232   add_tcl_strings(mystrings);
00233   add_tcl_ints(myints);
00234   add_builtins(H_ctcp, myctcp);
00235   add_help_reference("ctcp.help");
00236   if (!ctcp_version[0]) {
00237     strncpy(ctcp_version, ver, 120);
00238     ctcp_version[120] = 0;
00239   }
00240   if (!ctcp_finger[0]) {
00241     strncpy(ctcp_finger, ver, 120);
00242     ctcp_finger[120] = 0;
00243   }
00244   if (!ctcp_userinfo[0]) {
00245     strncpy(ctcp_userinfo, ver, 120);
00246     ctcp_userinfo[120] = 0;
00247   }
00248   return NULL;
00249 }

EXPORT_SCOPE char* ctcp_start (  ) 
static int ctcp_TIME ( char *  nick,
char *  uhost,
char *  handle,
char *  object,
char *  keyword,
char *  text 
) [static]

Definition at line 130 of file ctcp.c.

References ctcp_mode, ctcp_reply, now, and simple_sprintf.

00132 {
00133   char tms[25];
00134 
00135   if (ctcp_mode == 1)
00136     return 1;
00137   strncpy(tms, ctime(&now), 24);
00138   tms[24] = 0;
00139   simple_sprintf(ctcp_reply, "%s\001TIME %s\001", ctcp_reply, tms);
00140   return 1;
00141 }

static int ctcp_USERINFO ( char *  nick,
char *  uhost,
char *  handle,
char *  object,
char *  keyword,
char *  text 
) [static]

Definition at line 79 of file ctcp.c.

References ctcp_mode, ctcp_reply, ctcp_userinfo, and simple_sprintf.

00081 {
00082   if (ctcp_mode != 1 && ctcp_userinfo[0])
00083     simple_sprintf(ctcp_reply, "%s\001USERINFO %s\001", ctcp_reply,
00084                    ctcp_userinfo);
00085   return 1;
00086 }

static int ctcp_VERSION ( char *  nick,
char *  uhost,
char *  handle,
char *  object,
char *  keyword,
char *  text 
) [static]

Definition at line 70 of file ctcp.c.

References ctcp_mode, ctcp_reply, ctcp_version, and simple_sprintf.

00072 {
00073   if (ctcp_mode != 1 && ctcp_version[0])
00074     simple_sprintf(ctcp_reply, "%s\001VERSION %s\001", ctcp_reply,
00075                    ctcp_version);
00076   return 1;
00077 }


Variable Documentation

char ctcp_finger[121] [static]

Definition at line 38 of file ctcp.c.

Referenced by ctcp_FINGER(), and ctcp_start().

int ctcp_mode = 0 [static]
Function ctcp_table[] [static]
Initial value:

Definition at line 212 of file ctcp.c.

Referenced by ctcp_start().

char ctcp_userinfo[121] [static]

Definition at line 39 of file ctcp.c.

Referenced by ctcp_start(), and ctcp_USERINFO().

char ctcp_version[121] [static]

Definition at line 37 of file ctcp.c.

Referenced by ctcp_start(), and ctcp_VERSION().

Function* global = 0 [static]

Definition at line 35 of file ctcp.c.

cmd_t myctcp[] [static]
Initial value:
 {
  {"FINGER",     "",   ctcp_FINGER,      0 },
  {"ECHO",       "",   ctcp_ECHOERR,     0 },
  {"PING",       "",   ctcp_PING,        0 },
  {"ERRMSG",     "",   ctcp_ECHOERR,     0 },
  {"VERSION",    "",   ctcp_VERSION,     0 },
  {"USERINFO",   "",   ctcp_USERINFO,    0 },
  {"CLIENTINFO", "",   ctcp_CLIENTINFO,  0 },
  {"TIME",       "",   ctcp_TIME,        0 },
  {"CHAT",       "",   ctcp_CHAT,        0 },
  { 0 ,          0 ,  0 ,             0 }
}

Definition at line 175 of file ctcp.c.

tcl_ints myints[] [static]
Initial value:
 {
  {"ctcp-mode", &ctcp_mode},
  { 0 ,               0 }
}

Definition at line 195 of file ctcp.c.

tcl_strings mystrings[] [static]
Initial value:
 {
  {"ctcp-version",  ctcp_version,  120, 0},
  {"ctcp-finger",   ctcp_finger,   120, 0},
  {"ctcp-userinfo", ctcp_userinfo, 120, 0},
  { 0 ,             0 ,          0,   0}
}

Definition at line 188 of file ctcp.c.

Function * server_funcs = 0 [static]

Definition at line 35 of file ctcp.c.

Referenced by ctcp_start(), and send_uptime().


Generated on 7 Sep 2016 for Eggdrop by  doxygen 1.6.1