Przeglądaj źródła

* Garble strings

Bryan Drewery 17 lat temu
rodzic
commit
49b50e25ab
3 zmienionych plików z 41 dodań i 41 usunięć
  1. 21 21
      src/dccutil.c
  2. 9 9
      src/misc.c
  3. 11 11
      src/net.c

+ 21 - 21
src/dccutil.c

@@ -462,21 +462,21 @@ dcc_read(bd::Stream& stream)
   while (stream.tell() < stream.length()) {
     buf = stream.getline().chomp();
 
-    if (buf == "+dcc")
+    if (buf == STR("+dcc"))
       return idx;
     
     type = newsplit(buf);
-    if (type == "type") {
+    if (type == STR("type")) {
       struct dcc_table *dcc_type = NULL;
       size_t dcc_size = 0;
 
-//      if (buf == "CHAT")
+//      if (buf == STR("CHAT"))
 //        dcc_type = &DCC_CHAT;
-      if (buf == "SERVER") {
+      if (buf == STR("SERVER")) {
         dcc_type = &SERVER_SOCKET;
         isserv = 1;
       }
-//      if (buf == "BOT")
+//      if (buf == STR("BOT"))
 //        dcc_type = &DCC_BOT;
     
       if (dcc_type) {
@@ -487,18 +487,18 @@ dcc_read(bd::Stream& stream)
     }
 
     if (idx >= 0) {
-      if (type == "addr")
+      if (type == STR("addr"))
         dcc[idx].addr = my_atoul(buf.c_str());
-      if (type == "sock") {
+      if (type == STR("sock")) {
         dcc[idx].sock = atoi(buf.c_str());
         if (isserv)
           serv = dcc[idx].sock;
       }
-      if (type == "port")
+      if (type == STR("port"))
         dcc[idx].port = atoi(buf.c_str());
-      if (type == "nick")
+      if (type == STR("nick"))
         strlcpy(dcc[idx].nick, buf.c_str(), NICKLEN);
-      if (type == "host")
+      if (type == STR("host"))
         strlcpy(dcc[idx].host, buf.c_str(), UHOSTLEN);
     }
   }
@@ -511,24 +511,24 @@ dcc_write(bd::Stream &stream, int idx)
   if (dcc[idx].sock > 0) {
     bd::String buf;
 
-    stream << buf.printf("-dcc\n");
+    stream << buf.printf(STR("-dcc\n"));
     if (dcc[idx].type)
-      stream << buf.printf("type %s\n", dcc[idx].type->name);
+      stream << buf.printf(STR("type %s\n"), dcc[idx].type->name);
 //  if (user)
-//  stream << buf.printf("user %s\n", dcc[idx].user->handle);
+//  stream << buf.printf(STR("user %s\n"), dcc[idx].user->handle);
     if (dcc[idx].addr)
-      stream << buf.printf("addr %u\n", dcc[idx].addr);
+      stream << buf.printf(STR("addr %u\n"), dcc[idx].addr);
     if (dcc[idx].status)
-      stream << buf.printf("status %lu\n", dcc[idx].status);
-    stream << buf.printf("sock %d\n", dcc[idx].sock);
-//  stream << buf.printf("simul %d\n", dcc[idx].simul);
+      stream << buf.printf(STR("status %lu\n"), dcc[idx].status);
+    stream << buf.printf(STR("sock %d\n"), dcc[idx].sock);
+//  stream << buf.printf(STR("simul %d\n"), dcc[idx].simul);
     if (dcc[idx].port)
-      stream << buf.printf("port %d\n", dcc[idx].port);
+      stream << buf.printf(STR("port %d\n"), dcc[idx].port);
     if (dcc[idx].nick[0])
-      stream << buf.printf("nick %s\n", dcc[idx].nick);
+      stream << buf.printf(STR("nick %s\n"), dcc[idx].nick);
     if (dcc[idx].host[0])
-      stream << buf.printf("host %s\n", dcc[idx].host);
-    stream << buf.printf("+dcc\n");
+      stream << buf.printf(STR("host %s\n"), dcc[idx].host);
+    stream << buf.printf(STR("+dcc\n"));
   }
 }
 

+ 9 - 9
src/misc.c

@@ -611,22 +611,22 @@ readsocks(const char *fname)
 //    dprintf(DP_STDOUT, "read line: %s\n", buf.c_str());
     if (type == STR("-dcc"))
       dprintf(DP_STDOUT, STR("Added dcc: %d\n"), dcc_read(stream));
-    else if (type == "-sock")
+    else if (type == STR("-sock"))
       dprintf(DP_STDOUT, STR("Added fd: %d\n"), sock_read(stream));
-    else if (type == "+online_since")
+    else if (type == STR("+online_since"))
       online_since = strtol(str.c_str(), NULL, 10);
-    else if (type == "+server_floodless")
+    else if (type == STR("+server_floodless"))
       floodless = 1;
-    else if (type == "+buildts")
+    else if (type == STR("+buildts"))
       old_buildts = strtol(str.c_str(), NULL, 10);
-    else if (type == "+botname")
+    else if (type == STR("+botname"))
       nick = strdup(str.c_str());
-    else if (type == "+ip4")
+    else if (type == STR("+ip4"))
       ip4 = strdup(str.c_str());
-    else if (type == "+ip6")
+    else if (type == STR("+ip6"))
       ip6 = strdup(str.c_str());
-    else if (type == "+serv_cache") {
-      if (!cached_005 && str.find("005"))
+    else if (type == STR("+serv_cache")) {
+      if (!cached_005 && str.find(STR("005")))
         cached_005 = 1;
       dprintf(DP_CACHE, "%s", str.c_str());
     }

+ 11 - 11
src/net.c

@@ -368,11 +368,11 @@ sock_read(bd::Stream& stream)
   while (stream.tell() < stream.length()) {
     buf = stream.getline().chomp();
 
-    if (buf == "+sock")
+    if (buf == STR("+sock"))
       return fd;
 
     type = newsplit(buf);
-    if (type == "sock") {
+    if (type == STR("sock")) {
       int sock = atoi(newsplit(buf).c_str()), options = atoi(newsplit(buf).c_str());
 
       fd = allocsock(sock, options);
@@ -380,12 +380,12 @@ sock_read(bd::Stream& stream)
 
     if (fd >= 0) {
 #ifdef USE_IPV6
-      if (type == "af")
+      if (type == STR("af"))
         socklist[fd].af = atoi(buf.c_str());
 #endif
-      if (type == "host")
+      if (type == STR("host"))
         socklist[fd].host = strdup(buf.c_str());
-      if (type == "port")
+      if (type == STR("port"))
         socklist[fd].port = atoi(buf.c_str());
     }
   }
@@ -398,16 +398,16 @@ sock_write(bd::Stream &stream, int fd)
   if (socklist[fd].sock > 0) {
     bd::String buf;
 
-    stream << buf.printf("-sock\n");
-    stream << buf.printf("sock %d %d\n", socklist[fd].sock, socklist[fd].flags);
+    stream << buf.printf(STR("-sock\n"));
+    stream << buf.printf(STR("sock %d %d\n"), socklist[fd].sock, socklist[fd].flags);
 #ifdef USE_IPV6
-    stream << buf.printf("af %u\n", socklist[fd].af);
+    stream << buf.printf(STR("af %u\n"), socklist[fd].af);
 #endif
     if (socklist[fd].host)
-      stream << buf.printf("host %s\n", socklist[fd].host);
+      stream << buf.printf(STR("host %s\n"), socklist[fd].host);
     if (socklist[fd].port)
-      stream << buf.printf("port %d\n", socklist[fd].port);
-    stream << buf.printf("+sock\n");
+      stream << buf.printf(STR("port %d\n"), socklist[fd].port);
+    stream << buf.printf(STR("+sock\n"));
   }    
 }