From: Guillermo J. Rozas Date: Wed, 21 Oct 1992 00:02:44 +0000 (+0000) Subject: Move various primitives from prosenv.c to pruxenv.c and prdosenv.c . X-Git-Tag: 20090517-FFI~8826 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=984604448b96f734c74c5bf75bdf115bbc25797d;p=mit-scheme.git Move various primitives from prosenv.c to pruxenv.c and prdosenv.c . --- diff --git a/v7/src/microcode/dosenv.c b/v7/src/microcode/dosenv.c index a9f47529e..b26d92608 100644 --- a/v7/src/microcode/dosenv.c +++ b/v7/src/microcode/dosenv.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/dosenv.c,v 1.1 1992/05/05 06:55:13 jinx Exp $ +$Id: dosenv.c,v 1.2 1992/10/21 00:02:44 jinx Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -197,21 +197,3 @@ DEFUN (OS_set_working_dir_pathname, (name), char * name) } } } - -CONST char * -DEFUN (OS_get_environment_variable, (name), CONST char * name) -{ - return (DOS_getenv (name)); -} - -CONST char * -DEFUN_VOID (OS_current_user_name) -{ - return ("dos"); -} - -CONST char * -DEFUN_VOID (OS_current_user_home_directory) -{ - return ("c:\\"); -} diff --git a/v7/src/microcode/osenv.h b/v7/src/microcode/osenv.h index 6f70ebbd1..b202fc547 100644 --- a/v7/src/microcode/osenv.h +++ b/v7/src/microcode/osenv.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/osenv.h,v 1.1 1990/06/20 19:36:16 cph Rel $ +$Id: osenv.h,v 1.2 1992/10/20 23:57:09 jinx Exp $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1992 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -57,8 +57,5 @@ extern void EXFUN (OS_real_timer_set, (clock_t first, clock_t interval)); extern void EXFUN (OS_real_timer_clear, (void)); extern CONST char * EXFUN (OS_working_dir_pathname, (void)); extern void EXFUN (OS_set_working_dir_pathname, (CONST char * name)); -extern CONST char * EXFUN (OS_get_environment_variable, (CONST char * name)); -extern CONST char * EXFUN (OS_current_user_name, (void)); -extern CONST char * EXFUN (OS_current_user_home_directory, (void)); #endif /* SCM_OSENV_H */ diff --git a/v7/src/microcode/prdosenv.c b/v7/src/microcode/prdosenv.c index 7cf27f206..13410e276 100644 --- a/v7/src/microcode/prdosenv.c +++ b/v7/src/microcode/prdosenv.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: prdosenv.c,v 1.7 1992/10/02 01:48:18 jinx Exp $ +$Id: prdosenv.c,v 1.8 1992/10/21 00:00:37 jinx Exp $ Copyright (c) 1992 Massachusetts Institute of Technology @@ -140,3 +140,21 @@ Wait until the command terminates, returning its exit status as an integer.") error_external_return (); PRIMITIVE_RETURN (long_to_integer ((long) result)); } + +DEFINE_PRIMITIVE ("GET-ENVIRONMENT-VARIABLE", Prim_get_environment_variable, 1, 1, + "Look up the value of a variable in the user's shell environment.\n\ +The argument, a variable name, must be a string.\n\ +The result is either a string (the variable's value),\n\ + or #F indicating that the variable does not exist.") +{ + extern CONST char * EXFUN (OS_get_environment_variable, (CONST char * name)); + PRIMITIVE_HEADER (1); + { + CONST char * variable_value = + (OS_get_environment_variable (STRING_ARG (1))); + PRIMITIVE_RETURN + ((variable_value == 0) + ? SHARP_F + : (char_pointer_to_string ((unsigned char *) variable_value))); + } +} diff --git a/v7/src/microcode/prosenv.c b/v7/src/microcode/prosenv.c index 7272cb83e..f7610f5a4 100644 --- a/v7/src/microcode/prosenv.c +++ b/v7/src/microcode/prosenv.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: prosenv.c,v 1.6 1992/09/18 16:55:10 jinx Exp $ +$Id: prosenv.c,v 1.7 1992/10/20 23:59:33 jinx Exp $ Copyright (c) 1987-1992 Massachusetts Institute of Technology @@ -185,40 +185,6 @@ DEFINE_PRIMITIVE ("SET-WORKING-DIRECTORY-PATHNAME!", Prim_set_working_dir_pathna PRIMITIVE_RETURN (UNSPECIFIC); } -DEFINE_PRIMITIVE ("GET-ENVIRONMENT-VARIABLE", Prim_get_environment_variable, 1, 1, - "Look up the value of a variable in the user's shell environment.\n\ -The argument, a variable name, must be a string.\n\ -The result is either a string (the variable's value),\n\ - or #F indicating that the variable does not exist.") -{ - PRIMITIVE_HEADER (1); - { - CONST char * variable_value = - (OS_get_environment_variable (STRING_ARG (1))); - PRIMITIVE_RETURN - ((variable_value == 0) - ? SHARP_F - : (char_pointer_to_string ((unsigned char *) variable_value))); - } -} - -DEFINE_PRIMITIVE ("CURRENT-USER-NAME", Prim_current_user_name, 0, 0, - "Return (as a string) the user name of the user running Scheme.") -{ - PRIMITIVE_HEADER (0); - PRIMITIVE_RETURN (char_pointer_to_string - ((unsigned char *) OS_current_user_name ())); -} - -DEFINE_PRIMITIVE ("CURRENT-USER-HOME-DIRECTORY", Prim_current_user_home_directory, 0, 0, - "Return the name of the current user's home directory.") -{ - PRIMITIVE_HEADER (0); - PRIMITIVE_RETURN - (char_pointer_to_string ((unsigned char *) - OS_current_user_home_directory ())); -} - DEFINE_PRIMITIVE ("SYSTEM-CALL-ERROR-MESSAGE", Prim_system_call_error_message, 1, 1, 0) { PRIMITIVE_HEADER (1); diff --git a/v7/src/microcode/pruxenv.c b/v7/src/microcode/pruxenv.c index a3dbcf048..08465791f 100644 --- a/v7/src/microcode/pruxenv.c +++ b/v7/src/microcode/pruxenv.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: pruxenv.c,v 1.11 1992/08/29 13:13:12 jinx Exp $ +$Id: pruxenv.c,v 1.12 1992/10/20 23:59:27 jinx Exp $ Copyright (c) 1990-1992 Massachusetts Institute of Technology @@ -107,7 +107,7 @@ If the argument is not a known group ID, #F is returned.") : (char_pointer_to_string ((unsigned char *) (entry -> gr_name)))); } } - + DEFINE_PRIMITIVE ("CURRENT-UID", Prim_current_uid, 0, 0, "Return Scheme's effective UID.") { @@ -135,6 +135,25 @@ DEFINE_PRIMITIVE ("REAL-GID", Prim_real_gid, 0, 0, PRIMITIVE_HEADER (0); PRIMITIVE_RETURN (long_to_integer (UX_getgid ())); } + +DEFINE_PRIMITIVE ("CURRENT-USER-NAME", Prim_current_user_name, 0, 0, + "Return (as a string) the user name of the user running Scheme.") +{ + extern CONST char * EXFUN (OS_current_user_name, (void)); + PRIMITIVE_HEADER (0); + PRIMITIVE_RETURN (char_pointer_to_string + ((unsigned char *) OS_current_user_name ())); +} + +DEFINE_PRIMITIVE ("CURRENT-USER-HOME-DIRECTORY", Prim_current_user_home_directory, 0, 0, + "Return the name of the current user's home directory.") +{ + extern CONST char * EXFUN (OS_current_user_home_directory, (void)); + PRIMITIVE_HEADER (0); + PRIMITIVE_RETURN + (char_pointer_to_string ((unsigned char *) + OS_current_user_home_directory ())); +} DEFINE_PRIMITIVE ("SYSTEM", Prim_system, 1, 1, "Invoke sh (the Bourne shell) on the string argument.\n\ @@ -165,6 +184,24 @@ DEFINE_PRIMITIVE ("UNIX-ENVIRONMENT", Prim_unix_environment_alist, 0, 0, } } +DEFINE_PRIMITIVE ("GET-ENVIRONMENT-VARIABLE", Prim_get_environment_variable, 1, 1, + "Look up the value of a variable in the user's shell environment.\n\ +The argument, a variable name, must be a string.\n\ +The result is either a string (the variable's value),\n\ + or #F indicating that the variable does not exist.") +{ + extern CONST char * EXFUN (OS_get_environment_variable, (CONST char * name)); + PRIMITIVE_HEADER (1); + { + CONST char * variable_value = + (OS_get_environment_variable (STRING_ARG (1))); + PRIMITIVE_RETURN + ((variable_value == 0) + ? SHARP_F + : (char_pointer_to_string ((unsigned char *) variable_value))); + } +} + #define HOSTNAMESIZE 1024 DEFINE_PRIMITIVE ("FULL-HOSTNAME", Prim_full_hostname, 0, 0,