[srvx-commits] CVS: services/src service.h,1.3,1.4 service.c,1.3,1.4 proto.c,1.76,1.77 mod_common.h,
Brought to you by:
entrope
From: Entrope <en...@us...> - 2001-10-10 04:51:26
|
Update of /cvsroot/srvx/services/src In directory usw-pr-cvs1:/tmp/cvs-serv2931/src Modified Files: service.h service.c proto.c mod_common.h mod_common.c messages.h config.h.in Log Message: start implementing mod_common functions Index: service.h =================================================================== RCS file: /cvsroot/srvx/services/src/service.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** service.h 2001/10/10 04:00:41 1.3 --- service.h 2001/10/10 04:51:23 1.4 *************** *** 34,38 **** struct service_template { dict_t commands; /* string->struct service_command* */ ! struct service_common *common; }; --- 34,38 ---- struct service_template { dict_t commands; /* string->struct service_command* */ ! struct service_template_common *common; }; *************** *** 44,47 **** --- 44,48 ---- void service_init(); struct user *service_create(const char *templ_name, dict_t params); + void service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text); #endif /* !defined(SERVICE_H) */ Index: service.c =================================================================== RCS file: /cvsroot/srvx/services/src/service.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** service.c 2001/10/10 04:00:41 1.3 --- service.c 2001/10/10 04:51:23 1.4 *************** *** 46,50 **** } ! static void service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text) { --- 46,50 ---- } ! void service_chanmsg(struct user *bot, struct user *source, struct channel *chan, char *real_text) { Index: proto.c =================================================================== RCS file: /cvsroot/srvx/services/src/proto.c,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -r1.76 -r1.77 *** proto.c 2001/10/10 04:00:41 1.76 --- proto.c 2001/10/10 04:51:23 1.77 *************** *** 63,68 **** int ret, use_color; ! /* expand the parameters we got .. */ ! chars_sent = 0; /* Normally, I'd pass NULL as the first parameter to vsnprintf. * But guess what? It makes FreeBSD's libc allocate a buffer that it --- 63,68 ---- int ret, use_color; ! /* translate the format string */ ! format = gettext(format); /* Normally, I'd pass NULL as the first parameter to vsnprintf. * But guess what? It makes FreeBSD's libc allocate a buffer that it Index: mod_common.h =================================================================== RCS file: /cvsroot/srvx/services/src/mod_common.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** mod_common.h 2001/10/10 04:00:41 1.2 --- mod_common.h 2001/10/10 04:51:23 1.3 *************** *** 30,34 **** #define COMMON_VERSION MAKE_VERSION(COMMON_MAJOR, COMMON_MINOR, COMMON_REVISION) ! struct service_common { dict_t help; /* help index */ }; --- 30,34 ---- #define COMMON_VERSION MAKE_VERSION(COMMON_MAJOR, COMMON_MINOR, COMMON_REVISION) ! struct service_template_common { dict_t help; /* help index */ }; Index: mod_common.c =================================================================== RCS file: /cvsroot/srvx/services/src/mod_common.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** mod_common.c 2001/10/10 04:00:41 1.3 --- mod_common.c 2001/10/10 04:51:23 1.4 *************** *** 23,28 **** --- 23,30 ---- #include "hash.h" + #include "messages.h" #include "proto.h" #include "recdb.h" + #include "service.h" #include "tools.h" *************** *** 31,44 **** static struct module *common_module; static MODULE_COMMAND(cmd_help) { ! const char *topic; ! struct service_common *cstn; ! struct record_data *rec; (void)channel; cstn = NULL; if (!cstn->help) { ! send_message(user, bot, "%s", "Helpfile missing or internal help system error."); return 0; } --- 33,74 ---- static struct module *common_module; + /* Basic approach for help files: + * + * Each module's "raw" help file contains a set of help topics, which + * correspond to one command exported by the module. Each of these + * topics contains sub-topics, including a default topic (usually + * covering the command itself). For each command bound to the + * service template, look up the appropriate module's raw help entry, + * and prefix the contents of that topic with the bound command name. + * For instance, in mod_authserv_admin.help: + * "oset" { + * "" "This command lets opers set stuff."; + * "options" "blah blah blah"; + * }; + * If "oset" was bound to "oper-set" in the service template, it would + * result in the following help bindings: + * "oper-set" "This command lets opers set stuff."; + * "oper-set options" "blah blah blah"; + */ + static void + common_readhelp(struct user *bot, struct user *user) + { + /* TODO: implement common_readhelp */ + (void)bot; (void)user; + } + + /*******************/ + /* MODULE COMMANDS */ + /*******************/ + static MODULE_COMMAND(cmd_help) { ! const char *topic, *data; ! struct service_template_common *cstn; (void)channel; cstn = NULL; if (!cstn->help) { ! send_message(user, bot, N_("Helpfile missing.")); return 0; } *************** *** 48,61 **** unsplit_string(argv+1, argc-1); topic = argv[1]; - } - if (!(rec = dict_find(cstn->help, topic, NULL))) { - send_message(user, bot, "%s", "No help on that topic."); - return 0; } ! if (rec->type != RECDB_QSTRING) { ! send_message(user, bot, "%s", "Internal help system error."); return 0; } ! send_message(user, bot, "%s", rec->d.qstring); return 0; } --- 78,87 ---- unsplit_string(argv+1, argc-1); topic = argv[1]; } ! if (!(data = dict_find(cstn->help, topic, NULL))) { ! send_message(user, bot, N_("No help on that topic.")); return 0; } ! send_message(user, bot, "%s", data); return 0; } *************** *** 63,75 **** static MODULE_COMMAND(cmd_readhelp) { ! (void)user; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_readhelp */ return 0; } static MODULE_COMMAND(cmd_timecmd) { ! (void)user; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_timecmd */ return 0; } --- 89,123 ---- static MODULE_COMMAND(cmd_readhelp) { ! struct timeval start, stop; ! ! (void)channel; (void)argc; (void)argv; ! gettimeofday(&start, NULL); ! common_readhelp(bot, user); ! gettimeofday(&stop, NULL); ! stop.tv_sec -= start.tv_sec; ! stop.tv_usec -= start.tv_usec; ! if (stop.tv_usec < 0) { ! stop.tv_sec -= 1; ! stop.tv_usec += 1000000; ! } ! send_message(user, bot, N_("Loaded help files for $b%s$b in "FMT_TIME_T".%06lu seconds."), bot->nick, stop.tv_sec, stop.tv_usec); return 0; + return 0; } static MODULE_COMMAND(cmd_timecmd) { ! struct timeval start, stop; ! unsplit_string(argv+1, argc-1); ! gettimeofday(&start, NULL); ! service_chanmsg(bot, user, channel, argv[1]); ! gettimeofday(&stop, NULL); ! stop.tv_sec -= start.tv_sec; ! stop.tv_usec -= start.tv_usec; ! if (stop.tv_usec < 0) { ! stop.tv_sec -= 1; ! stop.tv_usec += 1000000; ! } ! send_message(user, bot, N_("Command $b%s$b finished in "FMT_TIME_T".%06lu seconds."), argv[1], stop.tv_sec, stop.tv_usec); return 0; } *************** *** 82,89 **** } static MODULE_COMMAND(cmd_god) { ! (void)user; (void)bot; (void)channel; (void)argc; (void)argv; ! /* TODO: implement cmd_god */ return 0; } --- 130,166 ---- } + /* TODO: unkludge IsHelping() */ + #define IsHelping(USER) 1 + static MODULE_COMMAND(cmd_god) { ! int new_helping; ! (void)channel; ! ! if (argc > 1) { ! if (enabled_string(argv[1])) new_helping = 1; ! else if (disabled_string(argv[1])) new_helping = 0; ! else { ! send_message(user, bot, MSG_INVALID_BINARY, argv[1]); ! return 0; ! } ! } else { ! new_helping = !IsHelping(user); ! } ! if (new_helping) { ! if (IsHelping(user)) { ! send_message(user, bot, N_("You already have security override enabled.")); ! return 0; ! } ! /* TODO: mark user as helping */ ! send_message(user, bot, N_("Security override has been enabled.")); ! } else { ! if (!IsHelping(user)) { ! send_message(user, bot, N_("You already have security override disabled.")); ! return 0; ! } ! /* TODO: mark user as not helping */ ! send_message(user, bot, N_("Security override has been disabled.")); ! } return 0; } *************** *** 110,113 **** --- 187,191 ---- common_module = module_register("common", COMMON_VERSION, &deps, lib); if (!common_module) return 1; + /* Register functions */ for (nn=0; cmds[nn].name; nn++) { Index: messages.h =================================================================== RCS file: /cvsroot/srvx/services/src/messages.h,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -r1.22 -r1.23 *** messages.h 2001/08/19 03:06:09 1.22 --- messages.h 2001/10/10 04:51:23 1.23 *************** *** 28,73 **** freak. */ ! #define MSG_VERSION "$bsrvx "VERSION"$b ("CODENAME"), Built: " __DATE__ ", " __TIME__"." ! #define MSG_SERVICE_IMMUNE "$b%s$b may not be kicked, killed, banned, or deopped." ! #define MSG_SERVICE_PRIVILEGED "$b%s$b is a privileged service." ! #define MSG_COMMAND_UNKNOWN "$b%s$b is an unknown command." ! #define MSG_COMMAND_PRIVILEGED "$b%s$b is a privileged command." ! #define MSG_COMMAND_DISABLED "$b%s$b is a disabled command." ! #define MSG_COMMAND_FLOOD "Too many commands sent, please wait." ! #define MSG_SETTING_PRIVILEGED "$b%s$b is a privileged setting." ! #define MSG_REGISTER_HANDLE "You must first register a handle with $b$N$b." ! #define MSG_AUTHENTICATE "You must first authenticate with $b$N$b." ! #define MSG_USER_AUTHENTICATE "%s must first authenticate with $b$N$b." ! #define MSG_HANDLE_UNKNOWN "Handle $b%s$b has not been registered." ! #define MSG_NICK_UNKNOWN "User with nick $b%s$b does not exist." ! #define MSG_CHANNEL_UNKNOWN "Channel with name $b%s$b does not exist." ! #define MSG_SERVER_UNKNOWN "Server with name $b%s$b does not exist or is not linked." ! #define MSG_NICKS_UNKNOWN "Some of the nicks provided are nonexistent." ! #define MSG_INVALID_GLINE "Invalid G-line '%s'." ! #define MSG_INVALID_DURATION "Invalid time span '%s'." ! #define MSG_INVALID_CHANNEL "You must provide the name of a channel that exists." ! #define MSG_CHANNEL_ABSENT "You aren't currently in $b%s$b." ! #define MSG_MISSING_PARAMS "$b%s$b requires more parameters." ! #define MSG_OPER_SUSPENDED "Your $b$O$b access has been suspended." ! #define MSG_USER_OUTRANKED "$b%s$b outranks you (command has no effect)." ! #define MSG_INVALID_CRITERIA "$b%s$b is an invalid search criteria." ! #define MSG_SEARCH_RESULTS "The following %s matched the criteria of your search:" ! #define MSG_MATCH_COUNT "Found $b%u$b matches." ! #define MSG_NO_MATCHES "Nothing matched the criteria of your search." ! #define MSG_INVALID_BINARY "$b%s$b is an invalid binary value." ! #define IDENT_FORMAT "%s [%s@%s/%ld.%ld.%ld.%ld]" #define IDENT_DATA(user) user->nick, user->username, user->hostname, (user->ip >> 24) & 255, (user->ip >> 16) & 255, (user->ip >> 8) & 255, user->ip & 255 --- 28,73 ---- freak. */ ! #define MSG_VERSION N_("$bsrvx "VERSION"$b ("CODENAME"), Built: " __DATE__ ", " __TIME__".") ! #define MSG_SERVICE_IMMUNE N_("$b%s$b may not be kicked, killed, banned, or deopped.") ! #define MSG_SERVICE_PRIVILEGED N_("$b%s$b is a privileged service.") ! #define MSG_COMMAND_UNKNOWN N_("$b%s$b is an unknown command.") ! #define MSG_COMMAND_PRIVILEGED N_("$b%s$b is a privileged command.") ! #define MSG_COMMAND_DISABLED N_("$b%s$b is a disabled command.") ! #define MSG_COMMAND_FLOOD N_("Too many commands sent, please wait.") ! #define MSG_SETTING_PRIVILEGED N_("$b%s$b is a privileged setting.") ! #define MSG_REGISTER_HANDLE N_("You must first register a handle with $b$N$b.") ! #define MSG_AUTHENTICATE N_("You must first authenticate with $b$N$b.") ! #define MSG_USER_AUTHENTICATE N_("%s must first authenticate with $b$N$b.") ! #define MSG_HANDLE_UNKNOWN N_("Handle $b%s$b has not been registered.") ! #define MSG_NICK_UNKNOWN N_("User with nick $b%s$b does not exist.") ! #define MSG_CHANNEL_UNKNOWN N_("Channel with name $b%s$b does not exist.") ! #define MSG_SERVER_UNKNOWN N_("Server with name $b%s$b does not exist or is not linked.") ! #define MSG_NICKS_UNKNOWN N_("Some of the nicks provided are nonexistent.") ! #define MSG_INVALID_GLINE N_("Invalid G-line '%s'.") ! #define MSG_INVALID_DURATION N_("Invalid time span '%s'.") ! #define MSG_INVALID_CHANNEL N_("You must provide the name of a channel that exists.") ! #define MSG_CHANNEL_ABSENT N_("You aren't currently in $b%s$b.") ! #define MSG_MISSING_PARAMS N_("$b%s$b requires more parameters.") ! #define MSG_OPER_SUSPENDED N_("Your $b$O$b access has been suspended.") ! #define MSG_USER_OUTRANKED N_("$b%s$b outranks you (command has no effect).") ! #define MSG_INVALID_CRITERIA N_("$b%s$b is an invalid search criteria.") ! #define MSG_SEARCH_RESULTS N_("The following %s matched the criteria of your search:") ! #define MSG_MATCH_COUNT N_("Found $b%u$b matches.") ! #define MSG_NO_MATCHES N_("Nothing matched the criteria of your search.") ! #define MSG_INVALID_BINARY N_("$b%s$b is an invalid binary value.") ! #define IDENT_FORMAT N_("%s [%s@%s/%ld.%ld.%ld.%ld]") #define IDENT_DATA(user) user->nick, user->username, user->hostname, (user->ip >> 24) & 255, (user->ip >> 16) & 255, (user->ip >> 8) & 255, user->ip & 255 Index: config.h.in =================================================================== RCS file: /cvsroot/srvx/services/src/config.h.in,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** config.h.in 2001/10/03 00:57:46 1.28 --- config.h.in 2001/10/10 04:51:23 1.29 *************** *** 115,118 **** --- 115,121 ---- #undef HAVE_LIBDMALLOCTH + /* Define if you have the <libintl.h> header file. */ + #undef HAVE_LIBINTL_H + /* Define if you have the `nsl' library (-lnsl). */ #undef HAVE_LIBNSL *************** *** 335,341 **** /* Define if your <sys/time.h> declares `struct tm'. */ #undef TM_IN_SYS_TIME - - /* Define to enable X2 transitioning features. */ - #undef TRANSITION /* Version number of package */ --- 338,341 ---- |