src/vmemsave.c
/************************************************************************/
/*									*/
/*			v m e m _ s a v e 0				*/
/*									*/
/*	Implements the VMEMSAVE subr.  Write out the current lisp	*/
/*	lisp image to the specified file.  If the sysout file-name	*/
/*	is explicitly specified, the directory on which the file	*/
/*	resides is exactly (?) an existing directory.  This is		*/
/*	guaranteed by the Lisp code, \MAIKO.CHECKFREEPAGE in LLFAULT.	*/
/*									*/
/*	If the file argument is nill, the default sysout-file name,	*/
/*	"~/lisp.virtualmem", is used, subject to override by the	*/
/*	LDEDESTSYSOUT UNIX-environment variable.			*/
/*									*/
/*									*/
/*									*/
/*									*/
/* Argument:	LispPTR	*args	args[0]					*/
/*			 The file name in Lisp format specifying a	*/
/*			 file to which the current Lisp image should	*/
/*			 be flushed or Lisp NIL.			*/
/*									*/
/* Value:	If succeed, returns NIL, otherwise one of the		*/
/*		following Lisp integers, indicating the reason.		*/
/*									*/
/*			1	BADFILENAME				*/
/*			2	NOFILESPACE				*/
/*			3	FILECANNOTOPEN				*/
/*			4	FILECANNOTSEEK				*/
/*			5	FILECANNOTWRITE				*/
/*			6	FILETIMEOUT				*/
/*									*/
/* Side Effect:	None.							*/
/*									*/
/************************************************************************/
v m e m _ s a v e 0

Implements the VMEMSAVE subr.  Write out the current lisp
lisp image to the specified file.  If the sysout file-name
is explicitly specified, the directory on which the file
resides is exactly (?) an existing directory.  This is
guaranteed by the Lisp code, \MAIKO.CHECKFREEPAGE in LLFAULT.

If the file argument is nill, the default sysout-file name,
"~/lisp.virtualmem", is used, subject to override by the
LDEDESTSYSOUT UNIX-environment variable.



LispPTR *args   args[0]
The file name in Lisp format specifying a
file to which the current Lisp image should
be flushed or Lisp NIL.

If succeed, returns NIL, otherwise one of the
following Lisp integers, indicating the reason.



Side Effect:   None.
v m e m _ s a v e 0 Implements the VMEMSAVE subr . Write out the current lisp lisp image to the specified file . If the sysout file - name is explicitly specified the directory on which the file resides is exactly ( ? ) an existing directory . This is guaranteed by the Lisp code \ MAIKO . CHECKFREEPAGE in LLFAULT . If the file argument is nill the default sysout - file name " ~ / lisp . virtualmem " is used subject to override by the LDEDESTSYSOUT UNIX - environment variable . LispPTR * args args [ 0 ] The file name in Lisp format specifying a file to which the current Lisp image should be flushed or Lisp NIL . If succeed returns NIL otherwise one of the following Lisp integers indicating the reason . Side Effect : None .
LispPTR vmem_save0(LispPTR *args)
{
  register char *def;
  char pathname[MAXPATHLEN], sysout[MAXPATHLEN], host[MAXNAMLEN];
#ifdef DOS
  char pwd[MAXNAMLEN];
  char drive[1];
#else
  struct passwd *pwd;
#endif 
  Lisp_errno = &Dummy_errno;
  if ((args[0] != NIL) && lispstringP(args[0])) {
    LispStringToCString(args[0], pathname, MAXPATHLEN);
    separate_host(pathname, host);
#ifdef DOS
    if (!unixpathname(pathname, sysout, 0, 0, drive, 0, 0)) return (BADFILENAME);
#else
    if (!unixpathname(pathname, sysout, 0, 0)) return (BADFILENAME);
#endif 
    return (vmem_save(sysout));
  } else {
    if ((def = getenv("LDEDESTSYSOUT")) == 0) {
#ifdef DOS
      if (getcwd(pwd, MAXNAMLEN) == NULL) return (FILETIMEOUT);
      strcpy(sysout, pwd);
      strcat(sysout, "/lisp.vm");
#else
      pwd = getpwuid(getuid()); 
      if (pwd == (struct passwd *)NULL) return (FILETIMEOUT);
      strcpy(sysout, pwd->pw_dir);
      strcat(sysout, "/lisp.virtualmem");
#endif 
    } else {
      if (*def == '~' && (*(def + 1) == '/' || *(def + 1) == '\0')) {
#ifdef DOS
        if (getcwd(pwd, MAXNAMLEN) == NULL) return (FILETIMEOUT);
        strcpy(sysout, pwd);
#else
        pwd = getpwuid(getuid()); 
        if (pwd == (struct passwd *)NULL) return (FILETIMEOUT);
        strcpy(sysout, pwd->pw_dir);
#endif 
        strcat(sysout, def + 1);
      } else {
        strcpy(sysout, def);
      }
    }
    return (vmem_save(sysout));
  }
}
LispPTR vmem_save0 ( LispPTR * args ) { register char * def ; char pathname [ MAXPATHLEN ] , sysout [ MAXPATHLEN ] , host [ MAXNAMLEN ] ; #ifdef DOS char pwd [ MAXNAMLEN ] ; char drive [ 1 ] ; #else struct passwd * pwd ; #endif Lisp_errno = & Dummy_errno ; if ( ( args [ 0 ] != NIL ) && lispstringP ( args [ 0 ] ) ) { LispStringToCString ( args [ 0 ] , pathname , MAXPATHLEN ) ; separate_host ( pathname , host ) ; #ifdef DOS if ( ! unixpathname ( pathname , sysout , 0 , 0 , drive , 0 , 0 ) ) return ( BADFILENAME ) ; #else if ( ! unixpathname ( pathname , sysout , 0 , 0 ) ) return ( BADFILENAME ) ; #endif return ( vmem_save ( sysout ) ) ; } else { if ( ( def = getenv ( " " ) ) == 0 ) { #ifdef DOS if ( getcwd ( pwd , MAXNAMLEN ) == NULL ) return ( FILETIMEOUT ) ; strcpy ( sysout , pwd ) ; strcat ( sysout , " " ) ; #else pwd = getpwuid ( getuid ( ) ) ; if ( pwd == ( struct passwd * ) NULL ) return ( FILETIMEOUT ) ; strcpy ( sysout , pwd -> pw_dir ) ; strcat ( sysout , " " ) ; #endif } else { if ( * def == ' ' && ( * ( def + 1 ) == ' ' || * ( def + 1 ) == ' \0 ' ) ) { #ifdef DOS if ( getcwd ( pwd , MAXNAMLEN ) == NULL ) return ( FILETIMEOUT ) ; strcpy ( sysout , pwd ) ; #else pwd = getpwuid ( getuid ( ) ) ; if ( pwd == ( struct passwd * ) NULL ) return ( FILETIMEOUT ) ; strcpy ( sysout , pwd -> pw_dir ) ; #endif strcat ( sysout , def + 1 ) ; } else { strcpy ( sysout , def ) ; } } return ( vmem_save ( sysout ) ) ; } }
v m e m _ s a v e 0
v m e m _ s a v e 0
/* DOS */ /* Check of lispstringP is safer for LispStringToCString */ /* DOS */ /* NEED TIMEOUT */ /* DOS */ /* NEED TIMEOUT */ /* DOS */