]> jfr.im git - irc/quakenet/newserv.git/blobdiff - lib/irc_string.c
merge
[irc/quakenet/newserv.git] / lib / irc_string.c
index ddab4574e327d3c9dac06e959921f7f399fe7c65..9f4929d5f7fafb8792ec8920a24e89b263840451 100644 (file)
  *
  * Copyright (c) 1998
  *      Andrea Cocito (Nemesi).
+ * Copyright (c)
+ *      Run (carlo@runaway.xs4all.nl) 1996
+ *
+ * mmatch/match/collapse
+ *
+ * Copyright (c)
+ *      Run (carlo@runaway.xs4all.nl) 1996
  *
  * License follows:
  *
@@ -153,7 +160,7 @@ int ircd_strcmp(const char *s1, const char *s2) {
   register const char* u2 = s2;
 
   while(ToLower(*u1) == ToLower(*u2)) {
-    if(*u1++)
+    if(!*u1++)
       return 0;
 
     u2++;
@@ -171,7 +178,7 @@ int ircd_strncmp(const char *s1, const char *s2, size_t len) {
     return 0;
 
   while(ToLower(*u1) == ToLower(*u2)) {
-    if(*u1++ || !remaining--)
+    if(!*u1++ || !remaining--)
       return 0;
 
     u2++;
@@ -214,7 +221,7 @@ char *delchars(char *string, const char *badchars) {
  *  Converts a long into a "p.q.r.s" IP address
  */
 
-const char *IPtostr(unsigned long IP) {
+const char *IPlongtostr(unsigned long IP) {
   static char buf[16];
 
   sprintf(buf,"%lu.%lu.%lu.%lu",(IP>>24),(IP>>16)&255,(IP>>8)&255,IP&255);
@@ -238,9 +245,11 @@ const char *longtoduration(unsigned long interval, int format) {
   hours=(interval%(3600*24))/3600;
   days=interval/(3600*24);
 
-  if (days>0 || format==0) {
+  if (format==0 || (days>0 && (hours||minutes||seconds))) {
     sprintf(outstring,"%d day%s, %02d:%02d:%02d",
             days,(days==1)?"":"s",hours,minutes,seconds);
+  } else if (days>0) {
+    sprintf(outstring, "%d day%s",days,(days==1)?"":"s");
   } else {
     if (hours>0) {
       pos += sprintf(outstring+pos,"%d hour%s ",hours,hours==1?"":"s");
@@ -308,7 +317,7 @@ int durationtolong(const char *string) {
   return total;
 }
 
-/* @GPL
+/*
  * mmatch()
  *
  * Written by Run (carlo@runaway.xs4all.nl), 25-10-96
@@ -327,6 +336,8 @@ int durationtolong(const char *string) {
  * a '?' in `new_mask' does not match a '\?' in `old_mask'.
  * And ofcourse... a '*' in `new_mask' does not match a '\*' in `old_mask'...
  * And last but not least, '\?' and '\*' in `new_mask' now become one character.
+ *
+ * Kindly BSD licensed by Run for Newserv.
  */
 
 int mmatch(const char *old_mask, const char *new_mask)