[BACK]Return to value.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tip

Diff for /src/usr.bin/tip/Attic/value.c between version 1.29 and 1.30

version 1.29, 2010/07/02 07:09:57 version 1.30, 2010/07/02 07:40:03
Line 30 
Line 30 
  * SUCH DAMAGE.   * SUCH DAMAGE.
  */   */
   
   #include <paths.h>
   
 #include "tip.h"  #include "tip.h"
   
 /*  /*
  * Variable manipulation.   * Variable manipulation.
  */   */
   
   value_t vtable[] = {
           { "beautify",     V_BOOL,              "be",     NULL, 0 },
           { "baudrate",     V_NUMBER,            "ba",     NULL, 0 },
           { "connect",      V_STRING|V_READONLY, "cm",     NULL, 0 },
           { "device",       V_STRING|V_READONLY, "dv",     NULL, 0 },
           { "eofread",      V_STRING,            "eofr",   NULL, 0 },
           { "eofwrite",     V_STRING,            "eofw",   NULL, 0 },
           { "eol",          V_STRING,            NULL,     NULL, 0 },
           { "escape",       V_CHAR,              "es",     NULL, 0 },
           { "exceptions",   V_STRING,            "ex",     NULL, 0 },
           { "force",        V_CHAR,              "fo",     NULL, 0 },
           { "framesize",    V_NUMBER,            "fr",     NULL, 0 },
           { "host",         V_STRING|V_READONLY, "ho",     NULL, 0 },
           { "log",          V_STRING,            NULL,     NULL, 0 },
           { "prompt",       V_CHAR,              "pr",     NULL, 0 },
           { "raise",        V_BOOL,              "ra",     NULL, 0 },
           { "raisechar",    V_CHAR,              "rc",     NULL, 0 },
           { "record",       V_STRING,            "rec",    NULL, 0 },
           { "remote",       V_STRING|V_READONLY, NULL,     NULL, 0 },
           { "script",       V_BOOL,              "sc",     NULL, 0 },
           { "tabexpand",    V_BOOL,              "tab",    NULL, 0 },
           { "verbose",      V_BOOL,              "verb",   NULL, 0 },
           { "SHELL",        V_STRING,            NULL,     NULL, 0 },
           { "HOME",         V_STRING,            NULL,     NULL, 0 },
           { "echocheck",    V_BOOL,              "ec",     NULL, 0 },
           { "disconnect",   V_STRING,            "di",     NULL, 0 },
           { "tandem",       V_BOOL,              "ta",     NULL, 0 },
           { "linedelay",    V_NUMBER,            "ldelay", NULL, 0 },
           { "chardelay",    V_NUMBER,            "cdelay", NULL, 0 },
           { "etimeout",     V_NUMBER,            "et",     NULL, 0 },
           { "rawftp",       V_BOOL,              "raw",    NULL, 0 },
           { "halfduplex",   V_BOOL,              "hdx",    NULL, 0 },
           { "localecho",    V_BOOL,              "le",     NULL, 0 },
           { "parity",       V_STRING,            "par",    NULL, 0 },
           { "hardwareflow", V_BOOL,              "hf",     NULL, 0 },
           { "linedisc",     V_NUMBER,            "ld",     NULL, 0 },
           { "direct",       V_BOOL,              "dc",     NULL, 0 },
           { NULL,           0,                    NULL,    NULL, 0 },
   };
   
 #define MIDDLE  35  #define MIDDLE  35
   
 static int      vlookup(char *);  static int      vlookup(char *);
Line 85 
Line 127 
         if (value == RECORD && string != NULL)          if (value == RECORD && string != NULL)
                 string = expand(string);                  string = expand(string);
   
         if (!(vp->v_flags & V_INIT))          free(vp->v_string);
                 free(vp->v_string);  
         if (string != NULL) {          if (string != NULL) {
                 vp->v_string = strdup(string);                  vp->v_string = strdup(string);
                 if (vp->v_string == NULL)                  if (vp->v_string == NULL)
                         err(1, "strdup");                          err(1, "strdup");
         } else          } else
                 vp->v_string = NULL;                  vp->v_string = NULL;
         vp->v_flags &= ~V_INIT;  
 }  }
   
 /* Set a number value. */  /* Set a number value. */
Line 129 
Line 169 
 void  void
 vinit(void)  vinit(void)
 {  {
         char file[FILENAME_MAX], *cp;          struct passwd   *pw;
         int written;          value_t         *vp;
         FILE *fp;          char             file[FILENAME_MAX], *cp;
           int              written;
           FILE            *fp;
   
         /* Read environment variables. */          /* Read environment variables. */
         if ((cp = getenv("HOME")))          if ((cp = getenv("HOME")) != NULL)
                 vsetstr(HOME, cp);                  vsetstr(HOME, cp);
         if ((cp = getenv("SHELL")))          else {
                   pw = getpwuid(getuid());
                   if (pw != NULL && pw->pw_dir != NULL)
                           vsetstr(HOME, pw->pw_dir);
                   else
                           vsetstr(HOME, "/");
           }
           if ((cp = getenv("SHELL")) != NULL)
                 vsetstr(SHELL, cp);                  vsetstr(SHELL, cp);
           else
                   vsetstr(SHELL, _PATH_BSHELL);
   
           /* Clear the table and set the defaults. */
           for (vp = vtable; vp->v_name != NULL; vp++) {
                   vp->v_string = NULL;
                   vp->v_number = 0;
           }
           vsetnum(BEAUTIFY, 1);
           vsetnum(ESCAPE, '~');
           vsetnum(FORCE, CTRL('p'));
           vsetnum(PROMPT, '\n');
           vsetnum(TAND, 1);
           vsetnum(VERBOSE, 1);
           vsetstr(LOG, _PATH_ACULOG);
   
         /* Read the .tiprc file in the HOME directory. */          /* Read the .tiprc file in the HOME directory. */
         written = snprintf(file, sizeof(file), "%s/.tiprc", vgetstr(HOME));          written = snprintf(file, sizeof(file), "%s/.tiprc", vgetstr(HOME));

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30