Explorar el Código

* Allow garbling of specific help entries with ::cmd: (last :)

svn: 412
Bryan Drewery hace 22 años
padre
commit
e9988b16ae
Se han modificado 4 ficheros con 19 adiciones y 25 borrados
  1. 0 2
      pack/conf.h
  2. 4 5
      src/cmds.c
  3. 12 10
      src/makehelp.c
  4. 3 8
      src/stringfix.c

+ 0 - 2
pack/conf.h

@@ -14,8 +14,6 @@
 #define S_AUTOAWAY	/*  yes		random autoaway/return on IRC 			*/
 #define S_AUTOLOCK      /*  yes         will lock channels upon certain coniditions     */
 #define S_DCCPASS	/*  yes		DCC command passwords 				*/
-#undef S_GARBLEHELP	/*  no		This will garble all help info, bloating binary *
-			 *		You may want this if you are paranoid.		*/
 #define S_GARBLESTRINGS	/*  yes		encrypt strings in binary			*/
 #define S_HIJACKCHECK   /*  yes		checks for a common fbsd process hijacker	*/
 #define S_LASTCHECK	/*  yes		checks every few seconds for logins with `last` */

+ 4 - 5
src/cmds.c

@@ -826,11 +826,10 @@ static void cmd_help(struct userrec *u, int idx, char *par)
         dprintf(idx, STR("Showing you help for '%s' (%s):"), match, flg);
         for (hi = 0; (help[hi].cmd) && (help[hi].desc); hi++) {
           if (!egg_strcasecmp(match, help[hi].cmd)) {
-#ifdef S_GARBLEHELP
-            showhelp(idx, &fr, degarble(help[hi].garble, help[hi].desc));
-#else /* !S_GARBLEHELP */
-            showhelp(idx, &fr, help[hi].desc);
-#endif /* S_GARBLEHELP */
+            if (help[hi].garble)
+              showhelp(idx, &fr, degarble(help[hi].garble, help[hi].desc));
+            else
+              showhelp(idx, &fr, help[hi].desc);
           }
         }
         done = 1;

+ 12 - 10
src/makehelp.c

@@ -151,11 +151,10 @@ help_t help[] = \n\
         } else { if (leaf || hub) { cl = 1; } leaf = 0; hub = 0;  }
 
         if (cmd && cmd[0]) {		/* CLOSE LAST CMD */
-#ifdef S_GARBLEHELP
-          fprintf(out,"\")},\n");
-#else /* !S_GARBLEHELP */
-          fprintf(out,"\"},\n");
-#endif /* S_GARBLEHELP */
+          if (strchr(cmd, ':'))		/* garbled */
+            fprintf(out,"\")},\n");
+          else
+            fprintf(out,"\"},\n");
           if (cl) { cl = 0; fprintf(out, "#endif\n"); }
           if (dohub) { dohub = 0; fprintf(out, "#ifdef HUB\n"); }
           else if (doleaf) { doleaf = 0; fprintf(out, "#ifdef LEAF\n"); }
@@ -169,11 +168,14 @@ help_t help[] = \n\
           printf(".");
           if (dohub) { dohub = 0; fprintf(out, "#ifdef HUB\n"); }
           else if (doleaf) { doleaf = 0; fprintf(out, "#ifdef LEAF\n"); }
-#ifdef S_GARBLEHELP
-          fprintf(out, "  {2, \"%s\", STR(\"", cmd);
-#else /* !S_GARBLEHELP */
-          fprintf(out, "  {2, \"%s\", 0, \"", cmd);
-#endif /* S_GARBLEHELP */
+          if (strchr(cmd, ':')) {
+            char *p2, *cmdn = malloc(strlen(cmd) + 1);
+            strcpy(cmdn, cmd);
+            p2 = strchr(cmdn, ':');
+            *p2 = 0;
+            fprintf(out, "  {2, \"%s\", STR(\"", cmdn);
+          } else
+            fprintf(out, "  {2, \"%s\", 0, \"", cmd);
         } else {			/* END */
           fprintf(out, "  {0, NULL}\n};\n");
         }

+ 3 - 8
src/stringfix.c

@@ -10,9 +10,7 @@
 #include "conf.h"
 
 #define WTF 16384
-#ifdef S_GARBLEHELP
 int help = 0;
-#endif /* S_GARBLEHELP */
 #ifdef S_GARBLESTRINGS
 void garble(char **inptr, char **outptr)
 {
@@ -83,12 +81,11 @@ void garble(char **inptr, char **outptr)
       out += 4;
       *out = 0;
     }
-#ifdef S_GARBLEHELP
+
     if (help)
-      sprintf(*outptr, "%d,\"%s\"", chars, obuf);
+      sprintf(*outptr, "%d, \"%s\"", chars, obuf);
     else
-#endif /* S_GARBLEHELP */
-      sprintf(*outptr, "degarble(%d,\"%s\")", chars, obuf);
+      sprintf(*outptr, "degarble(%d, \"%s\")", chars, obuf);
     *outptr += strlen(*outptr);
     in = p + 2;
   } else {
@@ -147,10 +144,8 @@ int main(int argc, char *argv[0])
 
   if (argc != 3 && argc != 4)
     return 1;
-#ifdef S_GARBLEHELP
   if (argc == 4)
     help = 1;
-#endif /* S_GARBLEHELP */
   if (!(f = fopen(argv[1], "r")))
     return 1;
   fseek(f, 0, SEEK_END);