- return (A_INVALID);
-}
-
-/*
- * Initialize the user command table.
- */
- public void
-init_cmd()
-{
- char *homedir;
- int f;
- int n;
- char filename[MAXPATHLEN];
- extern char *getenv();
-
- /*
- * Try to open "$HOME/.less"
- * If we can't, return without doing anything.
- */
- homedir = getenv("HOME");
- if (homedir == NULL)
- return;
- (void)sprintf(filename, "%s/%s", homedir, ".less");
- f = open(filename, O_RDONLY);
- if (f < 0)
- return;
-
- /*
- * Read the file into the user table.
- * {{ Minimal error checking is done here.
- * A garbage .less file will produce strange results.
- * To avoid a large amount of error checking code here, we
- * rely on the lesskey program to generate a good .less file. }}
- */
- n = read(f, (char *)usertable, MAX_USERCMD);
- if (n < 3 || usertable[n-2] != '\0')
- {
- /*
- * Several error cases are lumped together here:
- * - Cannot read user file (n < 0).
- * - User file is too short (a valid file must
- * have at least 3 chars: one char command string,
- * the terminating null byte, and the action byte).
- * - The final entry in the user file is bad (it
- * doesn't have a null byte in the proper place).
- * Many other error cases are not caught, such as
- * invalid format in any except the last entry,
- * invalid action codes, command strings too long, etc.
- */
- error("invalid user key file");
- n = 0;
- }
- userendtable = usertable + n;
- close(f);