]> jfr.im git - irc/quakenet/newserv.git/blobdiff - helpmod2/hgen.c
Remove test #ifs around the GL commands.
[irc/quakenet/newserv.git] / helpmod2 / hgen.c
index d7b52f11cb77b5a7b5ca95cf19c23b4f72621cc8..0e9c33f00f6af49b4869f8a3bf6ad75fc11f3079 100644 (file)
@@ -74,8 +74,7 @@ int strregexp(const char * str, const char * pattern)
 #define TIME_PRINT(elem,marker)\
 if (elem)\
 {\
-    sprintf(buf, " %d%s%n", elem, marker, &tmp);\
-    buf+=tmp;\
+    buf+=sprintf(buf, " %d%s", elem, marker);\
 }\
 
 /* This implementation might look a little evil but it does work */
@@ -87,7 +86,7 @@ const char *helpmod_strtime(int total_seconds)
     char *buf = buffers[buffer_index];
     char *buffer = buf;
 
-    int years, months, days, hours, minutes, seconds, tmp;
+    int years, months, days, hours, minutes, seconds;
 
     buffer_index = (buffer_index+1) % 3;
 
@@ -134,10 +133,7 @@ const char *helpmod_strtime(int total_seconds)
 
 int helpmod_read_strtime(const char *str)
 {
-    int sum = 0;
-    int tmp_sum;
-    int tmp;
-
+    int sum = 0, tmp_sum, tmp;
 
     while (*str)
     {
@@ -204,17 +200,8 @@ int helpmod_is_lame_line(const char *line)
     const char lamechars[] = {(char)2, (char)3, (char)22, (char)31, (char)0};
     if (strpbrk(line, lamechars) != NULL)
         return 1;
-    /*
-     if (strchr(line, (char)2))  bold
-     return 1;
-     if (strchr(line, (char)3))  colour
-        return 1;
-    if (strchr(line, (char)22)) reverse
-        return 1;
-    if (strchr(line, (char)31)) underline
-        return 1;
-*/
-    return 0;
+    else
+       return 0;
 }
 
 int strislower(const char *str)
@@ -249,3 +236,25 @@ int strnumcount(const char *str)
             count++;
     return count;
 }
+
+float helpmod_percentage(int larger, int smaller)
+{
+    if (larger == 0)
+       return 0.0;
+
+    return 100.0 * ((float)smaller / (float)larger);
+}
+
+int helpmod_select(const char *str, const char **strs, int *enums, int count)
+{
+    int i;
+
+    if (count == 0)
+       return -1;
+
+    for (i = 0;i < count;i++)
+       if (!ci_strcmp(strs[i], str))
+            return enums[i];
+
+    return -1;
+}