UnixOperatingSystem.st
changeset 25256 d37965c90cdb
parent 25190 0e87db7b776b
child 25262 cb9169b1c1d2
equal deleted inserted replaced
25255:59ab9566a7e5 25256:d37965c90cdb
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1988 by Claus Gittinger
     4  COPYRIGHT (c) 1988 by Claus Gittinger
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
  7521     "
  7523     "
  7522      OperatingSystem getEnvironment
  7524      OperatingSystem getEnvironment
  7523     "
  7525     "
  7524 !
  7526 !
  7525 
  7527 
  7526 getEnvironment:aStringOrSymbol
  7528 getEnvironment:aVariableNameStringOrSymbol
  7527     "get an environment string"
  7529     "get an environment string for the OS environment variable named aVariableNameStringOrSymbol,
       
  7530      or nil, if the variable is not present in the environment."
  7528 
  7531 
  7529 %{  /* NOCONTEXT */
  7532 %{  /* NOCONTEXT */
  7530 #ifdef __SCHTEAM__
  7533 #ifdef __SCHTEAM__
  7531     {
  7534     {
  7532 	java.lang.String val = java.lang.System.getenv( aStringOrSymbol.asString() );
  7535         java.lang.String val = java.lang.System.getenv( aVariableNameStringOrSymbol.asString() );
  7533 	STObject retVal;
  7536         STObject retVal;
  7534 
  7537 
  7535 	if (val == null) {
  7538         if (val == null) {
  7536 	    retVal = STObject.Nil;
  7539             retVal = STObject.Nil;
  7537 	} else {
  7540         } else {
  7538 	    retVal = new STString( val );
  7541             retVal = new STString( val );
  7539 	}
  7542         }
  7540 	return context._RETURN( retVal );
  7543         return context._RETURN( retVal );
  7541 	/* NOTREACHED */
  7544         /* NOTREACHED */
  7542     }
  7545     }
  7543 #else
  7546 #else
  7544     extern char *getenv();
  7547     extern char *getenv();
  7545 
  7548 
  7546     if (__isStringLike(aStringOrSymbol)) {
  7549     if (__isStringLike(aVariableNameStringOrSymbol)) {
  7547 	char *env =  getenv(__stringVal(aStringOrSymbol));
  7550         char *env =  getenv(__stringVal(aVariableNameStringOrSymbol));
  7548 	if (env) {
  7551         if (env) {
  7549 	    RETURN ( __MKSTRING(env) );
  7552             RETURN ( __MKSTRING(env) );
  7550 	}
  7553         }
  7551 	RETURN ( nil );
  7554         RETURN ( nil );
  7552     }
  7555     }
  7553 #endif /* not SCHTEAM */
  7556 #endif /* not SCHTEAM */
  7554 %}.
  7557 %}.
  7555     ^ self primitiveFailed
  7558     ^ self primitiveFailed
  7556 
  7559 
  7560      OperatingSystem getEnvironment:'HOME'
  7563      OperatingSystem getEnvironment:'HOME'
  7561      OperatingSystem getEnvironment:'NNTPSERVER'
  7564      OperatingSystem getEnvironment:'NNTPSERVER'
  7562      OperatingSystem getEnvironment:'MAIL'
  7565      OperatingSystem getEnvironment:'MAIL'
  7563      OperatingSystem getEnvironment:'PATH'
  7566      OperatingSystem getEnvironment:'PATH'
  7564     "
  7567     "
       
  7568 
       
  7569     "Modified: / 11-02-2020 / 17:43:26 / Stefan Vogel"
  7565 !
  7570 !
  7566 
  7571 
  7567 getHostName
  7572 getHostName
  7568     "return the hostname we are running on.
  7573     "return the hostname we are running on.
  7569      The host name returned is fully qualified - if returned so by the system."
  7574      The host name returned is fully qualified - if returned so by the system."
  9746 
  9751 
  9747     "
  9752     "
  9748      Codeset := #'utf8-mac'.
  9753      Codeset := #'utf8-mac'.
  9749      CodesetEncoder := nil.
  9754      CodesetEncoder := nil.
  9750      OperatingSystem getCodesetEncoder
  9755      OperatingSystem getCodesetEncoder
  9751      OperatingSystem encodePath:'äöü'
  9756      OperatingSystem encodePath:'äöü'
  9752     "
  9757     "
  9753 
  9758 
  9754     "Modified: / 23-01-2013 / 10:00:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  9759     "Modified: / 23-01-2013 / 10:00:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  9755     "Modified: / 27-02-2017 / 15:49:32 / stefan"
  9760     "Modified: / 27-02-2017 / 15:49:32 / stefan"
  9756     "Modified: / 09-08-2017 / 23:00:47 / cg"
  9761     "Modified: / 09-08-2017 / 23:00:47 / cg"
 13603 	    domain:#'AF_INET' type:nil protocol:nil flags:nil
 13608 	    domain:#'AF_INET' type:nil protocol:nil flags:nil
 13604      self getAddressInfo:'www.exept.de' serviceName:'https'
 13609      self getAddressInfo:'www.exept.de' serviceName:'https'
 13605 	    domain:#'AF_UNSPEC' type:nil protocol:nil flags:nil
 13610 	    domain:#'AF_UNSPEC' type:nil protocol:nil flags:nil
 13606      self getAddressInfo:'www.exept.de' serviceName:nil
 13611      self getAddressInfo:'www.exept.de' serviceName:nil
 13607 	    domain:#'AF_INET6' type:nil protocol:nil flags:nil
 13612 	    domain:#'AF_INET6' type:nil protocol:nil flags:nil
 13608      self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
 13613      self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
 13609 	    domain:#'AF_INET' type:#stream protocol:nil flags:nil
 13614 	    domain:#'AF_INET' type:#stream protocol:nil flags:nil
 13610      self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
 13615      self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
 13611 	    domain:#'AF_INET6' type:#stream protocol:nil flags:nil
 13616 	    domain:#'AF_INET6' type:#stream protocol:nil flags:nil
 13612     "
 13617     "
 13613 
 13618 
 13614     "Modified: / 03-03-2019 / 11:23:38 / Claus Gittinger"
 13619     "Modified: / 03-03-2019 / 11:23:38 / Claus Gittinger"
 13615 !
 13620 !