TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Automatically check for/load ~/.ttrc

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
sj



Joined: 22 Jan 2012
Posts: 16
Location: Manchester, England

PostPosted: Sun Jan 22, 2012 3:46 pm    Post subject: Automatically check for/load ~/.ttrc Reply with quote

Here's a patch (created against 2.00.8) to automatically use ~/.ttrc as its input file if it exists and a configuration file hasn't been specified through other means:

You should run autoconf again after applying the patch.

Code:

diff --recursive -u tt//src/config.h.in mytt//src/config.h.in
--- tt//src/config.h.in   2009-07-12 07:13:13.000000000 +0100
+++ mytt//src/config.h.in   2012-01-22 20:13:27.472659091 +0000
@@ -114,6 +114,9 @@
 /* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
 /* Define to 1 if you have the `strcasecmp' function. */
 #undef HAVE_STRCASECMP
 
diff --recursive -u tt//src/configure.in mytt//src/configure.in
--- tt//src/configure.in   2009-07-12 07:13:13.000000000 +0100
+++ mytt//src/configure.in   2012-01-22 20:02:20.912688418 +0000
@@ -65,7 +65,7 @@
 # Checks for header files.
 
 AC_HEADER_STDC
-AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h net/errno.h netdb.h netinet/in.h param.h pthread.h socks.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/ptem.h sys/socket.h sys/termio.h sys/time.h time.h unistd.h zlib.h util.h pty.h])
+AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h net/errno.h netdb.h netinet/in.h param.h pthread.h socks.h limits.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/ptem.h sys/socket.h sys/termio.h sys/time.h time.h unistd.h zlib.h util.h pty.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
diff --recursive -u tt//src/main.c mytt//src/main.c
--- tt//src/main.c   2012-01-02 19:32:43.000000000 +0000
+++ mytt//src/main.c   2012-01-22 20:44:02.396578361 +0000
@@ -158,7 +158,8 @@
 int main(int argc, char **argv)
 {
    int greeting = TRUE;
-
+   int script_specified = FALSE;
+   
    #ifdef SOCKS
       SOCKSinit(argv[0]);
    #endif
@@ -266,6 +267,7 @@
 
             case 'r':
                gtd->ses = do_read(gtd->ses, optarg);
+               script_specified = TRUE;
                break;
 
             case 't':
@@ -289,8 +291,26 @@
       if (argv[optind] != NULL)
       {
          gtd->ses = do_read(gtd->ses, argv[optind]);
+         script_specified = TRUE;
+      }
+   }
+
+   if(script_specified == FALSE)
+   {
+      FILE* fp = NULL;
+      char rc_path[PATH_MAX];
+      
+      snprintf(rc_path, PATH_MAX, "%s/.ttrc", getenv("HOME"));
+
+      fp = fopen(rc_path, "r");
+      if(fp != NULL)
+      {
+         fclose(fp);
+         gtd->ses = do_read(gtd->ses, rc_path);
+         script_specified = TRUE;
       }
    }
+
    check_all_events(gts, SUB_ARG|SUB_SEC, 0, 2, "PROGRAM START", CLIENT_NAME, CLIENT_VERSION);
    check_all_events(gts, SUB_ARG|SUB_SEC, 0, 2, "SCREEN RESIZE", ntos(gts->cols), ntos(gts->rows));
 
diff --recursive -u tt//src/tintin.h mytt//src/tintin.h
--- tt//src/tintin.h   2012-01-02 19:34:48.000000000 +0000
+++ mytt//src/tintin.h   2012-01-22 20:20:41.684639987 +0000
@@ -52,6 +52,14 @@
 #include <stdlib.h>
 #endif
 
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#else
+#ifndef PATH_MAX
+#define PATH_MAX 255
+#endif
+#endif
+
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
Back to top
View user's profile Send private message Visit poster's website
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Sun Jan 22, 2012 9:38 pm    Post subject: Reply with quote

I'm really picky about adding redundant functionality.

I'll go ahead and create a Development section in the forum for patches and snippets.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Feature Requests All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group