[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

pong2 - PATH_MAX patch for review



Hi again,

Here is a simple little patch to build pong2 (uses PATH_MAX).

Let me know if this looks sane.

Thanks!

Barry deFreese

--- pong2-0.1.3.orig/src/grapple/socket.h
+++ pong2-0.1.3/src/grapple/socket.h
@@ -27,7 +27,9 @@
 #include <sys/time.h>
 #include <netinet/in.h>
 
+#ifdef __linux__
 #include <linux/limits.h>
+#endif
 
 #ifndef HOST_NAME_MAX
 # define HOST_NAME_MAX 255
only in patch2:
unchanged:
--- pong2-0.1.3.orig/src/grapple/socket.c
+++ pong2-0.1.3/src/grapple/socket.c
@@ -35,7 +35,9 @@
 #include <sys/ioctl.h>
 #include <errno.h>
 #include <time.h>
+#ifdef __linux__
 #include <linux/limits.h>
+#endif
 #ifdef SOCK_SSL
 #include <openssl/ssl.h>
 #endif
@@ -344,6 +346,16 @@
 {
   FILE *fp;
   int loopa;
+
+#ifdef __GLIBC__
+  char *filename;
+
+  //Set the filename  
+  if (writer)
+    asprintf(filename,"/tmp/socket_%d.write",sock->fd);
+  else
+    asprintf(filename,"/tmp/socket_%d.read",sock->fd);
+#else
   char filename[PATH_MAX];
 
   //Set the filename  
@@ -352,6 +364,8 @@
   else
     sprintf(filename,"/tmp/socket_%d.read",sock->fd);
 
+#endif //GLIBC
+
   //Open the file for appending
   fp=fopen(filename,"a");
   if (fp)
@@ -371,6 +385,11 @@
 
       //Close the file, we're done
       fclose(fp);
+
+#ifdef __GLIBC__
+      free(filename);
+#endif
+
     }
   return;
 }

Reply to: