00001 /* 00002 * woobie.c -- part of woobie.mod 00003 * nonsensical command to exemplify module programming 00004 * 00005 * Originally written by ButchBub 15 July 1997 00006 * Comments by Fabian Knittel 29 December 1999 00007 * 00008 * $Id: woobie.c,v 1.29 2011/02/13 14:19:34 simple Exp $ 00009 */ 00010 /* 00011 * Copyright (C) 1999 - 2011 Eggheads Development Team 00012 * 00013 * This program is free software; you can redistribute it and/or 00014 * modify it under the terms of the GNU General Public License 00015 * as published by the Free Software Foundation; either version 2 00016 * of the License, or (at your option) any later version. 00017 * 00018 * This program is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License 00024 * along with this program; if not, write to the Free Software 00025 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00026 */ 00027 00028 #define MODULE_NAME "woobie" 00029 #define MAKING_WOOBIE 00030 00031 #include "src/mod/module.h" 00032 #include <stdlib.h> 00033 00034 #undef global 00035 /* Pointer to the eggdrop core function table. Gets initialized in 00036 * woobie_start(). 00037 */ 00038 static Function *global = NULL; 00039 00040 /* Calculate the memory we keep allocated. 00041 */ 00042 static int woobie_expmem() 00043 { 00044 int size = 0; 00045 00046 Context; 00047 return size; 00048 } 00049 00050 static int cmd_woobie(struct userrec *u, int idx, char *par) 00051 { 00052 /* Define a context. 00053 * 00054 * If the bot crashes after the context, it will be the last mentioned 00055 * in the resulting DEBUG file. This helps you debugging. 00056 */ 00057 Context; 00058 00059 /* Log the command as soon as you're sure all parameters are valid. */ 00060 putlog(LOG_CMDS, "*", "#%s# woobie", dcc[idx].nick); 00061 00062 dprintf(idx, "WOOBIE!\n"); 00063 return 0; 00064 } 00065 00066 /* A report on the module status. 00067 * 00068 * details is either 0 or 1: 00069 * 0 - `.status' 00070 * 1 - `.status all' or `.module woobie' 00071 */ 00072 static void woobie_report(int idx, int details) 00073 { 00074 if (details) { 00075 int size = woobie_expmem(); 00076 00077 dprintf(idx, " Using %d byte%s of memory\n", size, 00078 (size != 1) ? "s" : ""); 00079 } 00080 } 00081 00082 /* Note: The tcl-name is automatically created if you set it to NULL. In 00083 * the example below it would be just "*dcc:woobie". If you specify 00084 * "woobie:woobie" it would be "*dcc:woobie:woobie" instead. 00085 * ^----- command name ^--- table name 00086 * ^------------ module name 00087 * 00088 * This is only useful for stackable binding tables (and H_dcc isn't 00089 * stackable). 00090 */ 00091 static cmd_t mydcc[] = { 00092 /* command flags function tcl-name */ 00093 {"woobie", "", cmd_woobie, NULL}, 00094 {NULL, NULL, NULL, NULL} /* Mark end. */ 00095 }; 00096 00097 static char *woobie_close() 00098 { 00099 Context; 00100 rem_builtins(H_dcc, mydcc); 00101 module_undepend(MODULE_NAME); 00102 return NULL; 00103 } 00104 00105 /* Define the prototype here, to avoid warning messages in the 00106 * woobie_table. 00107 */ 00108 EXPORT_SCOPE char *woobie_start(); 00109 00110 /* This function table is exported and may be used by other modules and 00111 * the core. 00112 * 00113 * The first four have to be defined (you may define them as NULL), as 00114 * they are checked by eggdrop core. 00115 */ 00116 static Function woobie_table[] = { 00117 (Function) woobie_start, 00118 (Function) woobie_close, 00119 (Function) woobie_expmem, 00120 (Function) woobie_report, 00121 }; 00122 00123 char *woobie_start(Function *global_funcs) 00124 { 00125 /* Assign the core function table. After this point you use all normal 00126 * functions defined in src/mod/modules.h 00127 */ 00128 global = global_funcs; 00129 00130 Context; 00131 /* Register the module. */ 00132 module_register(MODULE_NAME, woobie_table, 2, 0); 00133 /* ^--- minor module version 00134 * ^------ major module version 00135 * ^-------------------- module function table 00136 * ^--------------------------------- module name 00137 */ 00138 00139 if (!module_depend(MODULE_NAME, "eggdrop", 106, 0)) { 00140 module_undepend(MODULE_NAME); 00141 return "This module requires Eggdrop 1.6.0 or later."; 00142 } 00143 00144 /* Add command table to bind list H_dcc, responsible for dcc commands. 00145 * Currently we only add one command, `woobie'. 00146 */ 00147 add_builtins(H_dcc, mydcc); 00148 return NULL; 00149 }