UnixOperatingSystem.st
author Stefan Vogel <sv@exept.de>
Tue, 11 Dec 2001 21:21:45 +0100
changeset 6306 0e4cc1ce9245
parent 6301 f95d23e6da4d
child 6334 cbb0e8c8c1a5
permissions -rw-r--r--
More FileDescriptorHandle stuff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 1988 by Claus Gittinger
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
     3
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    13
"{ Package: 'stx:libbasic' }"
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    14
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
AbstractOperatingSystem subclass:#UnixOperatingSystem
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    16
	instanceVariableNames:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    17
	classVariableNames:'HostName DomainName SlowFork ForkFailed CurrentDirectory'
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    18
	poolDictionaries:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    19
	category:'OS-Unix'
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    20
!
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    21
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    22
Object subclass:#FileDescriptorHandle
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    23
	instanceVariableNames:'fd'
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    24
	classVariableNames:'OpenFiles'
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    25
	poolDictionaries:''
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    26
	privateIn:UnixOperatingSystem
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    27
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    28
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    29
OSFileHandle subclass:#FilePointerHandle
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    30
	instanceVariableNames:''
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    31
	classVariableNames:''
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    32
	poolDictionaries:''
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    33
	privateIn:UnixOperatingSystem
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    34
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    35
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    36
Object subclass:#FileStatusInfo
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    37
	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path'
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    38
	classVariableNames:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    39
	poolDictionaries:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    40
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    43
Object subclass:#OSProcessStatus
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    44
	instanceVariableNames:'pid status code core'
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    45
	classVariableNames:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    46
	poolDictionaries:''
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    47
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!UnixOperatingSystem primitiveDefinitions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
#if defined(_AIX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
# ifndef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
#  define WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
#ifdef LINUX
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    63
# define __xxUSE_GNU      /* new */
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    64
# undef HAS_UTS_DOMAINNAME
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    65
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    66
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    67
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    68
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    69
# endif
3956
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    70
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    71
# ifndef _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    72
#  include <sys/types.h>
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    73
#  define _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    74
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
  /* use inline string macros */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
# define __STRINGDEFS__
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
    77
# include "linuxIntern.h"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
# define WANT_SHM
3544
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
    83
# define HAS_SETENV
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
    84
# define HAS_UNSETENV
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
    85
# include <time.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
#ifdef IRIX5
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
#ifdef ultrix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
#ifdef hpux
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
#ifdef solaris
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
#if defined(SYSV4) && defined(i386) /* e.g. unixware */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
 * notice: although many systems' include files
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
 * already block against multiple inclusion, some
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
 * do not. Therefore, this is done here again.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
 * (it does not hurt)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
 */ 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
#ifdef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
# ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
#  include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
#  define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
# include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
# define _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
# include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
# define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
#endif /* WANT_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
extern int shmctl(), shmget(), shmdt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
extern char * shmat();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
# include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
# define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
# include <sys/ipc.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
# define _SYS_IPC_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
# include <sys/shm.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
# define _SYS_SHM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
#endif /* WANT_SHM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
#ifdef IRIX5
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
# include <sys/syssgi.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
#ifdef transputer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
# define unlink(f)      ((remove(f) == 0) ? 0 : -1)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
#else /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
# ifdef SYSV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
#  ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
#   include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
#   define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
#  ifndef _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
#   ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
#    include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
#    define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
#  ifndef _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
#   include <sys/times.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
#   define _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
#  ifndef _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
#   include <sys/file.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
#   define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
#  if ! defined(sco3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
#   ifndef _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
#    include <unistd.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
#    define _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
#  if defined(isc3_2) || defined(sco3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
#   ifndef _SYS_TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
#    include <sys/time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
#    define _SYS_TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
#  if !defined(isc3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
#   if defined(PCS) && defined(mips)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
#    include "/usr/include/bsd/sys/time.h"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
#    include "/usr/include/sys/time.h"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
#    ifndef _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
#     include <time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
#     define _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
#    endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
#  if defined(isc3_2)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
#   include <sys/bsdtypes.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
# else /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   217
#  ifndef _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   218
#   include <sys/time.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   219
#   define _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   220
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   221
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   222
#  ifndef _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   223
#   include <sys/types.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   224
#   define _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   225
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   226
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
# endif /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
# ifdef aix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
#  ifndef _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
#   include <time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
#   define _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
#  ifndef _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
#   include <sys/select.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
#   define _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
# endif /* aix */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   243
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   244
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   245
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   246
# endif
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   247
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   248
# ifndef _PWD_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   249
#  include <pwd.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   250
#  define _PWD_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   251
# endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   252
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   253
# ifndef NO_GRP_H
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   254
#  ifndef _GRP_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   255
#   include <grp.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   256
#   define _GRP_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
#  endif
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   258
# endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   259
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
# ifndef _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
#  include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
#  define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
# ifndef _SYS_FILE_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   267
#  include <sys/file.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
#  define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
# ifndef _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
#  include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
#  define _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
# ifndef _FCNTL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   277
#  include <fcntl.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   278
#  define _FCNTL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
# ifndef _IOCTL_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   282
#  include <sys/ioctl.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   283
#  define _IOCTL_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
# if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
#  define HAS_LOCALECONV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
# if defined (HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
#  ifndef _LOCALE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
#   include <locale.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
#   define _LOCALE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   297
# if defined (HAS_FTIME)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   298
#  include <sys/timeb.h>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   299
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   300
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
/* 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
 * posix systems should define these ... 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
 * but on some (older) systems, they are not.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
# ifndef S_IXUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
#  ifdef S_IEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
#   define S_IXUSR S_IEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
#   define S_IXGRP (S_IEXEC>>3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
#   define S_IXOTH (S_IEXEC>>6)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
# ifndef S_IXUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
#  define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
#  define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
#  define S_IXOTH 0001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
# ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
#  define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
#  define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
#  define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
# ifndef S_IWUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
#  define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
#  define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
#  define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
# ifndef MAXPATHLEN
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   332
#  ifndef NO_SYS_PARAM_H
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   333
#   include <sys/param.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
#  ifndef MAXPATHLEN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
#   ifdef FILENAME_MAX  /* i.e. MSDOS_LIKE */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
#    define MAXPATHLEN FILENAME_MAX
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
#    ifdef MAX_PATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
#     define MAXPATHLEN MAX_PATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
#    else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
#     define MAXPATHLEN 1024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
#    endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
# if defined(HAS_UNAME)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
#  include <sys/utsname.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
# if defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
#  include <stropts.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
4285
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   356
# ifndef aix
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   357
#  include <sys/termios.h>
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   358
# endif
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   359
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
 * NeXT has no pid_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
 * and no sigemptyset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
# ifdef NEXT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
   typedef int pid_t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
#  define sigemptyset(set)      ((*(set) = 0L), 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
#  define HAS_GETDOMAINNAME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
#  define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
# ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
#  undef NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
#  undef HAS_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
#  define HAS_WAIT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
#  define HAS_SIGACTION
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
 * some (BSD ?) have no timezone global,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
 * but provide the info in struct timezone.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
# if defined(ultrix) || defined(sunos) || defined(NEXT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
#  define HAS_NO_TIMEZONE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   387
 * sigaction dummies (you won't believe these call themself ``POSIX'' systems ...)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
# ifndef SA_RESTART
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
#  define SA_RESTART    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
# ifndef SA_SIGINFO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
#  define SA_SIGINFO    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
# if defined(HAS_WAITPID) || defined(HAS_WAIT3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
#  include <sys/wait.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
# if defined(HAS_SYSINFO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
#  include <sys/systeminfo.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   404
# ifdef LINUX
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   405
#  include <linux/kernel.h>
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   406
#  include <linux/sys.h>
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   407
# endif
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   408
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   409
# if defined(HAS_GETSYSINFO)
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   410
#  include <sys/sysinfo.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   411
#  include <machine/hal_sysinfo.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   412
#  include <machine/hal/cpuconf.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   413
# endif
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   414
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   415
# if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   416
#  ifndef _UNISTD_H_INCLUDED_
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   417
#   include <unistd.h>
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   418
#   define _UNISTD_H_INCLUDED_
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   419
#  endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   420
# endif
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   421
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
#endif /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
 * on some systems errno is a macro ... check for it here
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
#ifndef errno
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
 extern errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
 * some (old ?) systems do not define this ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
#if !defined(R_OK) && !defined(_AIX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
# define R_OK    4       /* Test for Read permission */ 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
# define W_OK    2       /* Test for Write permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
# define X_OK    1       /* Test for eXecute permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
# define F_OK    0       /* Test for existence of File */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   441
#define SIGHANDLER_ARG
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
#ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
#ifdef NEXT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
 * not all systems have time_t and off_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
 * explicit add of those we know to have ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
#ifdef __osf__
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
# define TIME_T time_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
# define OFF_T  off_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
#ifndef TIME_T
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
# define TIME_T long
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
#ifndef OFF_T
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
# define OFF_T  long
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
 * where is the timezone info ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
#if defined(HAS_NO_TIMEZONE)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
# if defined(HAS_NO_TM_GMTOFF)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
#  define TIMEZONE(tmPtr)       0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
#  define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
#else
5656
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
   476
# if defined(HAS_ALTZONE)
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
   477
#  define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : altzone)
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
   478
# else  /*!HAS_ALTZONE*/
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
   479
#  define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : timezone-3600)
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
   480
# endif /*!HAS_ALTZONE*/
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
   481
#endif                                                                                                                                                                                                                                                                                                                                                                                                                               
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
3595
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   483
#ifndef CONST
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   484
# ifdef __GNUC__
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   485
#  define CONST const
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   486
# else
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   487
#  define CONST /* nothing */
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   488
# endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   489
#endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   490
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
%}
5656
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
   492
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
!UnixOperatingSystem primitiveFunctions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
 * some systems' system() is broken in that it does not correctly 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
 * handle EINTR and returns failure even though it actually succeeded. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
 * (LINUX is one of them)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
 * Here is a fixed version. If you encounter EINTR returns from
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
 * UnixOperatingSystem>>executeCommand, you ought to define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
 * in the xxxIntern.h file to get this fixed version.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   505
 *
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
 * As an added BONUS, this system() enables interrupts while waiting
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   507
 * for the child which enables other threads to continue.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
 * (i.e. it is RT safe)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   511
#if defined(WANT_SYSTEM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   513
/* # define DPRINTF(x)     printf x */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
# define DPRINTF(x)     /* nothing */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
# ifndef _STDDEF_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
#  include <stddef.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
#  define _STDDEF_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   520
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
# ifndef _STDLIB_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
#  include <stdlib.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
#  define _STDLIB_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
# ifndef _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
#  include <unistd.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
#  define _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
# ifndef _SYS_WAIT_H_INCLUDED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
#  include <sys/wait.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
#  define _SYS_WAIT_H_INCLUDED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
# ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
#  include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
#  define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
#  define       __environ       environ
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   548
#  if 1 /* !defined(LINUX) */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
#   define      __sigemptyset   sigemptyset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
#   define      __sigaction     sigaction
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
#   define      __sigaddset     sigaddset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
#   define      __sigprocmask   sigprocmask
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
#   define      __execve        execve
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
#   define      __wait          wait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
#   define      __waitpid       waitpid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
#   if defined(HAS_VFORK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
#    define     FORK            vfork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
#    define     FORK            fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
#  endif /* ! LINUX */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
   extern char **environ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   565
# define      __sigprocmask   sigprocmask
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   566
# define      __execve        execve
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   567
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
# define        SHELL_PATH      "/bin/sh"       /* Path of the shell.  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
# define        SHELL_NAME      "sh"            /* Name to give it.  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
# ifndef        FORK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
#  define       FORK    __fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
static int
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
mySystem(line)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
    register CONST char *line;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
    int status, save;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
    pid_t pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
    struct sigaction sa, intr, quit;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
    sigset_t block, omask;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
    if (line == NULL)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   585
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
    sa.sa_handler = SIG_IGN;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
    sa.sa_flags = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
    __sigemptyset (&sa.sa_mask);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
    if (__sigaction (SIGINT, &sa, &intr) < 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   592
	DPRINTF(("1: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   593
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
    if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   596
	save = errno;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   597
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   598
	errno = save;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   599
	DPRINTF(("2: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   600
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
    __sigemptyset (&block);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
    __sigaddset (&block, SIGCHLD);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
    save = errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   606
    if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   607
	if (errno == ENOSYS)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   608
	    errno = save;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   609
	else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   610
	    save = errno;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   611
	    (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   612
	    (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   613
	    errno = save;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   614
	    DPRINTF(("3: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   615
	    return -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   616
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    pid = FORK ();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
    if (pid == (pid_t) 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   621
	/* Child side.  */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   622
	CONST char *new_argv[4];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   623
	new_argv[0] = SHELL_NAME;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   624
	new_argv[1] = "-c";
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   625
	new_argv[2] = line;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   626
	new_argv[3] = NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   627
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   628
	/* Restore the signals.  */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   629
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   630
	(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   631
	(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   632
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   633
	/* Exec the shell.  */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   634
	(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   635
	_exit (127);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   637
	if (pid < (pid_t) 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   638
	    /* The fork failed.  */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   639
	    DPRINTF(("4: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   640
	    status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   641
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   642
	    /* Parent side.  */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
#ifdef  NO_WAITPID
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   644
	    pid_t child;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   645
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   646
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   647
		__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   648
		child = __wait (&status);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   649
		__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   650
		if (child < 0 && errno != EINTR) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   651
		    DPRINTF(("5: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   652
		    status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   653
		    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   654
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   655
	    } while (child != pid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
#else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   657
	    pid_t child;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   658
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   659
	    /* claus: the original did not care for EINTR here ... */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   660
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   661
		__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   662
		child = __waitpid (pid, &status, 0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   663
		__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   664
	    } while ((child != pid) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   665
	    if (child != pid) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   666
		DPRINTF(("6: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   667
		status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   668
	    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
#endif /* NO_WAITPID */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   670
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
    save = errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
    if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
     | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
     | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   676
	if (errno == ENOSYS) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   677
	    errno = save;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   678
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   679
	    status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   680
	    DPRINTF(("7: errno=%d\n", errno));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   681
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
    return status;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
# define __wait wait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
#endif /* WANT_SYSTEM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   692
 * some systems do not have realpath();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
 * the alternative of reading from a 'pwp'-pipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
 * is way too slow. Here is a realpath for the rest of us.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
 * define WANT_REALPATH in the xxxIntern-file to get it.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
#if defined(HAS_REALPATH)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
# undef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
# undef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
#if defined(WANT_REALPATH)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
# ifndef NULL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
#  define NULL (char *)0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   710
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   711
# define MAX_READLINKS 32
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
# ifndef MAXPATHLEN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
#  define MAXPATHLEN     1024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
static
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
char *realpath(path, resolved_path)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
char *path;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
char resolved_path [];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
{
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   722
	char copy_path[MAXPATHLEN];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   723
	char link_path[MAXPATHLEN];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   724
	char *new_path = resolved_path;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   725
	char *max_path;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   726
	int readlinks = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   727
	int n;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   728
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   729
	/* Make a copy of the source path since we may need to modify it. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   730
	strcpy(copy_path, path);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   731
	path = copy_path;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   732
	max_path = copy_path + MAXPATHLEN - 2;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   733
	/* If it's a relative pathname use getwd for starters. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   734
	if (*path != '/') {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
#ifdef HAS_GETCWD
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   736
		new_path = getcwd(new_path, MAXPATHLEN - 1);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   737
#else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   738
		new_path = getwd(new_path);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   739
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   740
		if (new_path == NULL) 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   741
		    return(NULL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   742
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   743
		new_path += strlen(new_path);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   744
		if (new_path[-1] != '/')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   745
			*new_path++ = '/';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   746
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   747
	else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   748
		*new_path++ = '/';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   749
		path++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   750
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   751
	/* Expand each slash-separated pathname component. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   752
	while (*path != '\0') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   753
		/* Ignore stray "/". */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   754
		if (*path == '/') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   755
			path++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   756
			continue;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   757
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   758
		if (*path == '.') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   759
			/* Ignore ".". */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   760
			if (path[1] == '\0' || path[1] == '/') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   761
				path++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   762
				continue;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   763
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   764
			if (path[1] == '.') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   765
				if (path[2] == '\0' || path[2] == '/') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   766
					path += 2;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   767
					/* Ignore ".." at root. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   768
					if (new_path == resolved_path + 1)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   769
						continue;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   770
					/* Handle ".." by backing up. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   771
					while ((--new_path)[-1] != '/')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   772
						;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   773
					continue;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   774
				}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   775
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   776
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   777
		/* Safely copy the next pathname component. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   778
		while (*path != '\0' && *path != '/') {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   779
			if (path > max_path) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   780
				errno = ENAMETOOLONG;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   781
				return NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   782
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   783
			*new_path++ = *path++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   784
		}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
#ifdef S_IFLNK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   786
		/* Protect against infinite loops. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   787
		if (readlinks++ > MAX_READLINKS) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   788
			errno = ELOOP;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   789
			return NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   790
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   791
		/* See if latest pathname component is a symlink. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   792
		*new_path = '\0';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   793
		n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   794
		if (n < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   795
			/* EINVAL means the file exists but isn't a symlink. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   796
			if (errno != EINVAL)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   797
				return NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   798
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   799
		else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   800
			/* Note: readlink doesn't add the null byte. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   801
			link_path[n] = '\0';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   802
			if (*link_path == '/')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   803
				/* Start over for an absolute symlink. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   804
				new_path = resolved_path;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   805
			else
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   806
				/* Otherwise back up over this component. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   807
				while (*(--new_path) != '/')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   808
					;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   809
			/* Safe sex check. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   810
			if (strlen(path) + n >= MAXPATHLEN) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   811
				errno = ENAMETOOLONG;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   812
				return NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   813
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   814
			/* Insert symlink contents into path. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   815
			strcat(link_path, path);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   816
			strcpy(copy_path, link_path);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   817
			path = copy_path;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   818
		}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
#endif /* S_IFLNK */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   820
		*new_path++ = '/';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   821
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   822
	/* Delete trailing slash but don't whomp a lone slash. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   823
	if (new_path != resolved_path + 1 && new_path[-1] == '/')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   824
		new_path--;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   825
	/* Make sure it's null terminated. */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   826
	*new_path = '\0';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   827
	return resolved_path;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
# define HAS_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
#endif /* WANT_REALPATH && not HAS_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
copyright
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
 COPYRIGHT (c) 1988 by Claus Gittinger
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   840
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
 This software is furnished under a license and may be used
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
 only in accordance with the terms of that license and with the
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
 inclusion of the above copyright notice.   This software may not
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
 be provided or otherwise made available to, or used by, any
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
 other person.  No title to or ownership of the software is
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
    this class realizes access to most (all ?) required operating system services;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
    some of it is very specific for unix, so do not depend on
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
    things available here in your applications 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
    - some may not be found in other OS's or be slightly different ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
    (On the other hand: I do not want to hide all features
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
     from you - in some situations it MAY be interesting to be
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
     able to get down to a select or fork system call easily (at least on Unix systems).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
     You decide - portability vs. functionality)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
    [Class variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   865
	HostName        <String>        remembered hostname
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   866
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   867
	DomainName      <String>        remembered domainname
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   868
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   869
	SlowFork        <Boolean>       if set, fork and popen are avoided;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   870
					(more or less obsolete now)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   871
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   872
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   873
	CurrentDirectory <String>       remembered currentDirectories path
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
    [author:]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   876
	Claus Gittinger
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   877
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
    [see also:]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   879
	OSProcessStatus
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   880
	Filename Date Time
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   881
	ExternalStream FileStream PipeStream Socket
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   882
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
examples
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
  various queries
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   888
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
    Transcript 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   890
	showCR:'hello ' , (OperatingSystem getLoginName)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   891
								[exEnd]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   892
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   893
								[exBegin]
3793
aff27e755ffd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   894
    OperatingSystem isUNIXlike ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   895
	Transcript showCR:'this is some UNIX-like OS'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
    ] ifFalse:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   897
	Transcript showCR:'this OS is not UNIX-like'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   898
    ]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   899
								[exEnd]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   900
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   901
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
    Transcript 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   903
	showCR:'this machine is called ' , OperatingSystem getHostName
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   904
								[exEnd]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   905
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   906
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   907
    Transcript 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   908
	showCR:('this machine is in the '
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   909
	       , OperatingSystem getDomainName
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   910
	       , ' domain')
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   911
								[exEnd]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   912
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   913
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
    Transcript 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   915
	showCR:('this machine''s CPU is a '
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   916
	       , OperatingSystem getCPUType
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   917
	       )
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   918
								[exEnd]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   919
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   920
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
    Transcript showCR:'executing ls command ...'.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
   922
    OperatingSystem executeCommand:'ls'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
    Transcript showCR:'... done.'.
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   924
								[exEnd]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   925
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
  locking a file 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
  (should be executed on two running smalltalks - not in two threads):
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   928
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   929
    |f|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   930
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   931
    f := 'testFile' asFilename readWriteStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   932
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   933
    10 timesRepeat:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   934
	'about to lock ...' printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   935
	[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   936
	  OperatingSystem 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   937
	    lockFD:(f fileDescriptor)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   938
	    shared:false
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   939
	    blocking:false
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   940
	] whileFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   941
	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   942
	    Delay waitForSeconds:1
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   943
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   944
	'LOCKED ...' printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   945
	Delay waitForSeconds:10.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   946
	'unlock ...' printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   947
	(OperatingSystem 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   948
	    unlockFD:(f fileDescriptor)) printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   949
	Delay waitForSeconds:3.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   950
    ]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   951
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   954
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
!UnixOperatingSystem class methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   956
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   957
initialize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   958
    "initialize the class"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   959
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   960
    ObjectMemory addDependent:self.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   961
    HostName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
    DomainName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
    LastErrorNumber := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
    PipeFailed := false.
4395
53122eb3ce70 clear ForkFailed flag; made it a classVar
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
   965
    ForkFailed := false.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
    SlowFork := false.
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   967
    CurrentDirectory := nil.
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   968
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   969
    "Modified: / 11.12.1998 / 16:35:39 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
update:something with:aParameter from:changedObject
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
    "catch image restart and flush some cached data"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
    something == #earlyRestart ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   976
	"
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   977
	 flush cached data/info
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   978
	"
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   979
	HostName := nil.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   980
	DomainName := nil.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   981
	LastErrorNumber := nil.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   982
	PipeFailed := false.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   983
	SlowFork := false.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   984
	ForkFailed := false.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   985
	CurrentDirectory := nil.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
    ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   988
    "Created: / 15.6.1996 / 15:22:37 / cg"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   989
    "Modified: / 7.1.1997 / 19:36:11 / stefan"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   990
    "Modified: / 11.12.1998 / 16:22:48 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
!UnixOperatingSystem class methodsFor:'OS signal constants'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
sigABRT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
    "return the signal number for SIGABRT - 0 if not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   999
    ^ self signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1000
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1001
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1002
     OperatingSystem sigABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1003
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
sigALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
    "return the signal number for SIGALRM - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1010
    ^ self signalNamed:#SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1011
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1012
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1013
     OperatingSystem sigALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1014
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1015
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
sigBREAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
    "return the signal number for SIGBREAK - 0 if not supported.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
     This is an MSDOS specific signal"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1021
    ^ self signalNamed:#SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1022
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1023
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1024
     OperatingSystem sigBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1025
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
sigBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
    "return the signal number for SIGBUS - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1032
    ^ self signalNamed:#SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1033
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1034
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1035
     OperatingSystem sigBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1036
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
sigCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
    "return the signal number for SIGCHLD - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1043
    ^ self signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1044
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1045
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1046
     OperatingSystem sigCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1047
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
sigCONT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
    "return the signal number for SIGCONT - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1054
    ^ self signalNamed:#SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1055
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1056
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1057
     OperatingSystem sigCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1058
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
sigDANGER
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
    "return the signal number for SIGDANGER - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1065
    ^ self signalNamed:#SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1066
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1067
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1068
     OperatingSystem sigDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1069
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1072
sigEMT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1073
    "return the signal number for SIGEMT - 0 if not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1074
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1076
    ^ self signalNamed:#SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1077
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1078
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1079
     OperatingSystem sigEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1080
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
sigFP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
    "return the signal number for SIGFP - 0 if not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1087
    ^ self signalNamed:#SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1088
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1089
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1090
     OperatingSystem sigFP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1091
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
sigGRANT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
    "return the signal number for SIGGRANT - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1098
    ^ self signalNamed:#SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1099
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1100
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1101
     OperatingSystem sigGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1102
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
sigHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
    "return the signal number for SIGHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1109
    ^ self signalNamed:#SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1110
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1111
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1112
     OperatingSystem sigHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1113
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1114
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
sigILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
    "return the signal number for SIGILL - 0 if not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1121
    ^ self signalNamed:#SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1122
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1123
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1124
     OperatingSystem sigILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1125
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
sigINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
    "return the signal number for SIGINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1132
    ^ self signalNamed:#SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1133
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1134
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1135
     OperatingSystem sigINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1136
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
sigIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
    "return the signal number for SIGIO - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1143
    ^ self signalNamed:#SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1144
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1145
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1146
     OperatingSystem sigIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1147
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
sigIOT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
    "return the signal number for SIGIOT - 0 if not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1154
    ^ self signalNamed:#SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1155
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1156
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1157
     OperatingSystem sigIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1158
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
sigKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
    "return the signal number for SIGKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1163
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1165
    ^ self signalNamed:#SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1166
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1167
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1168
     OperatingSystem sigKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1169
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
sigLOST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
    "return the signal number for SIGLOST - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1174
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1176
    ^ self signalNamed:#SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1177
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1178
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1179
     OperatingSystem sigLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1180
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1182
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1183
sigMIGRATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1184
    "return the signal number for SIGMIGRATE - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1186
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1187
    ^ self signalNamed:#SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1188
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1189
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1190
     OperatingSystem sigMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1191
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
sigMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
    "return the signal number for SIGMSG - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1196
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1197
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1198
    ^ self signalNamed:#SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1199
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1200
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1201
     OperatingSystem sigMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1202
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1203
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1204
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
sigPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1206
    "return the signal number for SIGPIPE - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1207
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1208
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1209
    ^ self signalNamed:#SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1210
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1211
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1212
     OperatingSystem sigPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1213
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1214
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
sigPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
    "return the signal number for SIGPOLL - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1220
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1221
    ^ self signalNamed:#SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1222
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1223
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1224
     OperatingSystem sigPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1225
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
sigPRE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1229
    "return the signal number for SIGPRE - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1230
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1231
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1232
    ^ self signalNamed:#SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1233
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1234
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1235
     OperatingSystem sigPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1236
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
sigPROF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
    "return the signal number for SIGPROF - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1241
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1243
    ^ self signalNamed:#SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1244
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1245
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1246
     OperatingSystem sigPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1247
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1248
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1249
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1250
sigPWR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1251
    "return the signal number for SIGPWR - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1252
     (not available on all systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1253
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1254
    ^ self signalNamed:#SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1255
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1256
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1257
     OperatingSystem sigPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1258
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1259
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1260
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
sigQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
    "return the signal number for SIGQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1263
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1264
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1265
    ^ self signalNamed:#SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1266
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1267
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1268
     OperatingSystem sigQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1269
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1270
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1271
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
sigRETRACT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1273
    "return the signal number for SIGRETRACT - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1274
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1275
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1276
    ^ self signalNamed:#SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1277
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1278
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1279
     OperatingSystem sigRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1280
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1281
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1282
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1284
sigSAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1285
    "return the signal number for SIGSAK - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1286
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1287
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1288
    ^ self signalNamed:#SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1289
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1290
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1291
     OperatingSystem sigSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1292
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1293
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1294
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1295
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1296
sigSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1297
    "return the signal number for SIGSEGV - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1298
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1299
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1300
    ^ self signalNamed:#SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1301
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1302
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1303
     OperatingSystem sigSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1304
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1305
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1307
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1308
sigSOUND
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1309
    "return the signal number for SIGSOUND - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1310
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1311
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1312
    ^ self signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1313
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1314
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1315
     OperatingSystem sigSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1316
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1317
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1318
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1319
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1320
sigSTOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1321
    "return the signal number for SIGSTOP - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1322
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1323
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1324
    ^ self signalNamed:#SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1325
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1326
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1327
     OperatingSystem sigSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1328
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1330
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
sigSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1332
    "return the signal number for SIGSYS - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1333
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1334
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1335
    ^ self signalNamed:#SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1336
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1337
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1338
     OperatingSystem sigSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1339
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
sigTERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
    "return the signal number for SIGTERM - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1344
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1345
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1346
    ^ self signalNamed:#SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1347
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1348
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1349
     OperatingSystem sigTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1350
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1351
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
sigTRAP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1355
    "return the signal number for SIGTRAP - 0 if not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1356
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1357
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1358
    ^ self signalNamed:#SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1359
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1360
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1361
     OperatingSystem sigTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1362
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1363
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1364
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1365
sigTSTP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1366
    "return the signal number for SIGTSTP - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1367
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1368
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1369
    ^ self signalNamed:#SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1370
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1371
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1372
     OperatingSystem sigTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1373
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1374
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1375
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1376
sigTTIN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1377
    "return the signal number for SIGTTIN - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1378
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1379
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1380
    ^ self signalNamed:#SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1381
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1382
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1383
     OperatingSystem sigTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1384
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
sigTTOU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
    "return the signal number for SIGTTOU - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1391
    ^ self signalNamed:#SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1392
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1393
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1394
     OperatingSystem sigTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1395
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1397
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1398
sigURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
    "return the signal number for SIGURG - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1400
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1401
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1402
    ^ self signalNamed:#SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1403
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1404
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1405
     OperatingSystem sigURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1406
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1407
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1408
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1409
sigUSR1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1410
    "return the signal number for SIGUSR1 - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1411
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1412
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1413
    ^ self signalNamed:#SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1414
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1415
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1416
     OperatingSystem sigUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1417
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1418
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1419
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
sigUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1421
    "return the signal number for SIGUSR2 - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1422
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1424
    ^ self signalNamed:#SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1425
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1426
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1427
     OperatingSystem sigUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1428
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1431
sigVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1432
    "return the signal number for SIGVTALRM - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1433
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1434
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1435
    ^ self signalNamed:#SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1436
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1437
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1438
     OperatingSystem sigVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1439
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1440
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1442
sigWINCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1443
    "return the signal number for SIGWINCH - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1444
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1445
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1446
    ^ self signalNamed:#SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1447
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1448
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1449
     OperatingSystem sigWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1450
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1451
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
sigXCPU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1455
    "return the signal number for SIGXCPU - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1456
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1457
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1458
    ^ self signalNamed:#SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1459
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1460
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1461
     OperatingSystem sigXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1462
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1463
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1465
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1466
sigXFSZ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1467
    "return the signal number for SIGXFSZ - 0 if not supported
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1468
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1469
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1470
    ^ self signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1471
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1472
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1473
     OperatingSystem sigXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1474
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1475
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1476
!
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1477
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1478
signalNamed:signalName
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1479
    "return the signal number for a named signal (must be a symbol)
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1480
     Return 0 if that signal is not supported by the OS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1481
     (NOTICE: the numeric value is not the same across unix-systems, 
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1482
      therefore do not remember or hardcode those numbers in the application)"
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1483
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1484
%{  /* NOCONTEXT */
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1485
#ifdef SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1486
    if (signalName == @symbol(SIGABRT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1487
	RETURN ( __MKSMALLINT(SIGABRT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1488
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1489
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1490
#ifdef SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1491
    if (signalName == @symbol(SIGALRM)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1492
	RETURN ( __MKSMALLINT(SIGALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1493
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1494
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1495
#ifdef SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1496
    if (signalName == @symbol(SIGBREAK)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1497
	RETURN ( __MKSMALLINT(SIGBREAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1498
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1499
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1500
#ifdef SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1501
    if (signalName == @symbol(SIGBUS)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1502
	RETURN ( __MKSMALLINT(SIGBUS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1503
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1504
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1505
#ifdef SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1506
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1507
     || (signalName == @symbol(SIGCLD)) ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1508
	RETURN ( __MKSMALLINT(SIGCHLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1509
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1510
#else
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1511
# if defined(SIGCLD)
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1512
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1513
     || (signalName == @symbol(SIGCLD)) ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1514
	RETURN ( __MKSMALLINT(SIGCLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1515
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1516
# endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1517
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1518
#ifdef SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1519
    if (signalName == @symbol(SIGCONT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1520
	RETURN ( __MKSMALLINT(SIGCONT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1521
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1522
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1523
#ifdef SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1524
    if (signalName == @symbol(SIGDANGER)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1525
	RETURN ( __MKSMALLINT(SIGDANGER) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1526
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1527
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1528
#ifdef SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1529
    if (signalName == @symbol(SIGEMT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1530
	RETURN ( __MKSMALLINT(SIGEMT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1531
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1532
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1533
#ifdef SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1534
    if (signalName == @symbol(SIGFPE)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1535
	RETURN ( __MKSMALLINT(SIGFPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1536
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1537
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1538
#ifdef SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1539
    if (signalName == @symbol(SIGGRANT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1540
	RETURN ( __MKSMALLINT(SIGGRANT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1541
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1542
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1543
#ifdef SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1544
    if (signalName == @symbol(SIGHUP)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1545
	RETURN ( __MKSMALLINT(SIGHUP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1546
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1547
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1548
#ifdef SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1549
    if (signalName == @symbol(SIGILL)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1550
	RETURN ( __MKSMALLINT(SIGILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1551
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1552
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1553
#ifdef SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1554
    if (signalName == @symbol(SIGINT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1555
	RETURN ( __MKSMALLINT(SIGINT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1556
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1557
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1558
#ifdef SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1559
    if (signalName == @symbol(SIGIO)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1560
	RETURN ( __MKSMALLINT(SIGIO) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1561
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1562
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1563
#ifdef SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1564
    if (signalName == @symbol(SIGIOT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1565
	RETURN ( __MKSMALLINT(SIGIOT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1566
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1567
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1568
#ifdef SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1569
    if (signalName == @symbol(SIGKILL)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1570
	RETURN ( __MKSMALLINT(SIGKILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1571
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1572
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1573
#ifdef SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1574
    if (signalName == @symbol(SIGLOST)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1575
	RETURN ( __MKSMALLINT(SIGLOST) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1576
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1577
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1578
#ifdef SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1579
    if (signalName == @symbol(SIGMIGRATE)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1580
	RETURN ( __MKSMALLINT(SIGMIGRATE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1581
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1582
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1583
#ifdef SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1584
    if (signalName == @symbol(SIGMSG)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1585
	RETURN ( __MKSMALLINT(SIGMSG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1586
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1587
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1588
#ifdef SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1589
    if (signalName == @symbol(SIGPIPE)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1590
	RETURN ( __MKSMALLINT(SIGPIPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1591
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1592
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1593
#ifdef SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1594
    if (signalName == @symbol(SIGPOLL)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1595
	RETURN ( __MKSMALLINT(SIGPOLL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1596
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1597
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1598
#ifdef SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1599
    if (signalName == @symbol(SIGPRE)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1600
	RETURN ( __MKSMALLINT(SIGPRE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1601
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1602
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1603
#ifdef SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1604
    if (signalName == @symbol(SIGPROF)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1605
	RETURN ( __MKSMALLINT(SIGPROF) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1606
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1607
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1608
#ifdef SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1609
    if (signalName == @symbol(SIGPWR)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1610
	RETURN ( __MKSMALLINT(SIGPWR) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1611
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1612
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1613
#ifdef SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1614
    if (signalName == @symbol(SIGQUIT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1615
	RETURN ( __MKSMALLINT(SIGQUIT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1616
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1617
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1618
#ifdef SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1619
    if (signalName == @symbol(SIGRETRACT)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1620
	RETURN ( __MKSMALLINT(SIGRETRACT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1621
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1622
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1623
#ifdef SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1624
    if (signalName == @symbol(SIGSAK)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1625
	RETURN ( __MKSMALLINT(SIGSAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1626
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1627
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1628
#ifdef SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1629
    if (signalName == @symbol(SIGSEGV)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1630
	RETURN ( __MKSMALLINT(SIGSEGV) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1631
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1632
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1633
#ifdef SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1634
    if (signalName == @symbol(SIGSOUND)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1635
	RETURN ( __MKSMALLINT(SIGSOUND) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1636
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1637
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1638
#ifdef SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1639
    if (signalName == @symbol(SIGSTOP)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1640
	RETURN ( __MKSMALLINT(SIGSTOP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1641
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1642
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1643
#ifdef SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1644
    if (signalName == @symbol(SIGSYS)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1645
	RETURN ( __MKSMALLINT(SIGSYS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1646
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1647
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1648
#ifdef SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1649
    if (signalName == @symbol(SIGTERM)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1650
	RETURN ( __MKSMALLINT(SIGTERM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1651
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1652
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1653
#ifdef SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1654
    if (signalName == @symbol(SIGTRAP)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1655
	RETURN ( __MKSMALLINT(SIGTRAP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1656
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1657
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1658
#ifdef SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1659
    if (signalName == @symbol(SIGTSTP)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1660
	RETURN ( __MKSMALLINT(SIGTSTP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1661
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1662
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1663
#ifdef SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1664
    if (signalName == @symbol(SIGTTIN)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1665
	RETURN ( __MKSMALLINT(SIGTTIN) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1666
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1667
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1668
#ifdef SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1669
    if (signalName == @symbol(SIGTTOU)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1670
	RETURN ( __MKSMALLINT(SIGTTOU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1671
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1672
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1673
#ifdef SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1674
    if (signalName == @symbol(SIGURG)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1675
	RETURN ( __MKSMALLINT(SIGURG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1676
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1677
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1678
#ifdef SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1679
    if (signalName == @symbol(SIGUSR1)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1680
	RETURN ( __MKSMALLINT(SIGUSR1) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1681
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1682
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1683
#ifdef SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1684
    if (signalName == @symbol(SIGUSR2)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1685
	RETURN ( __MKSMALLINT(SIGUSR2) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1686
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1687
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1688
#ifdef SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1689
    if (signalName == @symbol(SIGVTALRM)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1690
	RETURN ( __MKSMALLINT(SIGVTALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1691
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1692
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1693
#ifdef SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1694
    if (signalName == @symbol(SIGWINCH)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1695
	RETURN ( __MKSMALLINT(SIGWINCH) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1696
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1697
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1698
#ifdef SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1699
    if (signalName == @symbol(SIGXCPU)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1700
	RETURN ( __MKSMALLINT(SIGXCPU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1701
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1702
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1703
#ifdef SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1704
    if (signalName == @symbol(SIGXFSZ)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  1705
	RETURN ( __MKSMALLINT(SIGXFSZ) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1706
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1707
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1708
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1709
    RETURN ( __MKSMALLINT(0) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1710
%}
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1711
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1712
     OperatingSystem signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1713
     OperatingSystem signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1714
     OperatingSystem signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1715
     OperatingSystem signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1716
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1717
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1718
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1719
!UnixOperatingSystem class methodsFor:'error messages'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1720
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1721
currentErrorNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1722
    "returns the OS's last error nr (i.e. the value of errno).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1723
     Notice, that the value of this flag is only valid immediately
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1724
     after the error occurred - it gets updated with every other
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1725
     request to the OS.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1726
     Use lastErrorNumber - currentErrorNumber is invalidated by
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1727
     many, many internal calls."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1728
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1729
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1730
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1731
     RETURN ( __MKSMALLINT(errno) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1732
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1733
     "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  1734
      OperatingSystem currentErrorNumber
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1735
     "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1736
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1737
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1738
errorHolderForNumber:errNr
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1739
    "return an osErrorHolder for the given error number (as returned by a system call)." 
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1740
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1741
    |sym typ holder|
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1742
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1743
%{
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1744
    /* claus:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1745
     * I made this primitive code, since errnos are not
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1746
     * standard across unixes
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1747
     */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1748
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1749
    typ = @symbol(defaultOsErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1750
    sym = @symbol(ERROR_OTHER);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1751
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1752
    if (__isSmallInteger(errNr)) {
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1753
        switch ( __intVal(errNr)) {
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1754
            /*
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1755
             * POSIX errnos - these should be defined
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1756
             */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1757
#ifdef EPERM
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1758
            case EPERM:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1759
                sym = @symbol(EPERM);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1760
                typ = @symbol(noPermissionsSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1761
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1762
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1763
#ifdef ENOENT
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1764
            case ENOENT:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1765
                sym = @symbol(ENOENT);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1766
                typ = @symbol(nonexistentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1767
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1768
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1769
#ifdef ESRCH
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1770
            case ESRCH:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1771
                sym = @symbol(ESRCH);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1772
                typ = @symbol(unavailableReferentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1773
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1774
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1775
#ifdef EINTR
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1776
            case EINTR:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1777
                sym = @symbol(EINTR);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1778
                typ = @symbol(transientErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1779
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1780
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1781
#ifdef EIO
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1782
            case EIO:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1783
                sym = @symbol(EIO);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1784
                typ = @symbol(transferFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1785
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1786
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1787
#ifdef ENXIO
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1788
            case ENXIO:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1789
                sym = @symbol(ENXIO);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1790
                typ = @symbol(unavailableReferentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1791
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1792
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1793
#ifdef E2BIG
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1794
            case E2BIG:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1795
                sym = @symbol(E2BIG);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1796
                typ = @symbol(invalidArgumentsSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1797
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1798
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1799
#ifdef ENOEXEC
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1800
            case ENOEXEC:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1801
                sym = @symbol(ENOEXEC);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1802
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1803
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1804
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1805
#ifdef EBADF
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1806
            case EBADF:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1807
                sym = @symbol(EBADF);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1808
                typ = @symbol(badAccessorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1809
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1810
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1811
#ifdef ECHILD
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1812
            case ECHILD:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1813
                sym = @symbol(ECHILD);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1814
                typ = @symbol(informationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1815
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1816
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1817
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1818
            case EAGAIN:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1819
                sym = @symbol(EAGAIN);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1820
                typ = @symbol(notReadySignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1821
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1822
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1823
#ifdef ENOMEM
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1824
            case ENOMEM:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1825
                sym = @symbol(ENOMEM);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1826
                typ = @symbol(noMemorySignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1827
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1828
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1829
#ifdef EACCES
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1830
            case EACCES:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1831
                sym = @symbol(EACCES);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1832
                typ = @symbol(noPermissionsSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1833
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1834
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1835
#ifdef EFAULT
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1836
            case EFAULT:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1837
                sym = @symbol(EFAULT);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1838
                typ = @symbol(invalidArgumentsSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1839
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1840
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1841
#ifdef EBUSY
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1842
            case EBUSY:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1843
                sym = @symbol(EBUSY);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1844
                typ = @symbol(unavailableReferentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1845
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1846
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1847
#ifdef EEXIST
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1848
            case EEXIST:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1849
                sym = @symbol(EEXIST);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1850
                typ = @symbol(existingReferentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1851
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1852
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1853
#ifdef EXDEV
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1854
            case EXDEV:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1855
                sym = @symbol(EXDEV);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1856
                typ = @symbol(inappropriateReferentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1857
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1858
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1859
#ifdef ENODEV
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1860
            case ENODEV:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1861
                sym = @symbol(ENODEV);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1862
                typ = @symbol(inaccessibleSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1863
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1864
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1865
#ifdef ENOTDIR
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1866
            case ENOTDIR:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1867
                sym = @symbol(ENOTDIR);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1868
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1869
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1870
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1871
#ifdef EISDIR
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1872
            case EISDIR:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1873
                sym = @symbol(EISDIR);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1874
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1875
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1876
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1877
#ifdef EINVAL
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1878
            case EINVAL:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1879
                sym = @symbol(EINVAL);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1880
                typ = @symbol(invalidArgumentsSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1881
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1882
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1883
#ifdef ENFILE
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1884
            case ENFILE:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1885
                sym = @symbol(ENFILE);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1886
                typ = @symbol(noResourcesSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1887
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1888
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1889
#ifdef EMFILE
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1890
            case EMFILE:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1891
                sym = @symbol(EMFILE);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1892
                typ = @symbol(noResourcesSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1893
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1894
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1895
#ifdef ENOTTY
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1896
            case ENOTTY:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1897
                sym = @symbol(ENOTTY);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1898
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1899
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1900
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1901
#ifdef EFBIG
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1902
            case EFBIG:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1903
                sym = @symbol(EFBIG);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1904
                typ = @symbol(noResourcesSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1905
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1906
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1907
#ifdef ENOSPC
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1908
            case ENOSPC:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1909
                sym = @symbol(ENOSPC);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1910
                typ = @symbol(noResourcesSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1911
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1912
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1913
#ifdef ESPIPE
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1914
            case ESPIPE:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1915
                sym = @symbol(ESPIPE);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1916
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1917
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1918
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1919
#ifdef EROFS
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1920
            case EROFS:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1921
                sym = @symbol(EROFS);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1922
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1923
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1924
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1925
#ifdef EMLINK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1926
            case EMLINK:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1927
                sym = @symbol(EMLINK);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1928
                typ = @symbol(rangeErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1929
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1930
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1931
#ifdef EPIPE
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1932
            case EPIPE:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1933
                sym = @symbol(EPIPE);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1934
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1935
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1936
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1937
#ifdef EDOM
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1938
            case EDOM:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1939
                sym = @symbol(EDOM);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1940
                typ = @symbol(rangeErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1941
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1942
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1943
#ifdef ERANGE
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1944
            case ERANGE:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1945
                sym = @symbol(ERANGE);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1946
                typ = @symbol(rangeErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1947
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1948
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1949
#ifdef EDEADLK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1950
# if EDEADLK != EWOULDBLOCK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1951
            case EDEADLK:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1952
                sym = @symbol(EDEADLK);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1953
                typ = @symbol(noResourcesSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1954
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1955
# endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1956
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1957
#ifdef ENAMETOOLONG
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1958
            case ENAMETOOLONG:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1959
                sym = @symbol(ENAMETOOLONG);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1960
                typ = @symbol(rangeErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1961
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1962
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1963
#ifdef ENOLCK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1964
            case ENOLCK:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1965
                sym = @symbol(ENOLCK);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1966
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1967
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1968
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1969
#ifdef ENOSYS
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1970
            case ENOSYS:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1971
                sym = @symbol(ENOSYS);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1972
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1973
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1974
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1975
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1976
            case ENOTEMPTY:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1977
                sym = @symbol(ENOTEMPTY);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1978
                typ = @symbol(inappropriateReferentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1979
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1980
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1981
#ifdef EILSEQ
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1982
            case EILSEQ:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1983
                sym = @symbol(EILSEQ);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1984
                typ = @symbol(transferFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1985
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1986
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1987
            /*
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1988
             * XPG3 errnos - defined on most systems
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1989
             */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1990
#ifdef ENOTBLK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1991
            case ENOTBLK:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1992
                sym = @symbol(ENOTBLK);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1993
                typ = @symbol(inappropriateReferentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1994
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1995
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1996
#ifdef ETXTBSY
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1997
            case ETXTBSY:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1998
                sym = @symbol(ETXTBSY);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1999
                typ = @symbol(inaccessibleSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2000
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2001
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2002
            /*
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2003
             * some others
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2004
             */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2005
#ifdef EWOULDBLOCK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2006
            case EWOULDBLOCK:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2007
                sym = @symbol(EWOULDBLOCK);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2008
                typ = @symbol(notReadySignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2009
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2010
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2011
#ifdef ENOMSG
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2012
            case ENOMSG:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2013
                sym = @symbol(ENOMSG);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2014
                typ = @symbol(noDataSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2015
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2016
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2017
#ifdef ELOOP
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2018
            case ELOOP:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2019
                sym = @symbol(ELOOP);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2020
                typ = @symbol(rangeErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2021
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2022
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2023
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2024
            /*
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2025
             * some stream errors
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2026
             */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2027
#ifdef ETIME
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2028
            case ETIME:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2029
                sym = @symbol(ETIME);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2030
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2031
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2032
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2033
#ifdef ENOSR
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2034
            case ENOSR:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2035
                sym = @symbol(ENOSR);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2036
                typ = @symbol(noResourcesSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2037
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2038
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2039
#ifdef ENOSTR
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2040
            case ENOSTR:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2041
                sym = @symbol(ENOSTR);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2042
                typ = @symbol(inappropriateReferentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2043
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2044
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2045
#ifdef ECOMM
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2046
            case ECOMM:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2047
                sym = @symbol(ECOMM);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2048
                typ = @symbol(transferFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2049
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2050
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2051
#ifdef EPROTO
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2052
            case EPROTO:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2053
                sym = @symbol(EPROTO);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2054
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2055
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2056
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2057
            /*
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2058
             * nfs errors
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2059
             */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2060
#ifdef ESTALE
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2061
            case ESTALE:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2062
                sym = @symbol(ESTALE);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2063
                typ = @symbol(unavailableReferentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2064
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2065
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2066
#ifdef EREMOTE
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2067
            case EREMOTE:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2068
                sym = @symbol(EREMOTE);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2069
                typ = @symbol(rangeErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2070
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2071
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2072
            /*
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2073
             * some networking errors
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2074
             */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2075
#ifdef EINPROGRESS
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2076
            case EINPROGRESS:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2077
                sym = @symbol(EINPROGRESS);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2078
                typ = @symbol(operationStartedSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2079
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2080
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2081
#ifdef EALREADY
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2082
            case EALREADY:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2083
                sym = @symbol(EALREADY);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2084
                typ = @symbol(operationStartedSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2085
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2086
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2087
#ifdef ENOTSOCK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2088
            case ENOTSOCK:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2089
                sym = @symbol(ENOTSOCK);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2090
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2091
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2092
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2093
#ifdef EDESTADDRREQ
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2094
            case EDESTADDRREQ:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2095
                sym = @symbol(EDESTADDRREQ);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2096
                typ = @symbol(underspecifiedSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2097
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2098
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2099
#ifdef EMSGSIZE
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2100
            case EMSGSIZE:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2101
                sym = @symbol(EMSGSIZE);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2102
                typ = @symbol(rangeErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2103
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2104
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2105
#ifdef EPROTOTYPE
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2106
            case EPROTOTYPE:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2107
                sym = @symbol(EPROTOTYPE);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2108
                typ = @symbol(wrongSubtypeForOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2109
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2110
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2111
#ifdef ENOPROTOOPT
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2112
            case ENOPROTOOPT:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2113
                sym = @symbol(ENOPROTOOPT);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2114
                typ = @symbol(unsupportedOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2115
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2116
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2117
#ifdef EPROTONOSUPPORT
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2118
            case EPROTONOSUPPORT:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2119
                sym = @symbol(EPROTONOSUPPORT);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2120
                typ = @symbol(unsupportedOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2121
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2122
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2123
#ifdef ESOCKTNOSUPPORT
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2124
            case ESOCKTNOSUPPORT:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2125
                sym = @symbol(ESOCKTNOSUPPORT);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2126
                typ = @symbol(unsupportedOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2127
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2128
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2129
#ifdef EOPNOTSUPP
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2130
            case EOPNOTSUPP:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2131
                sym = @symbol(EOPNOTSUPP);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2132
                typ = @symbol(inappropriateOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2133
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2134
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2135
#ifdef EPFNOSUPPORT
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2136
            case EPFNOSUPPORT:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2137
                sym = @symbol(EPFNOSUPPORT);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2138
                typ = @symbol(unsupportedOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2139
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2140
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2141
#ifdef EAFNOSUPPORT
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2142
            case EAFNOSUPPORT:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2143
                sym = @symbol(EAFNOSUPPORT);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2144
                typ = @symbol(unsupportedOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2145
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2146
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2147
#ifdef EADDRINUSE
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2148
            case EADDRINUSE:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2149
                sym = @symbol(EADDRINUSE);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2150
                typ = @symbol(existingReferentSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2151
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2152
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2153
#ifdef EADDRNOTAVAIL
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2154
            case EADDRNOTAVAIL:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2155
                sym = @symbol(EADDRNOTAVAIL);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2156
                typ = @symbol(noPermissionsSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2157
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2158
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2159
#ifdef ETIMEDOUT
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2160
            case ETIMEDOUT:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2161
                sym = @symbol(ETIMEDOUT);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2162
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2163
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2164
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2165
#ifdef ECONNREFUSED
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2166
            case ECONNREFUSED:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2167
                sym = @symbol(ECONNREFUSED);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2168
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2169
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2170
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2171
#ifdef ENETDOWN
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2172
            case ENETDOWN:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2173
                sym = @symbol(ENETDOWN);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2174
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2175
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2176
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2177
#ifdef ENETUNREACH
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2178
            case ENETUNREACH:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2179
                sym = @symbol(ENETUNREACH);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2180
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2181
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2182
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2183
#ifdef ENETRESET
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2184
            case ENETRESET:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2185
                sym = @symbol(ENETRESET);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2186
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2187
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2188
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2189
#ifdef ECONNABORTED
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2190
            case ECONNABORTED:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2191
                sym = @symbol(ECONNABORTED);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2192
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2193
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2194
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2195
#ifdef ECONNRESET
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2196
            case ECONNRESET:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2197
                sym = @symbol(ECONNRESET);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2198
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2199
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2200
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2201
#ifdef EISCONN
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2202
            case EISCONN:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2203
                sym = @symbol(EISCONN);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2204
                typ = @symbol(unpreparedOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2205
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2206
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2207
#ifdef ENOTCONN
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2208
            case ENOTCONN:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2209
                sym = @symbol(ENOTCONN);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2210
                typ = @symbol(unpreparedOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2211
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2212
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2213
#ifdef ESHUTDOWN
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2214
            case ESHUTDOWN:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2215
                sym = @symbol(ESHUTDOWN);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2216
                typ = @symbol(unpreparedOperationSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2217
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2218
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2219
#ifdef EHOSTDOWN
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2220
            case EHOSTDOWN:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2221
                sym = @symbol(EHOSTDOWN);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2222
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2223
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2224
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2225
#ifdef EHOSTUNREACH
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2226
            case EHOSTUNREACH:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2227
                sym = @symbol(EHOSTUNREACH);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2228
                typ = @symbol(peerFaultSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2229
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2230
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2231
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2232
            default:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2233
                break;
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2234
        }
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2235
    }
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2236
%}.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2237
    holder := OSErrorHolder new.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2238
    holder errorSymbol:sym errorCategory:typ.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2239
    ^ holder
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2240
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2241
    "
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2242
     OperatingSystem errorHolderForNumber:4           
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2243
     self errorHolderForNumber:(self errorNumberFor:#EPERM)   
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2244
     self errorHolderForNumber:(self errorNumberFor:#EIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2245
     self errorHolderForNumber:(self errorNumberFor:#ENXIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2246
    "
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2247
!
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2248
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2249
errorNumberFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2250
    "given a symbolic error, return the numeric;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2251
     (i.e. errorNumberFor:#EBADF returns EBADF's value).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2252
     Use this, since error numbers are really not standard across unix systems."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2253
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2254
%{   /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2255
    OBJ sym = aSymbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2256
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2257
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2258
     * POSIX errnos - these should be defined
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2259
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2260
#ifdef EPERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2261
    if (sym == @symbol(EPERM)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2262
        RETURN ( __MKSMALLINT(EPERM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2263
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2264
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2265
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2266
#ifdef ENOENT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2267
    if (sym == @symbol(ENOENT)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2268
        RETURN ( __MKSMALLINT(ENOENT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2269
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2270
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2271
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2272
#ifdef ESRCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2273
    if (sym == @symbol(ESRCH)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2274
        RETURN ( __MKSMALLINT(ESRCH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2275
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2276
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2277
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2278
#ifdef EINTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2279
    if (sym == @symbol(EINTR)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2280
        RETURN ( __MKSMALLINT(EINTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2281
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2282
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2283
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2284
#ifdef EIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2285
    if (sym == @symbol(EIO)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2286
        RETURN ( __MKSMALLINT(EIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2287
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2288
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2289
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2290
#ifdef ENXIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2291
    if (sym == @symbol(ENXIO)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2292
        RETURN ( __MKSMALLINT(ENXIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2293
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2294
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2295
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2296
#ifdef E2BIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2297
    if (sym == @symbol(E2BIG)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2298
        RETURN ( __MKSMALLINT(E2BIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2299
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2300
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2301
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2302
#ifdef ENOEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2303
    if (sym == @symbol(ENOEXEC)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2304
        RETURN ( __MKSMALLINT(ENOEXEC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2305
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2306
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2307
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2308
#ifdef EBADF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2309
    if (sym == @symbol(EBADF)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2310
        RETURN ( __MKSMALLINT(EBADF) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2311
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2312
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2313
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2314
#ifdef ECHILD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2315
    if (sym == @symbol(ECHILD)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2316
        RETURN ( __MKSMALLINT(ECHILD) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2317
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2318
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2319
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2320
#if defined(EAGAIN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2321
    if (sym == @symbol(EAGAIN)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2322
        RETURN ( __MKSMALLINT(EAGAIN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2323
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2324
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2325
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2326
#ifdef ENOMEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2327
    if (sym == @symbol(ENOMEM)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2328
        RETURN ( __MKSMALLINT(ENOMEM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2329
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2330
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2332
#ifdef EACCES
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2333
    if (sym == @symbol(EACCES)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2334
        RETURN ( __MKSMALLINT(EACCES) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2335
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2336
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2337
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2338
#ifdef EFAULT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2339
    if (sym == @symbol(EFAULT)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2340
        RETURN ( __MKSMALLINT(EFAULT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2341
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2342
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2343
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2344
#ifdef EBUSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2345
    if (sym == @symbol(EBUSY)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2346
        RETURN ( __MKSMALLINT(EBUSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2347
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2348
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2349
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2350
#ifdef EXDEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2351
    if (sym == @symbol(EXDEV)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2352
        RETURN ( __MKSMALLINT(EXDEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2353
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2354
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2355
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2356
#ifdef ENODEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2357
    if (sym == @symbol(ENODEV)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2358
        RETURN ( __MKSMALLINT(ENODEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2359
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2360
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2361
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2362
#ifdef ENOTDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2363
    if (sym == @symbol(ENOTDIR)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2364
        RETURN ( __MKSMALLINT(ENOTDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2365
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2366
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2367
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2368
#ifdef EISDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2369
    if (sym == @symbol(EISDIR)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2370
        RETURN ( __MKSMALLINT(EISDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2371
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2372
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2373
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2374
#ifdef EINVAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2375
    if (sym == @symbol(EINVAL)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2376
        RETURN ( __MKSMALLINT(EINVAL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2377
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2378
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2379
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2380
#ifdef ENFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2381
    if (sym == @symbol(ENFILE)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2382
        RETURN ( __MKSMALLINT(ENFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2383
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2384
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2386
#ifdef EMFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2387
    if (sym == @symbol(EMFILE)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2388
        RETURN ( __MKSMALLINT(EMFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2389
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2390
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2391
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2392
#ifdef ENOTTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2393
    if (sym == @symbol(ENOTTY)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2394
        RETURN ( __MKSMALLINT(ENOTTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2395
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2396
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2397
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2398
#ifdef EFBIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2399
    if (sym == @symbol(EFBIG)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2400
        RETURN ( __MKSMALLINT(EFBIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2401
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2402
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2403
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2404
#ifdef ENOSPC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2405
    if (sym == @symbol(ENOSPC)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2406
        RETURN ( __MKSMALLINT(ENOSPC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2407
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2408
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2409
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2410
#ifdef ESPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2411
    if (sym == @symbol(ESPIPE)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2412
        RETURN ( __MKSMALLINT(ESPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2413
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2414
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2415
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2416
#ifdef EROFS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2417
    if (sym == @symbol(EROFS)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2418
        RETURN ( __MKSMALLINT(EROFS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2419
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2420
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2421
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2422
#ifdef EMLINK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2423
    if (sym == @symbol(EMLINK)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2424
        RETURN ( __MKSMALLINT(EMLINK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2425
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2426
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2427
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2428
#ifdef EPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2429
    if (sym == @symbol(EPIPE)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2430
        RETURN ( __MKSMALLINT(EPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2431
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2432
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2433
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2434
#ifdef EDOM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2435
    if (sym == @symbol(EDOM)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2436
        RETURN ( __MKSMALLINT(EDOM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2437
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2438
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2439
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2440
#ifdef ERANGE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2441
    if (sym == @symbol(ERANGE)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2442
        RETURN ( __MKSMALLINT(ERANGE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2443
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2444
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2445
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2446
#ifdef EDEADLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2447
    if (sym == @symbol(EDEADLK)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2448
        RETURN ( __MKSMALLINT(EDEADLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2449
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2450
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2451
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2452
#ifdef ENAMETOOLONG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2453
    if (sym == @symbol(ENAMETOOLONG)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2454
        RETURN ( __MKSMALLINT(ENAMETOOLONG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2455
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2456
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2457
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2458
#ifdef ENOLCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2459
    if (sym == @symbol(ENOLCK)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2460
        RETURN ( __MKSMALLINT(ENOLCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2461
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2462
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2463
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2464
#ifdef ENOSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2465
    if (sym == @symbol(ENOSYS)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2466
        RETURN ( __MKSMALLINT(ENOSYS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2467
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2468
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2469
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2470
#ifdef ENOTEMPTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2471
    if (sym == @symbol(ENOTEMPTY)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2472
        RETURN ( __MKSMALLINT(ENOTEMPTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2473
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2474
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2475
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2476
#ifdef EEXIST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2477
    if (sym == @symbol(EEXIST)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2478
        RETURN ( __MKSMALLINT(EEXIST) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2479
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2480
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2481
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2482
#ifdef EILSEQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2483
    if (sym == @symbol(EILSEQ)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2484
        RETURN ( __MKSMALLINT(EILSEQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2485
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2486
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2487
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2488
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2489
     * XPG3 errnos - defined on most systems
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2490
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2491
#ifdef ENOTBLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2492
    if (sym == @symbol(ENOTBLK)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2493
        RETURN ( __MKSMALLINT(ENOTBLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2494
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2495
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2497
#ifdef ETXTBSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2498
    if (sym == @symbol(ETXTBSY)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2499
        RETURN ( __MKSMALLINT(ETXTBSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2500
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2501
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2502
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2503
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2504
     * some others
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2505
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2506
#ifdef EWOULDBLOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2507
    if (sym == @symbol(EWOULDBLOCK)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2508
        RETURN ( __MKSMALLINT(EWOULDBLOCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2509
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2510
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2511
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2512
#ifdef ENOMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2513
    if (sym == @symbol(ENOMSG)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2514
        RETURN ( __MKSMALLINT(ENOMSG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2515
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2516
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2517
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2518
#ifdef ELOOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2519
    if (sym == @symbol(ELOOP)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2520
        RETURN ( __MKSMALLINT(ELOOP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2521
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2522
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2523
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2524
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2525
     * some stream errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2526
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2527
#ifdef ETIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2528
    if (sym == @symbol(ETIME)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2529
        RETURN ( __MKSMALLINT(ETIME) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2530
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2531
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2532
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2533
#ifdef ENOSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2534
    if (sym == @symbol(ENOSR)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2535
        RETURN ( __MKSMALLINT(ENOSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2536
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2537
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2538
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2539
#ifdef ENOSTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2540
    if (sym == @symbol(ENOSTR)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2541
        RETURN ( __MKSMALLINT(ENOSTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2542
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2543
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2544
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2545
#ifdef ECOMM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2546
    if (sym == @symbol(ECOMM)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2547
        RETURN ( __MKSMALLINT(ECOMM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2548
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2549
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2550
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2551
#ifdef EPROTO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2552
    if (sym == @symbol(EPROTO)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2553
        RETURN ( __MKSMALLINT(EPROTO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2554
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2555
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2556
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2557
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2558
     * nfs errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2559
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2560
#ifdef ESTALE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2561
    if (sym == @symbol(ESTALE)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2562
        RETURN ( __MKSMALLINT(ESTALE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2563
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2564
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2565
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2566
#ifdef EREMOTE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2567
    if (sym == @symbol(EREMOTE)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2568
        RETURN ( __MKSMALLINT(EREMOTE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2569
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2570
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2571
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2572
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2573
     * some networking errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2574
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2575
#ifdef EINPROGRESS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2576
    if (sym == @symbol(EINPROGRESS)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2577
        RETURN ( __MKSMALLINT(EINPROGRESS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2578
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2579
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2580
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2581
#ifdef EALREADY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2582
    if (sym == @symbol(EALREADY)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2583
        RETURN ( __MKSMALLINT(EALREADY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2584
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2585
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2587
#ifdef ENOTSOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2588
    if (sym == @symbol(ENOTSOCK)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2589
        RETURN ( __MKSMALLINT(ENOTSOCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2590
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2591
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2592
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2593
#ifdef EDESTADDRREQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2594
    if (sym == @symbol(EDESTADDRREQ)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2595
        RETURN ( __MKSMALLINT(EDESTADDRREQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2596
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2597
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2599
#ifdef EMSGSIZE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2600
    if (sym == @symbol(EMSGSIZE)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2601
        RETURN ( __MKSMALLINT(EMSGSIZE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2602
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2603
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2604
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2605
#ifdef EPROTOTYPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2606
    if (sym == @symbol(EPROTOTYPE)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2607
        RETURN ( __MKSMALLINT(EPROTOTYPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2608
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2609
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2610
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2611
#ifdef ENOPROTOOPT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2612
    if (sym == @symbol(ENOPROTOOPT)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2613
        RETURN ( __MKSMALLINT(ENOPROTOOPT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2614
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2615
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2616
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2617
#ifdef EPROTONOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2618
    if (sym == @symbol(EPROTONOSUPPORT)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2619
        RETURN ( __MKSMALLINT(EPROTONOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2620
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2621
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2622
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2623
#ifdef ESOCKTNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2624
    if (sym == @symbol(ESOCKTNOSUPPORT)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2625
        RETURN ( __MKSMALLINT(ESOCKTNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2626
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2627
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2628
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2629
#ifdef EOPNOTSUPP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2630
    if (sym == @symbol(EOPNOTSUPP)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2631
        RETURN ( __MKSMALLINT(EOPNOTSUPP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2632
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2633
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2634
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2635
#ifdef EPFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2636
    if (sym == @symbol(EPFNOSUPPORT)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2637
        RETURN ( __MKSMALLINT(EPFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2638
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2639
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2640
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2641
#ifdef EAFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2642
    if (sym == @symbol(EAFNOSUPPORT)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2643
        RETURN ( __MKSMALLINT(EAFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2644
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2645
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2646
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2647
#ifdef EADDRINUSE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2648
    if (sym == @symbol(EADDRINUSE)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2649
        RETURN ( __MKSMALLINT(EADDRINUSE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2650
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2651
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2652
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2653
#ifdef EADDRNOTAVAIL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2654
    if (sym == @symbol(EADDRNOTAVAIL)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2655
        RETURN ( __MKSMALLINT(EADDRNOTAVAIL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2656
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2657
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2658
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2659
#ifdef ETIMEDOUT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2660
    if (sym == @symbol(ETIMEDOUT)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2661
        RETURN ( __MKSMALLINT(ETIMEDOUT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2662
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2663
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2664
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2665
#ifdef ECONNREFUSED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2666
    if (sym == @symbol(ECONNREFUSED)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2667
        RETURN ( __MKSMALLINT(ECONNREFUSED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2668
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2669
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2670
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2671
#ifdef ENETDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2672
    if (sym == @symbol(ENETDOWN)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2673
        RETURN ( __MKSMALLINT(ENETDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2674
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2675
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2676
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2677
#ifdef ENETUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2678
    if (sym == @symbol(ENETUNREACH)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2679
        RETURN ( __MKSMALLINT(ENETUNREACH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2680
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2681
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2682
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2683
#ifdef ENETRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2684
    if (sym == @symbol(ENETRESET)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2685
        RETURN ( __MKSMALLINT(ENETRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2686
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2687
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2688
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2689
#ifdef ECONNABORTED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2690
    if (sym == @symbol(ECONNABORTED)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2691
        RETURN ( __MKSMALLINT(ECONNABORTED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2692
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2693
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2694
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2695
#ifdef ECONNRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2696
    if (sym == @symbol(ECONNRESET)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2697
        RETURN ( __MKSMALLINT(ECONNRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2698
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2699
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2700
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2701
#ifdef EISCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2702
    if (sym == @symbol(EISCONN)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2703
        RETURN ( __MKSMALLINT(EISCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2704
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2705
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2706
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2707
#ifdef ENOTCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2708
    if (sym == @symbol(ENOTCONN)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2709
        RETURN ( __MKSMALLINT(ENOTCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2710
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2711
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2712
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2713
#ifdef ESHUTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2714
    if (sym == @symbol(ESHUTDOWN)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2715
        RETURN ( __MKSMALLINT(ESHUTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2716
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2717
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2718
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2719
#ifdef EHOSTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2720
    if (sym == @symbol(EHOSTDOWN)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2721
        RETURN ( __MKSMALLINT(EHOSTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2722
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2723
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2725
#ifdef EHOSTUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2726
    if (sym == @symbol(EHOSTUNREACH)) {
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2727
        RETURN ( __MKSMALLINT(EHOSTUNREACH) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2728
    }
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2729
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2730
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2731
    ^ -1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2732
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2733
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2734
!UnixOperatingSystem class methodsFor:'executing OS commands'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2735
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2736
commandAndArgsForOSCommand:aCommandString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2737
    "get a shell and shell arguments for command execution"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2738
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2739
    |shell args|
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2740
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2741
    "/
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2742
    "/ '/bin/sh -c <command>'
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2743
    "/
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2744
    shell := '/bin/sh'.
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2745
    args := Array with:'sh' with:'-c' with:aCommandString.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2746
    ^ Array with:shell with:args
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2747
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2748
    "Modified: / 20.1.1998 / 16:57:19 / md"
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  2749
    "Modified: / 5.6.1998 / 17:40:48 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2750
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2751
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2752
exec:aCommandPath withArguments:argColl environment:env fileDescriptors:fdColl closeDescriptors:closeFdColl fork:doFork newPgrp:newPgrp inDirectory:aDirectory
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2753
    "Internal lowLevel entry for combined fork & exec;
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2754
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2755
     If fork is false (chain a command):
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2756
	 execute the OS command specified by the argument, aCommandPath, with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2757
	 arguments in argArray (no arguments, if nil).
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2758
	 If successful, this method does not return and smalltalk is gone.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2759
	 If not successful, it does return.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2760
	 Normal use is with forkForCommand.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2761
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2762
     If fork is true (subprocess command execution):
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2763
	fork a child to do the above.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2764
	The process id of the child process is returned; nil if the fork failed.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2765
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2766
     fdArray contains the filedescriptors, to be used for the child (if fork is true).
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2767
	fdArray[1] = 15 -> use fd 15 as stdin.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2768
	If an element of the array is set to nil, the corresponding filedescriptor
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2769
	will be closed for the child.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2770
	fdArray[0] == StdIn for child
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2771
	fdArray[1] == StdOut for child
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2772
	fdArray[2] == StdErr for child
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2773
	on VMS, these must be channels as returned by createMailBox.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2774
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2775
     closeFdArray contains descriptors that will be closed in the subprocess.
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2776
	closeDescriptors are ignored in the WIN32 & VMS versions.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2777
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2778
     If newPgrp is true, the subprocess will be established in a new process group.
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2779
	The processgroup will be equal to id.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2780
	newPgrp is not used on WIN32 and VMS systems.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2781
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2782
     env specifies environment variables which are passed differently from
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2783
     the current environment. If non-nil, it must be a dictionary providing
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2784
     key-value pairs for changed/added environment variables.
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2785
     To pass a variable as empty (i.e. unset), pass a nil value.
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2786
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2787
     Notice: this used to be two separate ST-methods; however, in order to use
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2788
	    vfork on some machines, it had to be merged into one, to avoid write
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2789
	    accesses to ST/X memory from the vforked-child.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2790
	    The code below only does read accesses."
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2791
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2792
    |envPairs argArray fdArray closeFdArray dirName|
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2793
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2794
    env notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2795
	envPairs := OrderedCollection new.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2796
	env keysAndValuesDo:[:key :val |
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2797
	    envPairs add:key; add:val
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2798
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2799
	envPairs := envPairs asArray.
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2800
    ].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2801
    argColl notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2802
	argArray := argColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2803
    ].
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2804
    fdColl notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2805
	fdArray := fdColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2806
    ].
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2807
    closeFdColl notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2808
	closeFdArray := closeFdColl asArray
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2809
    ].
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2810
    aDirectory notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2811
	dirName := aDirectory asFilename name
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2812
    ].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2813
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2814
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2815
    char **argv;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2816
    int nargs, i, id;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2817
    OBJ arg;
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  2818
    extern char **environ;
3571
9090dc66a427 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
  2819
    char **_env, **_nEnv;
3801
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  2820
#ifndef __isArrayLike
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  2821
# define __isArrayLike __isArray
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  2822
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2823
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2824
    if (__isString(aCommandPath) && 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2825
	((argArray == nil) || __isArrayLike(argArray)) &&
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2826
	((fdArray == nil) || __isArrayLike(fdArray)) &&
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2827
	((closeFdArray == nil) || __isArrayLike(closeFdArray))
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2828
    ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2829
	nargs = argArray == nil ? 0 : __arraySize(argArray);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2830
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2831
	if (argv) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2832
	    int nOldEnv, nNewEnv;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2833
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2834
	    for (i=0; i < nargs; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2835
		arg = __ArrayInstPtr(argArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2836
		if (__isString(arg)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2837
		    argv[i] = (char *) __stringVal(arg);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2838
		} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2839
		    argv[i] = "";
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2840
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2841
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2842
	    argv[i] = NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2843
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2844
	    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2845
	     * number of new items in environment ..       
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2846
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2847
	    nNewEnv = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2848
	    if ((envPairs != nil) && __isArrayLike(envPairs)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2849
		nNewEnv = __arraySize(envPairs) / 2;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2850
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2851
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2852
	    if (nNewEnv == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2853
		_nEnv = environ;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2854
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2855
		_env = environ;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2856
		/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2857
		 * get size of environment
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2858
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2859
		nOldEnv = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2860
		if (_env) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2861
		    while (*_env) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2862
			nOldEnv++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2863
			_env++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2864
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2865
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2866
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2867
		/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2868
		 * generate a new environment
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2869
		 * I have not found a spec which defines if
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2870
		 * items at the end overwrite previous definitions,
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2871
		 * or if the first encountered definition is valid.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2872
		 * To be prepared for any case, simply add the new definitions
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2873
		 * at both ends - that should do it in any case.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2874
		 * Someone with more know-how may want to fix this.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2875
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2876
		_nEnv = (char **)malloc(sizeof(char *) * (nNewEnv + nOldEnv + nNewEnv + 1));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2877
		if (_nEnv) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2878
		    char **eO, **eN;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2879
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2880
		    eN = _nEnv;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2881
		    if (nNewEnv) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2882
			/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2883
			 * add new items at the front ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2884
			 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2885
			int i;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2886
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2887
			for (i=0; (i+1)<__arraySize(envPairs); i+=2) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2888
			    OBJ t;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2889
			    char *var, *val, *e;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2890
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2891
			    t = __ArrayInstPtr(envPairs)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2892
			    if (__isString(t) || __isSymbol(t)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2893
				var = (char *)__stringVal(t);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2894
				t = __ArrayInstPtr(envPairs)->a_element[i+1];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2895
				if (__isString(t) || __isSymbol(t)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2896
				    val = (char *)__stringVal(t);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2897
				} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2898
				    val = NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2899
				}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2900
				if (val != NULL) {                
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2901
				    e = (char *)malloc(strlen(var) + 1 + strlen(val) + 1);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2902
				    strcpy(e, var);               
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2903
				    strcat(e, "=");               
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2904
				    strcat(e, val);               
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2905
				} else {                          
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2906
				    e = (char *)malloc(strlen(var) + 1 + 1);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2907
				    strcpy(e, var);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2908
				    strcat(e, "=");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2909
				}   
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2910
				*eN++ = e;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2911
			    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2912
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2913
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2914
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2915
		    if (nOldEnv) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2916
			/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2917
			 * append old environment 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2918
			 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2919
			eO = environ;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2920
			while (*eN = *eO++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2921
			    eN++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2922
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2923
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2924
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2925
		    if (nNewEnv) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2926
			/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2927
			 * new items again at the end
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2928
			 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2929
			for (eO = _nEnv, i=0; i<nNewEnv; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2930
			    *eN++ = *eO++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2931
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2932
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2933
			*eN = NULL;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2934
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2935
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2936
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2937
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2938
	    if (doFork == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2939
		/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2940
		 * fork a subprocess.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2941
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2942
		int nfd, nclose;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2943
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2944
		nfd = fdArray == nil ? 0 : __arraySize(fdArray);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2945
		nclose = closeFdArray == nil ? 0 : __arraySize(closeFdArray);
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2946
#ifdef HAS_VFORK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2947
		id = vfork();
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2948
#else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2949
		id = fork();
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2950
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2951
		if (id == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2952
		    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2953
		    ** In child.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2954
		    ** first: dup filedescriptors
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2955
		    */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2956
		    for (i = 0; i < nfd; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2957
			OBJ fd;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2958
			int rslt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2959
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2960
			fd = __ArrayInstPtr(fdArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2961
			if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2962
			    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2963
				rslt = dup2(__intVal(fd), i);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2964
			    } while ((rslt < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2965
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2966
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2967
		    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2968
		    ** second: close unused filedescriptors
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2969
		    */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2970
		    for (i = 0; i < nfd; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2971
			if (__ArrayInstPtr(fdArray)->a_element[i] == nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2972
			    close(i);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2973
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2974
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2975
		    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2976
		    ** third: close filedescriptors
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2977
		    */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2978
		    for (i = 0; i < nclose; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2979
			OBJ fd;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2980
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2981
			fd = __ArrayInstPtr(closeFdArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2982
			if (__isSmallInteger(fd)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2983
			    close(__intVal(fd));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2984
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2985
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2986
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2987
		    if (newPgrp == true) {
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  2988
#ifndef NEXT
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2989
			setsid();
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  2990
#endif
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  2991
#if defined(TIOCSCTTY)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2992
			ioctl(0, TIOCSCTTY, 0) ;
3561
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  2993
#endif
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  2994
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  2995
#if defined(TIOCSPGRP)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2996
			{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2997
			    int pgrp = getpid();
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2998
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  2999
			    ioctl(0, TIOCSPGRP, (char *)&pgrp);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3000
			}
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3001
#endif
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3002
#if defined(_POSIX_JOB_CONTROL)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3003
			(void) setpgid(0, 0);
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3004
#else
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3005
# if defined(BSD) || defined(LINUX)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3006
			(void) setpgrp(0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3007
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3008
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3009
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3010
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3011
		    if (dirName != nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3012
			chdir(__stringVal(dirName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3013
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3014
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3015
		    execve(__stringVal(aCommandPath), argv, _nEnv);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3016
		    /* should not be reached */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3017
		    _exit(127);                 /* POSIX 2 compatible exit value */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3018
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3019
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3020
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3021
		if (dirName != nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3022
		    chdir(__stringVal(dirName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3023
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3024
		/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3025
		 * no subprocess (i.e. transfer to another program)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3026
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3027
		execve(__stringVal(aCommandPath), argv, _nEnv);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3028
		/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3029
		 * should not be reached
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3030
		 * (well, it is, if you pass a wrong command-path)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3031
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3032
		id = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3033
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3034
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3035
	    if (nNewEnv && (_nEnv != NULL)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3036
		/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3037
		 * free new environment stuff
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3038
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3039
		for (i=0; i<nNewEnv;i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3040
		    char *e = _nEnv[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3041
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3042
		    if (e) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3043
			free(e);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3044
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3045
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3046
		free(_nEnv);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3047
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3048
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3049
	    free(argv);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3051
	    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3052
	     * In parent: succes or failure
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3053
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3054
	    if (id == -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3055
		RETURN (nil);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3056
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3057
		RETURN (__MKSMALLINT(id));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3058
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3059
	}
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3060
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3061
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3062
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3063
     path-argument not string
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3064
     or argArray not an array/nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3065
     or malloc failed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3066
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3067
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3068
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3069
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3070
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3071
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3072
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3073
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3074
     id == 0 ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3075
	'I am the child'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3076
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3077
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3078
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3079
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3080
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3081
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3082
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3083
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3084
     id == 0 ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3085
	'I am the child'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3086
	OperatingSystem
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3087
	   exec:'/bin/sh'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3088
	   withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3089
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3090
     ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3091
     id printNL.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3092
     (Delay forSeconds:3.5) wait.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3093
     'killing ...' printNL.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3094
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3095
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3096
    "
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3097
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3098
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3099
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3100
executeCommand:aCommandString inDirectory:aDirectory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3101
    "much like #executeCommand:, but changes the current directory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3102
     for the command. Since this is OS specific, use this instead of
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3103
     hardwiring any 'cd ..' command strings into your applictions."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3104
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3105
     ^ self
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3106
	executeCommand:aCommandString 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3107
	inputFrom:nil 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3108
	outputTo:nil 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3109
	errorTo:nil 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3110
	inDirectory:aDirectory asFilename name
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3111
	onError:[:status| false].
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3112
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3113
"/    | cmd |
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3114
"/
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3115
"/    "/ unix - prepend a 'cd' to the command
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3116
"/
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3117
"/    cmd := 'cd ' , aDirectory asFilename name, '; ' , aCommandString.
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  3118
"/    ^ self executeCommand:cmd
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3119
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3120
    "Modified: / 20.1.1998 / 17:03:03 / md"
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3121
    "Modified: / 5.6.1998 / 19:01:29 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3122
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3123
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3124
fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3125
    "fork a new (HEAVY-weight) unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3126
     Not supported with MSDOS & VMS systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3127
     Dont confuse this with Block>>fork, which creates 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3128
     lightweight smalltalk processes. This method will return
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3129
     0 to the child process, and a non-zero number (which is the childs
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3130
     unix-process-id) to the parent (original) process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3131
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3132
     In normal situations, you dont need to use this low level entry; see
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3133
     #startProcess: and #executCommand: for higher level interfaces."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3134
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3135
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3136
    int pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3137
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3138
    pid = fork();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3139
    RETURN ( __MKUINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3140
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3141
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3142
    "/ not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3144
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3145
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3146
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3147
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3148
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3150
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3151
     id == 0 ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3152
	'I am the child process' printCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3153
	OperatingSystem exit
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3155
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3156
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3157
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3158
getStatusOfProcess:aProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3159
    "wait for a process to terminate and fetch its exit status.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3160
     This is required to avoid zombie processes."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3161
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3162
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3163
    int status;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3164
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3165
    if (__isSmallInteger(aProcessId)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3166
	pid_t pid = (pid_t)(__intVal(aProcessId));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3167
	{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3168
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3169
# ifdef  NO_WAITPID
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3170
	    pid_t child;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3171
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3172
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3173
		__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3174
		child = __wait (&status);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3175
		__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3176
		if (child < 0 && errno != EINTR) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3177
		    fprintf(stderr, "OS: child-wait errno=%d\n", errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3178
		    status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3179
		    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3180
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3181
	    } while (child != pid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3182
# else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3183
	    pid_t child;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3184
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3185
	    /* claus: the original did not care for EINTR here ... */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3186
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3187
		__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3188
		child = __waitpid (pid, &status, 0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3189
		__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3190
	    } while ((child != pid) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3191
	    if (child != pid) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3192
		fprintf(stderr, "OS: child-waitpid errno=%d\n", errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3193
		status = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3194
	    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3195
# endif /* NO_WAITPID */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3196
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3197
	RETURN ( __MKSMALLINT(status));
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3198
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3199
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3200
    self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3201
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3202
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3203
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3204
pathOfCommand:aCommand
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3205
    "find where aCommand's executable file is;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3206
     return its full pathName if there is such a command, otherwise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3207
     return nil."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3208
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3209
    |path f fExt|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3210
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3211
    aCommand asFilename isAbsolute ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3212
	^ aCommand
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3213
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3214
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3215
    path := self getEnvironment:'PATH'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3216
    path notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3217
	(path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path |
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3218
	    path isEmpty ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3219
		f := aCommand asFilename
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3220
	    ] ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3221
		f := path asFilename construct:aCommand.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3222
	    ].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3223
	    self executableFileExtensions do:[:ext |
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3224
		ext notEmpty ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3225
		    fExt := (f pathName , ext) asFilename.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3226
		] ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3227
		    fExt := f.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3228
		].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3229
		fExt isExecutable ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3230
		    ^ fExt pathName
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3231
		].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3232
	    ].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3233
	].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3234
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3235
    ^ nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3236
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3237
    "unix:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3238
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3239
     OperatingSystem pathOfCommand:'fooBar'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3240
     OperatingSystem pathOfCommand:'ls'    
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3241
     OperatingSystem pathOfCommand:'cvs'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3242
     OperatingSystem pathOfCommand:'stx'   
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3243
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3244
    "windows:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3245
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3246
     OperatingSystem pathOfCommand:'windbg'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3247
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3248
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3249
    "Modified: / 5.6.1998 / 19:03:32 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3250
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3251
3928
c299502a62b9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  3252
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream errorTo:anExternalErrStream inDirectory:dir
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3253
    "start executing the OS command as specified by the argument, aCommandString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3254
     as a separate process; do not wait for the command to finish.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3255
     The commandString is passed to a shell for execution - see the description of
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3256
     'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3257
     The command gets stdIn, stdOut and stdErr assigned from the arguments;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3258
     each may be nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3259
     Return the processId if successful, nil otherwise.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3260
     Use #monitorPid:action: for synchronization and exec status return,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3261
     or #killProcess: to stop it."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3262
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3263
    |in out err shellAndArgs rslt|
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3264
4753
214fc4e89e7a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4436
diff changeset
  3265
    aCommandString isNil ifTrue:[^ nil].
214fc4e89e7a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4436
diff changeset
  3266
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3267
    (in := anExternalInStream) isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3268
	in := '/dev/null' asFilename readStream
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3269
    ].
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3270
    (out := anExternalOutStream) isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3271
	out := '/dev/null' asFilename writeStream
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3272
    ].
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3273
    (err := anExternalErrStream) isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3274
	anExternalOutStream isNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3275
	    err := out
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3276
	] ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3277
	    err := '/dev/null' asFilename writeStream
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3278
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3279
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3280
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3281
    shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
4753
214fc4e89e7a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4436
diff changeset
  3282
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3283
    rslt := self
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3284
	exec:(shellAndArgs at:1)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3285
	withArguments:(shellAndArgs at:2)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3286
	fileDescriptors:(Array with:in fileDescriptor
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3287
			       with:out fileDescriptor
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3288
			       with:err fileDescriptor)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3289
	closeDescriptors:nil
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3290
	fork:true
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3291
	newPgrp:true "/ false
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3292
	inDirectory:dir.
4436
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3293
318297e533a6 use /dev/null as default out/err in startProcess.
Claus Gittinger <cg@exept.de>
parents: 4395
diff changeset
  3294
    ^ rslt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3295
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3296
    "blocking at current prio (i.e. only higher prio threads execute):
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3297
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3298
     OperatingSystem executeCommand:'ls -l > out'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3299
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3300
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3301
    "non-blocking (lower prio threads continue):
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3302
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3303
     |in out err pid sema|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3304
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3305
     in := 'out' asFilename readStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3306
     out := 'out2' asFilename writeStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3307
     err := 'err' asFilename writeStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3308
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3309
     sema := Semaphore new.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3310
     pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3311
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3312
     The following will no longer work. monitorPid has disappeared 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3313
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3314
     pid notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3315
	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3316
     ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3317
     in close.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3318
     out close.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3319
     err close.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3320
     sema wait.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3321
     Transcript showCR:'finished'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3322
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3323
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3324
    "Modified: / 21.3.1997 / 10:04:35 / dq"
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3325
    "Modified: / 15.7.1997 / 16:03:51 / stefan"
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3326
    "Modified: / 5.6.1998 / 19:03:51 / cg"
3928
c299502a62b9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3801
diff changeset
  3327
    "Created: / 12.11.1998 / 14:39:20 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3328
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3329
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3330
!UnixOperatingSystem class methodsFor:'file access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3332
closeFd:anInteger
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3333
    "low level close of a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3334
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3335
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3336
     if (__isSmallInteger(anInteger)) {
5203
a1a9869b2d24 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5157
diff changeset
  3337
	if (@global(ExternalStream:FileOpenTrace) == true) {
a1a9869b2d24 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5157
diff changeset
  3338
	    fprintf(stderr, "close [UnixOp] fd=%d\n", __intVal(anInteger));
a1a9869b2d24 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5157
diff changeset
  3339
	}
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3340
	close(__intVal(anInteger));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3341
	RETURN(self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3342
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3343
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3344
     ^ self primitiveFailed.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3345
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3346
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3347
createDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3348
    "create a new directory with name 'aPathName', which may be an absolute
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3349
     path, or relative to the current directory.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3350
     Return true if successful (or the directory existed already), false if failed.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3351
     This is a low-level entry - use Filename protocol for compatibility."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3352
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3353
    "/ if it already exists this is ok
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3354
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3355
    (self isDirectory:aPathName) ifTrue:[^ true].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3356
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3357
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3358
    if (__isString(aPathName)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3359
	int ret;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3360
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3361
	ret = mkdir(__stringVal(aPathName), 0755);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3362
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3363
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3364
	    RETURN (false);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3365
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3366
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3367
      }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3368
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3369
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3370
"/    self isUNIXlike ifTrue:[
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3371
"/      ^ self executeCommand:('mkdir 2>/dev/null ', newPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3372
"/    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3373
"/    ^ self executeCommand:('mkdir ', newPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3374
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3375
    self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3376
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3377
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3378
     OperatingSystem createDirectory:'foo'  
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3379
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3380
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3381
    "Modified: 20.12.1995 / 11:24:13 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3382
    "Modified: 29.6.1996 / 14:06:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3383
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3384
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3385
createFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3386
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3387
    ^ self open:pathName attributes:#(O_RDWR O_APPEND O_CREAT) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3388
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3389
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3390
createFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3391
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3392
    ^ self open:pathName attributes:#(O_RDWR O_CREAT O_TRUNC) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3393
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3394
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3395
createHardLinkFrom:oldPath to:newPath
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3396
    "link the file 'oldPath' to 'newPath'. The link will be a hard link.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3397
     Return true if successful, false if not."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3398
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3399
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3400
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3401
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3402
    if (__isString(oldPath) && __isString(newPath)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3403
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3404
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3405
	    ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3406
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3407
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3408
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3409
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3410
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3411
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3412
	RETURN (true);
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3413
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3414
%}.
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3415
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3416
    "/ bad argument(s) given
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3417
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3418
    ^ self primitiveFailed 
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3419
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3420
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3421
     OperatingSystem linkFile:'foo' to:'bar'
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3422
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3423
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3424
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3425
createSymbolicLinkFrom:oldPath to:newPath
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3426
    "make a symbolic link for 'newPath' to the file 'oldPath'.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3427
     The link will be a soft (symbolic) link.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3428
     Return true if successful, false if not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3429
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3430
%{
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3431
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3432
    int ret;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3433
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3434
    if (__isString(oldPath) && __isString(newPath)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3435
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3436
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3437
	    ret = symlink((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3438
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3439
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3440
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3441
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3442
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3443
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3444
	RETURN (true);
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3445
    }
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3446
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3447
%}.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3448
    (oldPath isString not or:[newPath isString not]) ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3449
	"/
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3450
	"/ bad argument(s) given
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3451
	"/
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3452
	^ self primitiveFailed 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3453
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3454
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3455
    "/
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3456
    "/ this Unix does not seem to support symbolic links
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3457
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3458
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3459
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3460
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3461
     OperatingSystem symbolicLinkFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3462
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3463
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3464
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3465
open:path attributes:attributes mode:modeInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3466
    "open a file, return an os specific fileHandle. 
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3467
     openmode is a symbol defining the way to open
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3468
     valid modes are:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3469
        #O_RDONLY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3470
        #O_RDWR
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3471
        #O_WRONLY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3472
        #O_CREAT
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3473
        #O_APPEND
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3474
        #O_SYNC
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3475
        #O_LARGEFILE
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3476
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3477
     This is a private entry, but maybe useful to open/create a file in a special mode,
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3478
     which is proprietrary to the operatingSystem."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3479
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3480
    |error fileDescriptor|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3481
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3482
%{
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3483
    OBJ *ap;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3484
    int nAttributes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3485
    int fd;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3486
    int mode, openFlags = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3487
    int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3488
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3489
    if (!__isString(path)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3490
        error = @symbol(badArgument1);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3491
        goto err;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3492
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3493
    if (!__isArray(attributes)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3494
        error = @symbol(badArgument2);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3495
        goto err;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3496
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3497
    if (modeInteger == nil) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3498
        mode = 0644;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3499
    } else if (__isSmallInteger(modeInteger)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3500
        mode = __intVal(modeInteger);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3501
    } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3502
        error = @symbol(badArgument3);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3503
        goto err;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3504
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3505
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3506
    nAttributes = __arraySize(attributes);
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3507
    for (n = 0, ap = __ArrayInstPtr(attributes)->a_element; 
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3508
         n < nAttributes; 
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3509
         n++) {
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3510
        OBJ attribute = ap[n];
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3511
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3512
        if (attribute == @symbol(O_RDONLY)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3513
            openFlags |= O_RDONLY;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3514
        } else if (attribute == @symbol(O_RDWR)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3515
            openFlags |= O_RDWR;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3516
        } else if (attribute == @symbol(O_WRONLY)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3517
            openFlags |= O_WRONLY;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3518
        } else if (attribute == @symbol(O_CREAT)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3519
            openFlags |= O_CREAT;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3520
        } else if (attribute == @symbol(O_APPEND)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3521
            openFlags |= O_APPEND;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3522
        } else if (attribute == @symbol(O_EXCL)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3523
            openFlags |= O_EXCL;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3524
        } else if (attribute == @symbol(O_TRUNC)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3525
            openFlags |= O_TRUNC;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3526
        } else if (attribute == @symbol(O_LARGEFILE)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3527
#ifdef O_LARGEFILE
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3528
            openFlags |= O_LARGEFILE;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3529
#else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3530
            error = @symbol(badArgument2);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3531
            goto err;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3532
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3533
        } else if (attribute == @symbol(O_SYNC)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3534
#ifdef O_SYNC
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3535
            openFlags |= O_SYNC;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3536
#else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3537
            error = @symbol(badArgument2);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3538
            goto err;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3539
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3540
        }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3541
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3542
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3543
#if defined(O_NONBLOCK)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3544
    openFlags |= O_NONBLOCK;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3545
#else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3546
# if defined(O_NDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3547
    openFlags |= O_NDELAY;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3548
# endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3549
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3550
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3551
again:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3552
    fd = open((char *) __stringVal(path), openFlags, mode);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3553
    if (fd < 0) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3554
        if (errno == EINTR) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3555
            __HANDLE_INTERRUPTS__;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3556
            goto again;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3557
        } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3558
            error = __MKSMALLINT(errno);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3559
            goto err;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3560
        }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3561
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3562
    fileDescriptor = __MKSMALLINT(fd);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3563
err:;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3564
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3565
    ^ fileDescriptor notNil ifTrue:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3566
        FileDescriptorHandle for:fileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3567
    ] ifFalse:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3568
        (self errorHolderForNumber:error) reportError
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3569
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3570
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3571
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3572
        self open:'/etc/hosts' attributes:#(O_RDONLY) mode:nil
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3573
        self open:'/tmp/xxzz' attributes:#(O_RDWR O_CREAT) mode:8r611
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3574
        self open:'/etc/passwd' attributes:#(O_RDWR) mode:nil
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3575
        self open:'/no one knows this file' attributes:#(O_RDONLY) mode:nil
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3576
        self open:'foo/bar/baz' attributes:#(O_RDWR O_CREAT) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3577
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3578
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3579
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3580
openFileForAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3581
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3582
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3583
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3584
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3585
openFileForRead:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3586
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3587
    ^ self open:pathName attributes:#(O_RDONLY) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3588
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3589
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3590
openFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3591
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3592
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3593
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3594
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3595
openFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3596
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3597
    ^ self open:pathName attributes:#(O_RDWR)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3598
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3599
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3600
openFileForWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3601
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3602
    ^ self open:pathName attributes:#(O_WRONLY)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3603
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3604
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3605
recursiveCopyDirectory:sourcePathName to:destination
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3606
    "copy the directory named 'sourcePathName' and all contained files/directories to 'destination'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3607
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3608
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3609
    ^ self executeCommand:('cp -rf ' , sourcePathName, ' ', destination)
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3610
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3611
    "Modified: / 5.6.1998 / 18:33:57 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3612
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3613
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3614
recursiveRemoveDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3615
    "remove the directory named 'fullPathName' and all contained files/directories.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3616
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3617
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3618
    ^ self executeCommand:('rm -rf ' , fullPathName)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3619
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3620
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3621
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3622
     OperatingSystem recursiveRemoveDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3623
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3624
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3625
    "Modified: / 5.6.1998 / 18:34:03 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3626
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3627
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3628
removeDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3629
    "remove the directory named 'fullPathName'. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3630
     The directory must be empty and you must have appropriate access rights.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3631
     Return true if successful, false if directory is not empty or no permission.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3632
     This is a lowLevel entry - use Filename protocol for compatibility."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3633
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3634
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3635
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3636
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3637
    if (__isString(fullPathName)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3638
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3639
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3640
	    ret = rmdir((char *) __stringVal(fullPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3641
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3642
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3643
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3644
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3645
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3646
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3647
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3648
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3649
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3650
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3651
    "/ either not a string argument,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3652
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3653
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3654
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3655
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3656
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3657
     OperatingSystem createDirectory:'foo'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3658
     OperatingSystem removeDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3659
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3660
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3661
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3662
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3663
removeFile:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3664
    "remove the file named 'fullPathName'; return true if successful.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3665
     This is a lowLevel entry - use Filename protocol for compatibility."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3666
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3667
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3668
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3669
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3670
    if (__isString(fullPathName)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3671
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3672
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3673
	    ret = unlink((char *) __stringVal(fullPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3674
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3675
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3676
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3677
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3678
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3679
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3680
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3681
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3682
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3683
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3684
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3685
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3686
renameFile:oldPath to:newPath
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3687
    "rename the file 'oldPath' to 'newPath'. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3688
     Someone else has to care for the names to be correct and 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3689
     correct for the OS used - therefore, this should not be called
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3690
     directlt. Instead, use Filename protocol to rename; this cares for
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3691
     any invalid names.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3692
     Returns true if successful, false if not"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3693
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3694
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3695
    int ret, eno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3696
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3697
    if (__isString(oldPath) && __isString(newPath)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3698
#if defined(HAS_RENAME)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3699
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3700
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3701
	    ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3702
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3703
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3704
#else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3705
	ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3706
	if (ret >= 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3707
	    ret = unlink((char *) __stringVal(oldPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3708
	    if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3709
		eno = errno;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3710
		unlink((char *) __stringVal(newPath));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3711
		errno = eno;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3712
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3713
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3714
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3715
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3716
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3717
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3718
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3719
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3720
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3721
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3722
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3723
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3724
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3725
     OperatingSystem renameFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3726
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3727
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3728
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3729
truncateFile:aPathName to:newSize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3730
    "change a files size return true on success, false on failure.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3731
     This may not be supported on all architectures.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3732
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3733
     This is a low-level entry - use Filename protocol."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3734
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3735
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3736
#ifdef HAS_TRUNCATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3737
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3738
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3739
    if (__isString(aPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3740
     && __isSmallInteger(newSize)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3741
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3742
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3743
	    ret = truncate((char *) __stringVal(aPathName), __intVal(newSize));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3744
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3745
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3746
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3747
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3748
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3749
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3750
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3751
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3752
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3753
# ifdef HAS_FTRUNCATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3754
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3755
    int fd;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3756
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3757
    if (__isString(aPathName)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3758
     && __isSmallInteger(newSize)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3759
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3760
	    fd = open((char *) __stringVal(aPathName), 2);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3761
	} while (fd < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3762
	if (fd < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3763
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3764
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3765
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3766
        
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3767
	ret = ftruncate(fd, __intVal(newSize));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3768
	close(fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3769
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3770
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3771
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3772
	} 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3773
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3774
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3775
# endif /* using FTRUNCATE */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3776
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3777
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3778
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3779
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3780
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3781
!UnixOperatingSystem class methodsFor:'file access rights'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3782
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3783
accessMaskFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3784
    "return the access bits mask for numbers as returned by 
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3785
     OperatingSystem>>accessModeOf:
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3786
     and expected by OperatingSystem>>changeAccessModeOf:to:.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3787
     Since these numbers are OS dependent, always use the mask
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3788
     (never hardcode 8rxxx into your code)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3789
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3790
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3791
#   ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3792
    /* posix systems should define these ... */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3793
#    define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3794
#    define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3795
#    define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3796
#    define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3797
#    define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3798
#    define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3799
#    define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3800
#    define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3801
#    define S_IXOTH 0001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3802
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3803
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3804
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3805
    if (aSymbol == @symbol(readUser)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3806
	RETURN ( __MKSMALLINT(S_IRUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3807
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3808
    if (aSymbol == @symbol(writeUser)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3809
	RETURN ( __MKSMALLINT(S_IWUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3810
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3811
    if (aSymbol == @symbol(executeUser)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3812
	RETURN ( __MKSMALLINT(S_IXUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3813
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3814
    if (aSymbol == @symbol(readGroup)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3815
	RETURN ( __MKSMALLINT(S_IRGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3816
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3817
    if (aSymbol == @symbol(writeGroup)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3818
	RETURN ( __MKSMALLINT(S_IWGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3819
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3820
    if (aSymbol == @symbol(executeGroup)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3821
	RETURN ( __MKSMALLINT(S_IXGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3822
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3823
    if (aSymbol == @symbol(readOthers)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3824
	RETURN ( __MKSMALLINT(S_IROTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3825
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3826
    if (aSymbol == @symbol(writeOthers)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3827
	RETURN ( __MKSMALLINT(S_IWOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3828
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3829
    if (aSymbol == @symbol(executeOthers)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3830
	RETURN ( __MKSMALLINT(S_IXOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3831
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3832
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3833
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3834
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3835
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3836
     OperatingSystem accessMaskFor:#readUser
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3837
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3838
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3839
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3840
accessModeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3841
    "return a number representing access rights rwxrwxrwx for owner,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3842
     group and others. Return nil if such a file does not exist.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3843
     Notice that the returned number is OS dependent - use the 
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3844
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3845
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3846
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3847
     this could have been implemented as:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3848
	(self infoOf:aPathName) at:#mode
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3849
     but for huge directory searches the code below is faster
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3850
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3851
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3852
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3853
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3854
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3855
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3856
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3857
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3858
	printf("stat on '%s' for accessMode\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3859
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3860
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3861
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3862
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3863
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3864
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3865
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3866
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3867
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3868
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3869
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3870
	RETURN ( __MKSMALLINT(buf.st_mode & 0777) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3871
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3872
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3873
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3874
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3875
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3876
    (OperatingSystem accessModeOf:'/') printStringRadix:8
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3877
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3878
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3879
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3880
changeAccessModeOf:aPathName to:modeBits
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3881
    "change the access rights of aPathName to the OS dependent modeBits.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3882
     You should construct this mask using accessMaskFor, to be OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3883
     independent. Return true if changed, 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3884
     false if such a file does not exist or change was not allowd."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3885
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3886
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3887
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3888
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3889
    if (__isString(aPathName) && __isSmallInteger(modeBits)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3890
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3891
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3892
	    ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3893
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3894
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3895
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3896
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3897
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3898
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3899
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3900
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3901
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3902
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3903
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3904
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3905
!UnixOperatingSystem class methodsFor:'file locking'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3906
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3907
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3908
   "set a lock on the file represented by aFileDescriptor.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3909
    (such as returned by ExternalStream>>fileDescriptor).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3910
    On some systems, only advisory locks are available -
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3911
    these depends on other accessors to also perform the locking operation.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3912
    If they do not, they may still access the file 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3913
    (on some systems, locks are mandatory, on others, they are advisory). 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3914
    The isSharedReadLock argument (if true) specifies if multiple readers
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3915
    are to be allowed - if false, they are not.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3916
    On some systems, all locks are non-exclusive locks.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3917
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3918
    Returns true, if the lock was aquired, false otherwise.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3919
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3920
    Notice, that not all OS's support these locks; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3921
    on some, this may simply be a no-op.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3922
    Also notice, that some systems block the process, to wait for the lock.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3923
    This can (again: on some systems) be avoided by passing a false blockIfLocked
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3924
    argument."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3925
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3926
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3927
    if (__isSmallInteger(aFileDescriptor)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3928
	int fd = __intVal(aFileDescriptor);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3929
	int lockArg;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3930
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3931
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3932
	 * claus: sigh - each one has a different interface ... 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3933
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3934
#if defined(F_SETLK)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3935
	{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3936
	    /* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3937
	     * new fcntl(SETLK) interface;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3938
	     * available on SYSV4 and Linux
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3939
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3940
	    struct flock flock;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3941
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3942
	    if (isSharedReadLock == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3943
		flock.l_type = F_RDLCK;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3944
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3945
		flock.l_type = F_WRLCK;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3946
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3947
	    flock.l_whence = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3948
	    flock.l_start = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3949
	    flock.l_len = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3950
	    lockArg = F_SETLK;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3951
# if defined(F_SETLKW)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3952
	    if (blockIfLocked == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3953
		lockArg = F_SETLKW;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3954
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3955
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3956
	    if (fcntl(fd, lockArg, &flock) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3957
		RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3958
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3959
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3960
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3961
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3962
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3963
# if defined(LOCK_EX) && defined(LOCK_UN)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3964
	/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3965
	 * BSD 4.3 advisory locks
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3966
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3967
	lockArg = LOCK_EX;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3968
#  if defined(LOCK_SH)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3969
	if (isSharedReadLock == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3970
	    lockArg = LOCK_SH
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3971
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3972
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3973
#  if defined(LOCK_NB)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3974
	if (blockIfLocked == false) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3975
	    lockArg |= LOCK_NB;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3976
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3977
#  endif
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3978
	if (flock(fd, lockArg) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3979
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3980
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3981
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3982
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3983
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3984
#  if defined(F_LOCK) && defined(F_UNLOCK)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3985
	/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3986
	 * SYSV3 advisory locks
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3987
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3988
	if (lockf(fd, F_LOCK, 0) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3989
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  3990
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3991
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3992
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3993
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3994
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3995
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3996
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3997
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3998
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3999
supportsFileLinks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4000
    "return true, if the OS supports file links (hard links).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4001
     Typically, only unix returns true here."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4002
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4003
    ^ true
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4004
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4005
    "Modified: / 5.6.1998 / 18:35:01 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4006
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4007
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4008
supportsFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4009
    "return true, if the OS supports file locking"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4011
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4012
#if defined(F_SETLK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4013
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4014
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4015
# if defined(LOCK_EX) && defined(LOCK_UN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4016
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4017
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4018
#  if defined(F_LOCK) && defined(F_UNLOCK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4019
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4020
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4021
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4022
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4023
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4024
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4025
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4026
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4027
     OperatingSystem supportsFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4028
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4029
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4030
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4031
supportsNonBlockingFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4032
    "return true, if the OS supports nonBlocking file locking
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4033
     (i.e. with immediate return instead of waiting for the lock)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4034
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4035
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4036
#if defined(F_SETLK) && defined(F_SETLKW)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4037
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4038
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4039
# if defined(LOCK_EX) && defined(LOCK_UN) && defined(LOCK_NB)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4040
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4041
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4042
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4043
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4044
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4045
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4046
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4047
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4048
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4049
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4050
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4051
supportsSharedLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4052
    "return true, if the OS supports shared (i.e. multiple reader)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4053
     file locking."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4054
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4055
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4056
#if defined(F_SETLK) && defined(F_RDLCK) && defined(F_WRLCK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4057
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4058
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4059
# if defined(LOCK_EX) && defined(LOCK_SH) && defined(LOCK_UN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4060
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4061
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4062
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4063
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4064
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4065
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4066
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4067
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4068
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4069
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4070
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4071
unlockFD:aFileDescriptor
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4072
    "clear a file lock on the file represented by aFileDescriptor,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4073
     which was previously aquired by #lockFD:.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4074
     Return false, if the unlock failed 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4075
     (which may happens when a wrong fd is passed, 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4076
      no lock was set previously, or the systsem does not support locks).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4077
     Notice, that not all OS's support file locks; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4078
     on some, this may simply be a no-op."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4079
     
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4080
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4081
    if (__isSmallInteger(aFileDescriptor)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4082
	int fd = __intVal(aFileDescriptor);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4083
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4084
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4085
	 * claus: sigh - each one has a different interface ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4086
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4087
#if defined(F_SETLK)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4088
	{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4089
	    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4090
	     * new fcntl(SETLK) interface;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4091
	     * available on SYSV4 and Linux
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4092
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4093
	    struct flock flock;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4094
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4095
	    flock.l_type = F_UNLCK;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4096
	    flock.l_whence = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4097
	    flock.l_start = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4098
	    flock.l_len = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4099
	    if (fcntl(fd, F_SETLK, &flock) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4100
		RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4101
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4102
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4103
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4104
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4105
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4106
# if defined(LOCK_EX) && defined(LOCK_UN)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4107
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4108
	 * BSD 4.3 advisory locks
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4109
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4110
	if (flock(fd, LOCK_UN) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4111
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4112
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4113
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4114
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4115
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4116
#  if defined(F_LOCK) && defined(F_UNLOCK)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4117
	/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4118
	 * SYSV3 advisory locks
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4119
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4120
	if (lockf(fd, F_UNLOCK, 0) != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4121
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4122
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4123
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4124
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4125
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4126
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4127
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4128
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4129
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4130
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4131
!UnixOperatingSystem class methodsFor:'file queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4132
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4133
caseSensitiveFilenames
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4134
    "return true, if the OS has caseSensitive file naming.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4135
     On MSDOS, this will return false; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4136
     on a real OS, we return true."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4137
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4138
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4139
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4140
    "Modified: / 5.6.1998 / 18:35:18 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4141
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4142
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4143
compressPath:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4144
    "return the pathName compressed - that is, remove all ..-entries
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4145
     and . entries. This does not always (in case of symbolic links)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4146
     return the true pathName and is therefore used as a fallback
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4147
     if realPath and popen failed."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4148
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4149
    |names n "{ Class: SmallInteger }" |
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4150
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4151
    names := pathName 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4152
		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4153
    names := names asOrderedCollection.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4154
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4155
     cut off initial double-slashes
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4156
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4157
    [names startsWith:#('' '')] whileTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4158
	names removeFirst.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4159
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4160
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4161
     cut off double-slashes at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4162
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4163
    [names endsWith:#('')] whileTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4164
	names removeLast.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4165
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4166
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4167
     cut off current-dir at beginning
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4168
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4169
    n := names size.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4170
    [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4171
	names removeFirst.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4172
	n := n - 1.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4173
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4174
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4175
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4176
     cut off parent-dirs at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4177
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4178
    [(n > 2) 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4179
     and:[(names endsWith:#('..'))
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4180
     and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4181
	names removeLast; removeLast.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4182
	n := n - 2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4183
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4184
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4185
    ^ names asStringWith:self fileSeparator 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4186
		    from:1
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4187
		    to:n
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4188
		    compressTabs:false final:nil 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4190
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4191
     OperatingSystem compressPath:'./..'    
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4192
     OperatingSystem compressPath:'/foo/bar/baz/..'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4193
     OperatingSystem compressPath:'foo/bar/baz/..'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4194
     OperatingSystem compressPath:'foo/bar/baz/../'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4195
     OperatingSystem compressPath:'foo/bar/baz/..///' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4196
     OperatingSystem compressPath:'///foo/bar/baz/..///' 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4197
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4198
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4199
    "Modified: 1.11.1996 / 20:13:48 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4200
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4201
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4202
fileSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4203
    "return the character used to separate names in a path.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4204
     This character differs for MSDOS and other systems,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4205
     (but those are currently not supported - so this is some
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4206
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4207
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4208
    ^ $/
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4209
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4210
    "Modified: / 5.6.1998 / 18:35:24 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4211
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4212
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4213
getDiskInfoOf:aDirectoryPath
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4214
    "return some disk info. 
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4215
     The amountof information returned depends upon the OS, and is
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4216
     not guaranteed to be consistent across architectures.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4217
     On unix, the information returned is (at least):
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4218
	freeBytes
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4219
	totalBytes
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4220
    "
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4221
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4222
    |p outputText keys values n info
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4223
     fileSystemIdx sizeIdx usedIdx availIdx capacityIdx mountIdx|
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4224
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4225
    p := PipeStream readingFrom:('df -k ' , aDirectoryPath).
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4226
    p isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4227
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4228
    [
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4229
	outputText := p contentsOfEntireFile.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4230
    ] valueNowOrOnUnwindDo:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4231
	p close.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4232
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4233
"/ Transcript showCR:outputText asString.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4234
    outputText isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4235
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4236
    outputText := outputText asCollectionOfLines.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4237
    outputText size < 2 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4238
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4239
    keys := (outputText at:1) asLowercase asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4240
    values := (outputText at:2) asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4241
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4242
    "/ we may have to validate the following column indices
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4243
    "/ on some rude Unix versions ...
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4244
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4245
    fileSystemIdx := 1.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4246
    sizeIdx := 2.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4247
    usedIdx := 3.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4248
    availIdx := 4.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4249
    capacityIdx := 5.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4250
    mountIdx := 6.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4251
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4252
    values size < 6 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4253
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4254
    info := IdentityDictionary new.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4255
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4256
    n := Integer readFrom:(values at:capacityIdx) onError:nil.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4257
    n notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4258
	info at:#percentUsed put:n
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4259
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4260
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4261
    n := Integer readFrom:(values at:availIdx) onError:nil.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4262
    n notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4263
	info at:#freeBytes put:(n * 1024)
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4264
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4265
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4266
    n := Integer readFrom:(values at:usedIdx) onError:nil.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4267
    n notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4268
	info at:#usedBytes put:(n * 1024)
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4269
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4270
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4271
    n := Integer readFrom:(values at:sizeIdx) onError:nil.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4272
    n notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4273
	info at:#totalBytes put:(n * 1024)
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4274
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4275
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4276
    info at:#mountPoint put:(values at:mountIdx).
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4277
    info at:#fileSystem put:(values at:fileSystemIdx).
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4278
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4279
    ^ info
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4280
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4281
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4282
     OperatingSystem getDiskInfoOf:'/'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4283
     OperatingSystem getDiskInfoOf:'.'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4284
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4285
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4286
    "Modified: / 22.5.1999 / 00:32:13 / cg"
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4287
!
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4288
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4289
getDriveList
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4290
    "return a list of volumes in the system. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4291
     On unix, no such thing like a volume exists 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4292
     - there, a syntetic list with root, home & current is returned. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4293
     On MSDOS, a list of drive letters is (eventually) returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4294
     On VMS, a list of volumes is (eventually) returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4295
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4296
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4297
    "/ default: retrurn array filled with
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4298
    "/ root, home and current directories.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4299
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4300
    ^ Array 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4301
	with:'/'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4302
	with:(self getHomeDirectory)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4303
	with:(Filename currentDirectory pathName)
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4304
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4305
    "Modified: / 5.6.1998 / 18:35:35 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4306
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4307
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4308
getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4309
    "return info about mounted volumes. 
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4310
     The amount of information returned depends upon the OS, and is
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4311
     not guaranteed to be consistent across architectures.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4312
     On unix, the information returned is (at least):
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4313
	mountPoint - mount point
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4314
	fileSystem - device or NFS-remotePath
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4315
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4316
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4317
    |p outputText keys values info infoEntry|
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4318
4933
bfa38904104e use df -k
Claus Gittinger <cg@exept.de>
parents: 4923
diff changeset
  4319
    p := PipeStream readingFrom:('df -k').
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4320
    p isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4321
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4322
    [
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4323
	outputText := p contentsOfEntireFile.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4324
    ] valueNowOrOnUnwindDo:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4325
	p close.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4326
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4327
"/ Transcript showCR:outputText asString.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4328
    outputText isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4329
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4330
    outputText := outputText asCollectionOfLines.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4331
    outputText size < 2 ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4332
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4333
    keys := (outputText at:1) asLowercase asCollectionOfWords.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4334
    "/ we may have to validate the following column indices
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4335
    "/ on some rude Unix versions ...
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4336
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4337
    info := OrderedCollection new.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4338
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4339
    outputText from:2 do:[:line |
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4340
	values := line asCollectionOfWords.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4341
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4342
	values size >= 2 ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4343
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4344
	    infoEntry := IdentityDictionary new.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4345
	    infoEntry at:#mountPoint put:(values last).
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4346
	    infoEntry at:#fileSystem put:(values first).
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4347
	    info add:infoEntry.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4348
	]
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4349
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4350
    ^ info
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4351
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4352
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4353
     OperatingSystem getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4354
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4355
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4356
    "Modified: / 22.5.1999 / 00:32:13 / cg"
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4357
!
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4358
4201
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4359
getNullDevice
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4360
    "return the name of the OS's null device"
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4361
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4362
    ^ '/dev/null'
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4363
!
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4364
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4365
infoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4366
    "return some object filled with info for the file 'aPathName';
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4367
     the info (for which corresponding access methods are understood by
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4368
     the returned object) is:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4369
	 type            - a symbol giving the files type
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4370
	 mode            - numeric access mode 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4371
	 uid             - owners user id
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4372
	 gid             - owners group id
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4373
	 size            - files size
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4374
	 id              - files number (i.e. inode number)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4375
	 accessed        - last access time (as Timestamp)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4376
	 modified        - last modification time (as Timestamp)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4377
	 statusChanged   - last status change time (as Timestamp)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4378
	 alternativeName     - (windows only:) the MSDOS name of the file
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4379
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4380
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4381
	 recordAttributes    - (VMS only:) recordAttributes
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4382
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4383
	 recordSize          - (VMS only:) record size.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4384
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4385
     Some of the fields may be returned as nil on systems which do not provide
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4386
     all of the information.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4387
     Return nil if such a file does not exist. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4388
     For symbolic links (if supported by the OS), 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4389
     the info of the pointed-to-file (i.e. the target) is returned;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4390
     use #linkInfoOf: to get info about the link itself.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4391
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4392
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4393
    |info type mode uid gid size id 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4394
     atime mtime ctime 
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  4395
     aOStime mOStime cOStime|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4396
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4397
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4398
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4399
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4401
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4402
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4403
	printf("stat on '%s' for info\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4404
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4405
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4406
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4407
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4408
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4409
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4410
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4411
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4412
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4413
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4414
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4415
	switch (buf.st_mode & S_IFMT) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4416
	    case S_IFDIR:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4417
		type = @symbol(directory);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4418
		break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4419
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4420
	    case S_IFREG:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4421
		type = @symbol(regular);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4422
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4423
# ifdef S_IFCHR
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4424
	    case S_IFCHR:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4425
		type = @symbol(characterSpecial);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4426
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4427
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4428
# ifdef S_IFBLK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4429
	    case S_IFBLK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4430
		type = @symbol(blockSpecial);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4431
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4432
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4433
# ifdef S_IFMPC
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4434
	    case S_IFMPC:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4435
		type = @symbol(multiplexedCharacterSpecial);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4436
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4437
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4438
# ifdef S_IFMPB
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4439
	    case S_IFMPB:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4440
		type = @symbol(multiplexedBlockSpecial);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4441
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4442
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4443
# ifdef S_IFLNK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4444
	    case S_IFLNK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4445
		type = @symbol(symbolicLink);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4446
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4447
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4448
# ifdef S_IFSOCK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4449
	    case S_IFSOCK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4450
		type = @symbol(socket);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4451
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4452
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4453
# ifdef S_IFIFO
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4454
	    case S_IFIFO:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4455
		type = @symbol(fifo);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4456
		break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4457
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4458
	    default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4459
		type = @symbol(unknown);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4460
		break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4461
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4462
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4463
	ino = buf.st_ino;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4464
	id = __MKUINT(ino);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4465
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4466
	mode = __MKSMALLINT(buf.st_mode & 0777);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4467
	uid = __MKSMALLINT(buf.st_uid);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4468
	gid = __MKSMALLINT(buf.st_gid);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4469
	size = __MKUINT(buf.st_size);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4470
	aOStime = __MKUINT(buf.st_atime);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4471
	mOStime = __MKUINT(buf.st_mtime);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4472
	cOStime = __MKUINT(buf.st_ctime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4473
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4474
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4475
    mode notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4476
	atime := AbsoluteTime fromOSTime:(aOStime * 1000).
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4477
	mtime := AbsoluteTime fromOSTime:(mOStime * 1000).
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4478
	ctime := AbsoluteTime fromOSTime:(cOStime * 1000).
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4479
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4480
	info := FileStatusInfo
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4481
		    type:type 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4482
		    mode:mode 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4483
		    uid:uid 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4484
		    gid:gid 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4485
		    size:size 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4486
		    id:id 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4487
		    accessed:atime 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4488
		    modified:mtime 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4489
		    statusChanged:ctime
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4490
		    path:nil.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4491
	^ info
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4492
   ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4493
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4494
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4495
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4496
    OperatingSystem infoOf:'/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4497
    (OperatingSystem infoOf:'/') uid
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4498
    (OperatingSystem infoOf:'/') accessed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4499
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4500
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4501
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4502
isDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4503
    "return true, if 'aPathName' is a valid directory path name.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4504
     (i.e. exists and is a directory).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4505
     This also returns true for symbolic links pointing to a directory;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4506
     if you need to check for this, use #linkInfo:."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4507
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4508
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4509
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4510
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4511
    if (__isString(aPathName)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4512
	struct stat buf;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4513
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4514
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4515
	printf("stat on '%s' for isDirectory\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4516
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4517
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4518
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4519
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4520
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4521
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4522
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4523
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4524
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4525
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4526
	RETURN ( ((buf.st_mode & S_IFMT) == S_IFDIR) ? true : false);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4527
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4528
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4529
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4530
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4531
    "an alternative implementation would be:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4532
	^ (self infoOf:aPathName) type == #directory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4533
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4534
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4535
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4536
isExecutable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4537
    "return true, if the given file is executable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4538
     For symbolic links, the pointed-to-file is checked."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4539
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4540
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4541
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4542
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4543
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4544
# ifdef TRACE_ACCESS_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4545
	printf("access on '%s' for executable\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4546
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4547
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4548
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4549
	    ret = access(__stringVal(aPathName), X_OK);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4550
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4551
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4552
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4553
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4554
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4555
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4556
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4557
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4558
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4559
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4560
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4561
isReadable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4562
    "return true, if the file/dir 'aPathName' is readable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4563
     For symbolic links, the pointed-to-file is checked."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4564
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4565
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4566
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4567
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4568
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4569
# ifdef TRACE_ACCESS_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4570
	printf("access on '%s' for readable\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4571
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4572
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4573
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4574
	    ret = access(__stringVal(aPathName), R_OK);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4575
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4576
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4577
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4578
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4579
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4580
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4581
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4582
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4583
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4584
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4585
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4586
isSymbolicLink:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4587
    "return true, if the given file is a symbolic link"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4588
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4589
    ^ (self linkInfoOf:aPathName) notNil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4590
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4591
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4592
     OperatingSystem isSymbolicLink:'Make.proto'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4593
     OperatingSystem isSymbolicLink:'Makefile' 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4594
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4595
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4596
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4597
isValidPath:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4598
    "return true, if 'aPathName' is a valid path name
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4599
     (i.e. the file or directory exists)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4600
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4601
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4602
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4603
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4604
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4605
    if (__isString(aPathName) || __isSymbol(aPathName) ) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4606
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4607
	printf("stat on '%s' for isValidPath\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4608
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4609
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4610
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4611
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4612
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4613
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4614
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4615
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4616
	    RETURN (false);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4617
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4618
	RETURN ( ret ? false : true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4619
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4620
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4621
    ^ self primitiveFailed
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4622
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4623
"/ alternative:
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4624
"/        ^ (self infoOf:aPathName) notNil
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4625
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4626
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4627
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4628
isWritable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4629
    "return true, if the given file is writable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4630
     For symbolic links, the pointed-to-file is checked."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4631
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4632
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4633
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4634
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4635
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4636
# ifdef TRACE_ACCESS_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4637
	printf("access on '%s' for writable\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4638
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4639
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4640
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4641
	    ret = access(__stringVal(aPathName), W_OK);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4642
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4643
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4644
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4645
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4646
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4647
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4648
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4649
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4650
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4651
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4652
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4653
linkInfoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4654
    "return a dictionary filled with info for the file 'aPathName',
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4655
     IFF aPathName is a symbolic link. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4656
     If aPathName is invalid, or its NOT a symbolic link, nil is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4657
     (which means, that systems like VMS or MSDOS always return nil here.)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4658
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4659
     The contents of the dictionary gives info about the link itself,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4660
     on contrast to #infoOf:, which returns the info of the pointed to file
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4661
     in case of a symbolic link."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4662
     
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4663
    |info type mode uid gid size id atime mtime ctime path|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4664
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4665
%{  /* STACK: 1200 */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  4666
#if defined(S_IFLNK)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4667
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4668
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4669
    char pathBuffer[1024];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4670
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4671
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4672
    if (__isString(aPathName)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4673
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4674
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4675
	    ret = lstat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4676
	} while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4677
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4678
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4679
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4680
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4681
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4682
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4683
	switch (buf.st_mode & S_IFMT) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4684
	    default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4685
		RETURN ( nil ); /* not a symbolic link */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4686
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4687
	    case S_IFLNK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4688
		type = @symbol(symbolicLink);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4689
		break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4690
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4691
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4692
	ino = buf.st_ino;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4693
	id = __MKUINT(ino);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4694
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4695
	mode = __MKSMALLINT(buf.st_mode & 0777);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4696
	uid = __MKSMALLINT(buf.st_uid);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4697
	gid = __MKSMALLINT(buf.st_gid);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4698
	size = __MKUINT(buf.st_size);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4699
	atime = __MKUINT(buf.st_atime);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4700
	mtime = __MKUINT(buf.st_mtime);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4701
	ctime = __MKUINT(buf.st_ctime);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4702
	if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4703
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4704
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4705
	} 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4706
	pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4707
	path = __MKSTRING(pathBuffer);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4708
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4709
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4710
    RETURN ( nil );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4711
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4712
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4713
    mode notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4714
	info := IdentityDictionary new.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4715
	^ FileStatusInfo
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4716
	    type:type 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4717
	    mode:mode 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4718
	    uid:uid 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4719
	    gid:gid 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4720
	    size:size 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4721
	    id:id 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4722
	    accessed:(AbsoluteTime fromOSTime:(atime * 1000)) 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4723
	    modified:(AbsoluteTime fromOSTime:(mtime * 1000)) 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4724
	    statusChanged:(AbsoluteTime fromOSTime:(ctime * 1000))
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4725
	    path:path
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4726
   ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4727
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4728
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4729
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4730
    OperatingSystem infoOf:'Make.proto'  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4731
    OperatingSystem linkInfoOf:'Make.proto' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4732
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4733
    OperatingSystem infoOf:'resources/motif.style'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4734
    OperatingSystem linkInfoOf:'resources/motif.style' 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4735
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4736
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4737
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4738
parentDirectoryName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4739
    "return the name used to refer to parent directories.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4740
     In MSDOS, Unix and other systems this is '..', but maybe different
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4741
     for other systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4742
     (but those are currently not supported - so this is some
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4743
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4744
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4745
    ^ '..'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4746
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4747
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4748
pathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4749
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4750
     - thats the full pathname of the directory, starting at '/'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4751
     This method needs the path to be valid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4752
     (i.e. all directories must exist, be readable and executable).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4753
     Notice: if symbolic links are involved, the result may look different
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4754
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4755
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4756
    |p path command|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4757
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4758
    "some systems have a convenient function for this ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4759
    path := self primPathNameOf:pathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4760
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4761
    path isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4762
	(self isValidPath:pathName) ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4763
	    p := pathName.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4764
	    [(p size > 1)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4765
	     and:[p endsWith:(self fileSeparator)]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4766
	    ] whileTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4767
		p := p copyWithoutLast:1.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4768
	    ].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4769
	    ^ p
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4770
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4771
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4772
	(SlowFork==true or:[PipeFailed==true]) ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4773
	    PipeStream openErrorSignal handle:[:ex |
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4774
		PipeFailed := true.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4775
		'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4776
		ex return.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4777
	    ] do:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4778
		"have to fall back ..."
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4779
		command := 'cd "' , pathName , '"; pwd'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4780
		p := PipeStream readingFrom:command.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4781
	    ].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4782
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4783
	    (p isNil or:[p atEnd]) ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4784
		('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4785
	    ] ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4786
		path := p nextLine.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4787
		p close.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4788
	    ]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4789
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4790
	path isNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4791
	    "/
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4792
	    "/ return the original - there is nothing else can we do
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4793
	    "/
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4794
	    path := pathName
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4795
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4796
	(SlowFork==true or:[ForkFailed==true]) ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4797
	    path := self compressPath:path
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4798
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4799
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4800
    ^ path.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4801
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4802
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4803
     OperatingSystem pathNameOf:'.'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4804
     OperatingSystem pathNameOf:'../smalltalk/../smalltalk'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4805
     OperatingSystem pathNameOf:'../../..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4806
     OperatingSystem pathNameOf:'..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4807
     OperatingSystem pathNameOf:'/tmp////' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4808
     OperatingSystem pathNameOf:'/foo/bar' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4809
     OperatingSystem pathNameOf:'/foo/bar/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4810
     OperatingSystem pathNameOf:'/foo/bar//'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4811
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4812
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4813
    "Modified: / 29.11.1996 / 18:02:12 / stefan"
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4814
    "Modified: / 5.6.1998 / 18:37:15 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4815
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4816
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4817
primIdOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4818
    "the actual code to return the fileNumber (i.e. inode number) of a file."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4819
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  4820
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4821
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4822
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4823
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4824
    OBJ retVal;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4825
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4826
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4827
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4828
	printf("stat on '%s' for id\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4829
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4830
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4831
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4832
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4833
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4834
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4835
	if (ret >= 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4836
	    ino = buf.st_ino;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4837
	    retVal = __MKUINT(ino);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4838
	    RETURN (retVal);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4839
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4840
	@global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4841
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4842
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4843
    RETURN (nil);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4844
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4845
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4846
5492
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4847
primInfoOf:aPathName
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4848
   "for rel5 only"
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4849
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4850
   ^ self primitiveFailed
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4851
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4852
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4853
!
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4854
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4855
primPathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4856
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4857
     - thats the full pathname of the directory, starting at '/'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4858
     This method here returns nil, if the OS does not provide a
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4859
     realPath library function.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4860
     Notice: if symbolic links are involved, the result may look different
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4861
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4862
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4863
    |path|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4864
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4865
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4866
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4867
    if (__isString(pathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4868
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4869
#ifdef HAS_GETCWD
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4870
	if (strcmp(__stringVal(pathName), ".") == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4871
	    char nameBuffer[MAXPATHLEN + 1];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4872
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4873
	    if (@global(CurrentDirectory) == nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4874
		if (getcwd(nameBuffer, MAXPATHLEN)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4875
		    OBJ d;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4876
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4877
		    @global(CurrentDirectory) = d = __MKSTRING(nameBuffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4878
		    __GSTORE(d);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4879
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4880
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4881
	    RETURN (@global(CurrentDirectory));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4882
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4883
#endif /* HAS_GETCWD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4884
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4885
#ifdef HAS_REALPATH
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4886
	{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4887
	    char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4888
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4889
	    if (realpath(__stringVal(pathName), nameBuffer)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4890
		RETURN ( __MKSTRING(nameBuffer) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4891
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4892
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4893
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4894
#endif /* ! HAS_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4895
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4896
%}.
5451
2e21cd54b656 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5448
diff changeset
  4897
    ^ nil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4898
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4899
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4900
timeOfLastAccess:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4901
    "return the time, when the file was last accessed.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4902
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4903
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4904
    "could be implemented as:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4905
	(self infoOf:aPathName) accessed 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4906
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4907
    |osSeconds i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4908
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4909
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4910
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4911
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4912
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4913
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4914
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4915
	printf("stat on '%s' for timeOfLastAccess\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4916
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4917
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4918
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4919
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4920
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4921
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4922
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4923
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4924
	    RETURN (nil);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4925
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4926
	osSeconds = __MKUINT(buf.st_atime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4927
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4928
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4929
    osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4930
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4931
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4932
    i notNil ifTrue:[^ i accessed].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4933
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4934
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4935
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4936
     OperatingSystem timeOfLastAccess:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4937
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4938
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4939
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4940
timeOfLastChange:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4941
    "return the time, when the file was last changed. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4942
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4943
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4944
    "could be implemented as:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4945
	(self infoOf:aPathName) modified
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4946
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4947
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4948
    |osSeconds i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4949
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4950
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4951
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4952
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4953
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4954
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4955
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4956
	printf("stat on '%s' for timeOfLastChange\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4957
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4958
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4959
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4960
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4961
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4962
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4963
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4964
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4965
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4966
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4967
	osSeconds = __MKUINT(buf.st_mtime);
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4968
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4969
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4970
    osSeconds notNil ifTrue:[^ AbsoluteTime fromOSTime:(osSeconds * 1000)].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4971
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4972
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4973
    i notNil ifTrue:[^ i modified].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4974
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4975
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4976
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4977
     OperatingSystem timeOfLastChange:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4978
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4979
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4980
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4981
typeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4982
    "return the type of a file as a symbol; for nonexistent files,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4983
     nil is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4984
     Notice: for symbolic links, the type of the pointed-to file is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4985
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4986
    |i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4987
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4988
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4989
     this could have been implemented as:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  4990
	(self infoOf:aPathName) type 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4991
     but for huge directory searches the code below is faster
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4992
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4993
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4994
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4995
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4996
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4997
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4998
    if (__isString(aPathName)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4999
# ifdef TRACE_STAT_CALLS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5000
	printf("stat on '%s' for type\n", __stringVal(aPathName));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5001
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5002
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5003
	do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5004
	    ret = stat((char *) __stringVal(aPathName), &buf);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5005
	} while (ret < 0 && errno == EINTR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5006
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5007
	if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5008
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5009
	    RETURN ( nil );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5010
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5011
	switch (buf.st_mode & S_IFMT) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5012
	    case S_IFDIR:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5013
		RETURN ( @symbol(directory) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5014
	    case S_IFREG:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5015
		RETURN ( @symbol(regular) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5016
# ifdef S_IFCHR
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5017
	    case S_IFCHR:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5018
		RETURN ( @symbol(characterSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5019
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5020
# ifdef S_IFBLK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5021
	    case S_IFBLK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5022
		RETURN ( @symbol(blockSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5023
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5024
# ifdef S_IFLNK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5025
	    case S_IFLNK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5026
		RETURN ( @symbol(symbolicLink) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5027
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5028
# ifdef S_IFSOCK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5029
	    case S_IFSOCK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5030
		RETURN ( @symbol(socket) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5031
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5032
# ifdef S_IFIFO
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5033
	    case S_IFIFO:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5034
		RETURN ( @symbol(fifo) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5035
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5036
	    default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5037
		RETURN ( @symbol(unknown) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5038
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5039
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5040
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5041
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5042
    i notNil ifTrue:[^ i type].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5043
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5044
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5045
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5046
     OperatingSystem typeOf:'/'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5047
     OperatingSystem typeOf:'.'   
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5048
     OperatingSystem typeOf:'Make.proto' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5049
     OperatingSystem typeOf:'resources/motif.style' 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5050
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5051
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5052
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5053
volumeNameOf:aPathString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5054
    "return the volumeName of the argument, aPath
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5055
     - thats the name of the volume where aPath is.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5056
     Not all OperatingSystems support/use volumes; on unix,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5057
     this always returns an empty string."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5058
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5059
    ^ ''
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5060
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5061
    "Modified: / 5.6.1998 / 18:38:11 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5062
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5063
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5064
!UnixOperatingSystem class methodsFor:'interrupts & signals'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5065
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5066
defaultSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5067
    "revert to the default action on arrival of a (Unix-)signal.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5068
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5069
     WARNING: for some signals, it is no good idea to revert to default;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5070
     for example, the default for SIGINT (i.e. ^C) is to exit; while the
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5071
     default for SIGQUIT (^ \) is to dump core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5072
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5073
     systems - use OperatingSystem sigXXX to get the numeric value for
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5074
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5075
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5076
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5077
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5078
    if (__isSmallInteger(signalNumber)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5079
#ifdef SIG_DFL
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5080
	signal(__intVal(signalNumber), SIG_DFL);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5081
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5082
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5083
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5084
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5085
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5086
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5087
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5088
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5089
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5090
    "you better save a snapshot image before trying this ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5091
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5092
     'if you hit ^C now, Smalltalk will exit immediately' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5093
     OperatingSystem defaultSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5094
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5095
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5096
     'normal ^C handling again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5097
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5098
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5099
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5100
disableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5101
    "turn off IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5102
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5103
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5104
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5105
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5106
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5107
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5108
    if (__isSmallInteger(fd)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5109
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5110
# if defined(SYSV4)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5111
	ret = ioctl(f, I_SETSIG, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5112
# else /*! SYSV4*/
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5113
	flags = fcntl(f, F_GETFL, 0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5114
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5115
	 * if already clear, there is no need for this syscall ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5116
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5117
	if (flags & FASYNC) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5118
	    ret = fcntl(f, F_SETFL, flags & ~FASYNC);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5119
	    if (ret >= 0) ret = flags;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5120
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5121
	    ret = flags;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5122
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5123
# endif /* !SYSV4 */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5124
	RETURN ( __MKSMALLINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5125
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5126
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5127
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5128
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5129
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5130
     or if the OS does not support IO interrupts.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5131
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5132
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5133
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5134
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5135
disableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5136
    "disable (Unix-) signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5137
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5138
     WARNING: for some signals, it is no good idea to disable
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5139
     them; for example, disabling the SIGINT signal turns off ^C
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5140
     handling.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5141
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5142
     systems - use OperatingSystem sigXXX to get the numeric value for
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5143
     a signal.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5144
     Use only for fully debugged stand alone applications."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5145
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5146
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5147
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5148
    if (__isSmallInteger(signalNumber)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5149
	int sigNo = __intVal(signalNumber);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5150
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5151
	if (sigNo == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5152
	    RETURN (self);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5153
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5154
#ifdef SIG_IGN
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5155
	signal(sigNo, SIG_IGN);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5156
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5157
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5158
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5159
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5160
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5161
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5162
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5163
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5164
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5165
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5166
     'now, ^C is totally ignored ...' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5167
     OperatingSystem disableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5168
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5169
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5170
     '^C handled again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5171
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5172
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5173
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5174
disableTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5175
    "disable timer interrupts.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5176
     WARNING: 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5177
	the system will not operate correctly with timer interrupts
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5178
	disabled, because no scheduling or timeouts are possible."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5179
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5180
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5181
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5182
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5183
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5184
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5185
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5186
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5187
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5188
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5189
    setitimer(ITIMER_REAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5190
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5191
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5192
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5193
# if defined(USE_SLOW_ALARM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5194
#  if defined(SIGALRM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5195
    alarm(0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5196
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5197
#  endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5198
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5199
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5200
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5201
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5202
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5203
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5204
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5205
enableChildSignalInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5206
    "enable childSignal interrupts 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5207
     (SIGCHLD, if the architecture supports it).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5208
     After enabling, these signals will send the message 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5209
     'childSignalInterrupt' to the ChildSignalInterruptHandler object."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5210
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5211
    self enableSignal:(self sigCHLD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5212
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5213
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5214
enableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5215
    "turn on IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5216
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5217
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5218
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5219
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5220
#ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5221
    extern void __signalIoInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5222
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5223
    static int firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5224
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5225
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5226
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5227
 * SIGIO/SIGPOLL - data available for I/O
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5228
 * (used to wake up waiting processes)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5229
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5230
#ifdef SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5231
# define THESIGNAL SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5232
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5233
# ifdef SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5234
#  define THESIGNAL SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5235
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5236
#  ifdef SIGURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5237
#   define THESIGNAL SIGURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5238
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5239
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5240
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5241
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5242
    if (__isSmallInteger(fd)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5243
	if (firstCall) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5244
#ifdef HAS_SIGACTION
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5245
	    struct sigaction act;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5246
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5247
	    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5248
	     * Do not add SA_RESTART here. A signal can cause a
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5249
	     * thread switch, another thread can do a garbage collect
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5250
	     * and restarted system calls may write into old
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5251
	     * (collected) addresses.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5252
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5253
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5254
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5255
	    sigemptyset(&act.sa_mask);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5256
	    act.sa_handler = __signalIoInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5257
	    sigaction(THESIGNAL, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5258
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5259
# ifdef HAS_SIGVEC
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5260
	    struct sigvec vec;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5261
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5262
	    vec.sv_flags = SV_INTERRUPT;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5263
	    sigemptyset(&vec.sv_mask);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5264
	    vec.sv_handler = __signalIoInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5265
	    sigvec(THESIGNAL, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5266
# else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5267
	    signal(THESIGNAL, __signalIoInterrupt);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5268
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5269
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5270
	    firstCall = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5271
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5272
#undef THESIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5273
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5274
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5275
# if defined(SYSV4)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5276
	ret = ioctl(f, I_SETSIG, S_INPUT | S_HIPRI | S_ERROR | S_RDNORM | S_RDBAND | S_MSG | S_HANGUP);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5277
# else /*! SYSV4*/
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5278
	flags = fcntl(f, F_GETFL, 0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5279
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5280
	 * if already set, there is no need for this syscall ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5281
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5282
	if (flags & FASYNC) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5283
	    ret = flags;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5284
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5285
	    ret = fcntl(f, F_SETFL, flags | FASYNC);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5286
	    if (ret >= 0) ret = flags;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5287
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5288
# endif /*!SYSV4*/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5289
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5290
#if defined(F_SETOWN) || defined(FIOSETOWN)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5291
	{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5292
	    int pid;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5293
	    int ok;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5294
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5295
	    pid = getpid();
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5296
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5297
# if defined(F_SETOWN)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5298
	    ok = fcntl(f, F_SETOWN, pid);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5299
	    /* printf("F_SETOWN returns %d (%d)\n", ret, errno); */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5300
# else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5301
	    ok = ioctl(f, FIOSETOWN, &pid);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5302
	    /* printf("FIOSETOWN returns %d (%d)\n", ret, errno); */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5303
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5304
	    if (ok < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5305
		ret = ok;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5306
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5307
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5308
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5309
	RETURN ( __MKUINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5310
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5311
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5312
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5313
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5314
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5315
     or if the system does not support SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5316
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5317
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5318
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5319
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5320
enableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5321
    "enable (Unix-)signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5322
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5323
     The signal will be delivered to one of the standard handlers
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5324
     (SIGINT, SIGQUIT, etc) or to a general handler, which
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5325
     sends #signalInterrupt:.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5326
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5327
     NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5328
     systems - use OperatingSystem sigXXX to get the numeric value for
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5329
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5330
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5331
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5332
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5333
#ifdef NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5334
# define SIG_LIMIT NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5335
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5336
# ifdef SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5337
#  define SIG_LIMIT SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5338
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5339
#  ifdef SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5340
#   define SIG_LIMIT SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5341
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5342
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5343
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5344
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5345
#if defined(SIGPOLL) && !defined(SIGIO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5346
# define SIGIO SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5347
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5348
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5349
#ifdef SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5350
# define CHILD_SIGNAL   SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5351
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5352
# ifdef SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5353
#  define CHILD_SIGNAL  SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5354
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5355
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5356
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5357
    int sigNr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5358
#if defined(SIGINT) || defined(SIGQUIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5359
# ifndef __signalUserInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5360
    extern void __signalUserInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5361
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5362
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5363
#ifdef SIGFPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5364
# ifndef __signalFpExceptionInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5365
    extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5366
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5367
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5368
#ifdef SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5369
# ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5370
    extern void __signalIoInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5371
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5372
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5373
#ifdef CHILD_SIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5374
# ifndef __signalChildInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5375
    extern void __signalChildInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5376
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5377
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5378
#ifdef SIGPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5379
# ifndef __signalPIPEInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5380
    extern void __signalPIPEInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5381
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5382
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5383
#ifdef SIGBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5384
# ifndef __signalBUSInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5385
    extern void __signalBUSInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5386
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5387
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5388
#ifdef SIGSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5389
# ifndef __signalSEGVInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5390
    extern void __signalSEGVInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5391
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5392
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5393
#if defined(SIGILL) || defined(SIGEMT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5394
# ifndef __signalTrapInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5395
    extern void __signalTrapInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5396
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5397
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5398
#ifdef SIGALRM
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
  5399
# ifndef __signalTimerInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5400
    extern void __signalTimerInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5401
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5402
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5403
#ifndef __signalInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5404
    extern void __signalInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5405
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5406
    void (*handler)(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5407
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5408
    if (__isSmallInteger(signalNumber)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5409
     && ((sigNr = __intVal(signalNumber)) >= 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5410
#ifdef SIG_LIMIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5411
     &&  (sigNr <= SIG_LIMIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5412
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5413
    ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5414
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5415
	 * standard signals are forced into standard handlers
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5416
	 * - all others go into general signalInterrupt
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5417
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5418
#if defined(SIGPOLL) && defined(SIGIO)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5419
	if (sigNr == SIGPOLL)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5420
	    sigNr = SIGIO;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5421
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5422
	switch (sigNr) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5423
	    case 0:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5424
		/* enabling a non-supported signal */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5425
		RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5426
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5427
#ifdef SIGBREAK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5428
	    case SIGBREAK:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5429
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5430
#ifdef SIGINT
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5431
	    case SIGINT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5432
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5433
#ifdef SIGQUIT
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5434
	    case SIGQUIT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5435
#endif
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  5436
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5437
		handler = __signalUserInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5438
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5439
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5440
#ifdef SIGFPE
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5441
	    case SIGFPE:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5442
		handler = __signalFpExceptionInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5443
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5444
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5445
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5446
#ifdef SIGPIPE
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5447
	    case SIGPIPE:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5448
		handler = __signalPIPEInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5449
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5450
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5451
#ifdef SIGBUS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5452
	    case SIGBUS:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5453
		handler = __signalBUSInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5454
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5455
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5456
#ifdef SIGSEGV
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5457
	    case SIGSEGV:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5458
		handler = __signalSEGVInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5459
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5460
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5461
#ifdef SIGILL
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5462
	    case SIGILL:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5463
		handler = __signalTrapInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5464
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5465
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5466
#ifdef SIGEMT
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5467
	    case SIGEMT:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5468
		handler = __signalTrapInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5469
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5470
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5471
#ifdef SIGIO
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5472
	    case SIGIO:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5473
		handler = __signalIoInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5474
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5475
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5476
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5477
#ifdef CHILD_SIGNAL
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5478
	    case CHILD_SIGNAL:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5479
		handler = __signalChildInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5480
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5481
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5482
#ifdef SIGALRM
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5483
	    case SIGALRM:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5484
		handler = __signalTimerInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5485
		break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5486
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5487
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5488
	    default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5489
		handler = __signalInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5490
		break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5491
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5492
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5493
	{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5494
#ifdef HAS_SIGACTION
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5495
	    struct sigaction act;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5496
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5497
	    /*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5498
	     * Do not add SA_RESTART here. A signal can cause a
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5499
	     * thread switch, another thread can do a garbage collect
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5500
	     * and restarted system calls may write into old
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5501
	     * (collected) addresses.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5502
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5503
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5504
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5505
	    sigemptyset(&act.sa_mask);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5506
	    act.sa_handler = handler;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5507
	    sigaction(sigNr, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5508
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5509
# ifdef HAS_SIGVEC
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5510
	    struct sigvec vec;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5511
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5512
	    vec.sv_flags = SV_INTERRUPT;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5513
	    sigemptyset(&vec.sv_mask);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5514
	    vec.sv_handler = handler;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5515
	    sigvec(sigNr, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5516
# else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5517
	    (void) signal(sigNr, handler);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5518
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5519
#endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5520
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5521
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5522
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5523
	 * maybe, we should ret the old enable-status
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5524
	 * as boolean here ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5525
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5526
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5527
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5528
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5529
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5530
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5531
     this error is triggered on non-integer argument, or
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5532
     if the signal number is not in the valid range (1..NSIG)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5533
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5534
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5535
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5536
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5537
enableTimer:milliSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5538
    "setup for a timerInterrupt, to be signalled after some (real) time."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5539
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5540
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5541
    int millis;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5542
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5543
    millis = __intVal(milliSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5544
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5545
#ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5546
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5547
	static int firstCall = 1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5548
# ifndef __signalTimerInterrupt
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5549
	extern void __signalTimerInterrupt(SIGHANDLER_ARG);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5550
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5551
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5552
	if (firstCall) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5553
# ifdef HAS_SIGACTION
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5554
	    struct sigaction act;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5555
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5556
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5557
	    sigemptyset(&act.sa_mask);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5558
	    act.sa_handler = __signalTimerInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5559
	    sigaction(SIGALRM, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5560
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5561
#  ifdef HAS_SIGVEC
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5562
	    struct sigvec vec;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5563
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5564
	    vec.sv_flags = SV_INTERRUPT;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5565
	    sigemptyset(&vec.sv_mask);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5566
	    vec.sv_handler = __signalTimerInterrupt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5567
	    sigvec(SIGALRM, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5568
#  else /* neither SIGACTION nor SIGVEC */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5569
	    signal(SIGALRM, __signalTimerInterrupt);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5570
#  endif /* stupid system  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5571
# endif
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5572
	    firstCall = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5573
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5574
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5575
#endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5576
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5577
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5578
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5579
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5580
	struct itimerval dt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5581
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5582
	dt.it_interval.tv_sec = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5583
	dt.it_interval.tv_usec = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5584
	dt.it_value.tv_sec = millis / 1000;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5585
	dt.it_value.tv_usec = (millis % 1000) * 1000;  
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5586
	setitimer(ITIMER_REAL, &dt, 0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5587
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5588
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5589
#else /* no ITIMER_REAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5590
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5591
# ifdef USE_SLOW_ALARM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5592
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5593
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5594
	 * last fallback - use alarm (which only gives 1 second resolution).
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5595
	 * If the system does not support any of the above, you have to life
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5596
	 * with this. The consequence is that pressing CTRL-C processing and
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5597
	 * thread switching will take place much delayed.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5598
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5599
	alarm(1);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5600
	RETURN(true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5601
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5602
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5603
#endif /* ITIMER_REAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5604
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5605
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5606
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5607
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5608
killProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5609
    "kill a unix process.
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5610
     The process has a no chance to do some cleanup.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5611
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5612
     WARNING: in order to avoid zombie processes (on unix),
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5613
	      you may have to fetch the processes exitstatus with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5614
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5615
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5616
    self sendSignal:(self sigKILL) to:processId.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5617
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5618
    "Modified: / 10.6.1998 / 11:59:12 / cg"
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5619
!
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5620
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5621
killProcessGroup:processGroupId
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5622
    "kill a unix process group.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5623
     The process has a no chance to do some cleanup.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5624
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5625
     WARNING: in order to avoid zombie processes (on unix),
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5626
	      you may have to fetch the processes exitstatus with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5627
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5628
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5629
    self sendSignal:(self sigKILL) to:(processGroupId negated).
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5630
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5631
    "Created: / 10.6.1998 / 11:59:29 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5632
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5633
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5634
sendSignal:signalNumber to:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5635
    "send a unix signal to some process (maybe myself).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5636
     Returns false if any error occurred, true otherwise.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5637
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5638
     Do not confuse UNIX signals with Smalltalk-Signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5639
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5640
     WARNING: in order to avoid zombie processes (on unix),
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5641
	      you may have to fetch the processes exitstatus with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5642
	      OperatingSystem>>getStatusOfProcess:aProcessId
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5643
	      if the signal terminates that process."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5644
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5645
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5646
    if (__bothSmallInteger(signalNumber, processId)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5647
	if (kill(__intVal(processId), __intVal(signalNumber)) < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5648
	    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5649
	    RETURN ( false );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5650
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5651
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5652
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5653
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5654
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5655
    "/ either invalid argument (non-integers)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5656
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5657
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5658
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5659
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5660
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5661
startSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5662
    "trigger a spyInterrupt, to be signalled after some short (virtual) time.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5663
     This is used by the old MessageTally for profiling.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5664
     Should be changed to use real profiling timer if available.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5665
     On systems, where no virtual timer is available, use the real timer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5666
     (which is of course less correct).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5667
     OBSOLETE: the new messageTally runs as a high prio process, not using 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5668
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5669
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5670
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5671
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5672
#ifndef __spyInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5673
    extern void __spyInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5674
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5675
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5676
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5677
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5678
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5679
# ifdef SIGVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5680
    signal(SIGVTALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5681
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5682
#  ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5683
    signal(SIGALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5684
#  else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5685
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5686
     * mhmh - system has neither SIGBTALRM nor SIGALRM ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5687
     * what should we do here ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5688
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5689
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5690
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5691
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5692
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5693
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5694
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5695
    dt.it_value.tv_usec = 1000;   /* 1000 Hz */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5696
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5697
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5698
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5699
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5700
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5701
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5702
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5703
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5704
stopSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5705
    "stop spy timing - disable spy timer.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5706
     OBSOLETE: the new messageTally runs as a high prio process, not using 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5707
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5708
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5709
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5710
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5711
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5712
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5713
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5714
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5715
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5716
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5717
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5718
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5719
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5720
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5721
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5722
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5723
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5725
terminateProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5726
    "terminate a unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5727
     The process has a chance to do some cleanup.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5728
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5729
     WARNING: in order to avoid zombie processes (on unix),
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5730
	      you may have to fetch the processes exitstatus with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5731
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5732
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  5733
    self sendSignal:(self sigTERM) to:processId.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5734
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5735
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5736
    "Modified: / 27.1.1998 / 20:05:47 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5737
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5738
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5739
terminateProcessGroup:processGroupId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5740
    "terminate a unix process group.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5741
     The process has a chance to do some cleanup.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5742
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5743
     WARNING: in order to avoid zombie processes (on unix),
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5744
	      you may have to fetch the processes exitstatus with
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5745
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5746
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  5747
    self sendSignal:(self sigTERM) to:(processGroupId negated).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5748
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5749
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5750
    "Created: / 23.4.1996 / 16:40:34 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5751
    "Modified: / 27.1.1998 / 20:05:59 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5752
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5753
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5754
!UnixOperatingSystem class methodsFor:'ipc support - UNIX'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5755
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5756
makePTYPair
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5757
    "make a pipe, return array with two filedescriptors on success,
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5758
     nil on failure.
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5759
     This is a lowLevel entry, not for public use.
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5760
     See ExternalStream>>makePipe for a more user-friendly, public interface."
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5761
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5762
    |fdS fdM|    
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5763
                
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5764
%{       
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5765
    /*
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5766
     * Find a pseudo tty to use and open both sides.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5767
     *  _fdM receives the master file descriptor while _fdS
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5768
     *  receives the slave.  The master is opened with O_NDELAY as commonly
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5769
     *  needed in daemons such as rlogind and telnetd.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5770
     */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5771
3536
adad0d12c9a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3534
diff changeset
  5772
#ifdef IRIX5
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5773
    int _fdM, _fdS;
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5774
    char *line;
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5775
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5776
    line = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0);
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5777
    if ((line != 0) && (_fdM >= 0)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5778
	_fdS = open(line, O_RDWR);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5779
	if (_fdS < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5780
	    (void)close(_fdM);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5781
	    _fdS = _fdM = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5782
	}
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5783
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5784
	_fdM -1;
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5785
    }
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5786
    if ((_fdM >= 0) && (_fdS >= 0)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5787
	 fdM = __MKSMALLINT(_fdM);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5788
	 fdS = __MKSMALLINT(_fdS);
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5789
    }
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5790
#   define NO_PTY_TEMPL
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5791
#endif /* IRIX5 */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5792
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5793
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5794
#ifdef LINUX
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5795
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5796
#   define PT_INDEX      5
3550
6c3824d07eac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  5797
#   define PTY_1_CHARS  "pqrstuabcdevwxyz"
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5798
#   define PTY_2_CHARS  "0123456789abcdef"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5799
#endif /* LINUX */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5800
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5801
#ifdef solaris
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5802
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5803
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5804
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5805
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5806
#endif /* solaris */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5807
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5808
#ifdef aix
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5809
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5810
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5811
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5812
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5813
#endif /* aix */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5814
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5815
#ifdef next3
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5816
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5817
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5818
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5819
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5820
#endif /* next3 */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5821
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5822
#ifdef hpux
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5823
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5824
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5825
#   define PTY_1_CHARS  "pqrs"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5826
#   define PTY_2_CHARS  "0123456789abcdef"
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5827
#endif /* hpux */
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5828
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5829
#if defined(__osf__)
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5830
#   define PTY_TEMPL    "/dev/ptyXX"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5831
#   define PT_INDEX      5
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5832
#   define PTY_1_CHARS  "pq"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5833
#   define PTY_2_CHARS  "0123456789abcdef"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5834
#endif /* osf1 */
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5835
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5836
#if defined(BSD) && !defined(PTY_TEMPL)
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5837
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5838
#   define PT_INDEX      5
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5839
#   define PTY_1_CHARS  "p"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5840
#   define PTY_2_CHARS  "0123456789abcdefghijklmnopqrstuv"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5841
#endif /* BSD */
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5842
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5843
#ifdef NO_PTY_TEMPL
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5844
# undef PTY_TEMPL
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5845
#endif
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5846
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5847
#ifdef PTY_TEMPL
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5848
#   include <grp.h>
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5849
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5850
# ifdef OLD /* mhmh - suse linux6 places line into rodata ??? */
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5851
    static char line[] = PTY_TEMPL;
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5852
# else
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5853
    char line[128];
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5854
# endif
3575
39723f691a0e hp-cc does not recognize const keyword
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
  5855
    register CONST char *cp1, *cp2;
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5856
    int len, _fdM = -1, _fdS = -1, ttygid;
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5857
    struct group *gr;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5858
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5859
# ifdef OLD
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5860
    len = sizeof(PTY_TEMPL) - 1;
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5861
# else
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5862
    strcpy(line, PTY_TEMPL);
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5863
    len = strlen(line);
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  5864
# endif
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5865
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5866
    if ((gr = getgrnam("tty")) != NULL)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5867
	ttygid = gr->gr_gid;
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5868
    else
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5869
	ttygid = -1;
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5870
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5871
    for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5872
	line[len-2] = * cp1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5873
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5874
	for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5875
	    line[PT_INDEX] = 'p';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5876
	    line[len-1] = *cp2;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5877
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5878
	    if ((_fdM = open(line, O_RDWR, 0)) < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5879
		if (errno == ENOENT) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5880
		    _fdM = _fdS = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5881
		    goto getOutOfHere; /* out of ptys */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5882
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5883
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5884
		line[PT_INDEX] = 't';
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5885
		(void) chown( line, getuid(), ttygid );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5886
		(void) chmod( line, S_IRUSR|S_IWUSR|S_IWGRP );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5887
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5888
		if( (_fdS = open(line, O_RDWR, 0)) >= 0 ) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5889
		    goto getOutOfHere;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5890
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5891
		(void) close( _fdM );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5892
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5893
	}
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5894
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5895
  getOutOfHere: ;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5896
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5897
    if ((_fdM >= 0) && (_fdS >= 0)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5898
	 fdM = __MKSMALLINT(_fdM);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5899
	 fdS = __MKSMALLINT(_fdS);
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5900
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5901
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5902
#endif /* PTY_TEMPL */
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5903
#undef NO_PTY_TEMPL
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  5904
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5905
%}.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5906
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5907
    fdM notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5908
	^ Array with:fdM with:fdS.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5909
    ].
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5910
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5911
    ^ nil
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5912
!
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5913
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5914
makePipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5915
    "make a pipe, return array with two filedescriptors on success,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5916
     nil on failure.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5917
     This is a lowLevel entry, not for public use.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5918
     See ExternalStream>>makePipe for a more user-friendly, public interface."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5919
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5920
    |fd1 fd2|    
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5921
                
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5922
%{       
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5923
     int fds[2];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5924
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5925
     if (pipe(fds) < 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5926
	@global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5927
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5928
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5929
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5930
     fd1 = __MKSMALLINT(fds[0]);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5931
     fd2 = __MKSMALLINT(fds[1]);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5932
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5933
    fd1 notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5934
	^ Array with:fd1 with:fd2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5935
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5936
    ^ nil
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5937
!
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5938
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5939
setWindowSizeOnFileDescriptor:fd width:w height:h
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5940
    "emit a TIOCSWINSZ ioctl; (req'd for terminal emulators)"
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5941
%{
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5942
#ifdef TIOCSWINSZ
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5943
    struct winsize wsize;
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5944
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5945
    if (__isSmallInteger(fd)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5946
     && __isSmallInteger(w)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5947
     && __isSmallInteger(h)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5948
	wsize.ws_row = (unsigned short)__intVal(h);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5949
	wsize.ws_col = (unsigned short)__intVal(w);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5950
	if (ioctl(__intVal(fd), TIOCSWINSZ, (char *)&wsize) >= 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5951
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5952
	}
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5953
    }
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5954
#endif
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5955
%}.
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  5956
    ^ false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5957
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5958
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5959
!UnixOperatingSystem class methodsFor:'misc'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5960
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5961
closePid:pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5962
    "free pid resource"
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5963
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5964
    ^ true.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5965
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5966
    "Created: / 28.1.1998 / 14:23:04 / md"
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5967
    "Modified: / 28.1.1998 / 14:27:18 / md"
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5968
    "Modified: / 5.6.1998 / 18:38:46 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5969
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5970
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5971
slowFork:aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5972
    "set/clear the `avoid-fork-if-possible-because-its-slow' flag.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5973
     Only used internally on SYSV3 systems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5974
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5975
    SlowFork := aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5976
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5977
    "Modified: 22.4.1996 / 13:13:09 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5978
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5979
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5980
!UnixOperatingSystem class methodsFor:'os queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5981
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5982
executableFileExtensions
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5983
    "return a collection of extensions for executable program files.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5984
     Only req'd for msdos like systems ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5985
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5986
    ^ #('')
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5987
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5988
    "Created: / 2.5.1997 / 11:42:29 / cg"
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5989
    "Modified: / 5.6.1998 / 18:38:52 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5990
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5991
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5992
getDomainName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5993
    "return the domain this host is in.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5994
     Notice:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  5995
	not all systems support this; on some, 'unknown' is returned."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5996
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5997
    |name idx hostName|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5998
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5999
    DomainName notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6000
	^ DomainName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6001
    ].
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6002
    name := self primGetDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6003
    name isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6004
	"/ fallBack
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6005
	name := self getEnvironment:'DOMAIN'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6006
	name isNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6007
	    name := self getCommandOutputFrom:'domainname'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6008
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6009
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6010
    name isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6011
	"/ sometimes, we can extract the domainName from the hostName ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6012
	hostName := self getHostName.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6013
	hostName notNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6014
	    idx := hostName indexOf:$..
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6015
	    idx ~~ 0 ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6016
		name := hostName copyFrom:idx+1.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6017
	    ]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6018
	]. 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6019
	name isNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6020
	    'UnixOperatingSystem [warning]: cannot find out domainname' errorPrintCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6021
	    name := 'unknown'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6022
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6023
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6024
    DomainName := name.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6025
    ^ name
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6026
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6027
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6028
     OperatingSystem getDomainName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6029
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6030
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6031
    "Modified: 26.4.1996 / 10:04:54 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6032
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6033
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6034
getEnvironment:aStringOrSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6035
    "get an environment string"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6036
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6037
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6038
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6039
    char *env;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6040
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6041
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6042
    if (__isString(aStringOrSymbol) || __isSymbol(aStringOrSymbol)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6043
	env =  getenv(__stringVal(aStringOrSymbol));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6044
	if (env) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6045
	    RETURN ( __MKSTRING(env) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6046
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6047
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6048
    }
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6049
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  6050
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6051
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6052
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6053
     OperatingSystem getEnvironment:'LANG'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6054
     OperatingSystem getEnvironment:'LOGIN'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6055
     OperatingSystem getEnvironment:'HOME'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6056
     OperatingSystem getEnvironment:'NNTPSERVER'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6057
     OperatingSystem getEnvironment:'MAIL'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6058
     OperatingSystem getEnvironment:'PATH'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6059
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6060
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6061
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6062
getHostName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6063
    "return the hostname we are running on - if there is
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6064
     a HOST environment variable, we are much faster here ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6065
     Notice:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6066
	not all systems support this; on some, 'unknown' is returned."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6067
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6068
    |name idx|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6069
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6070
    HostName notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6071
	^ HostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6072
    ].
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6073
    name := self primGetHostName.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  6074
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6075
    name isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6076
	"/ fallBack
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6077
	name := self getEnvironment:'HOST'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6078
	name isNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6079
	    name := self getCommandOutputFrom:'hostname'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6080
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6081
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6082
    name isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6083
	'UnixOperatingSystem [warning]: cannot find out hostname' errorPrintCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6084
	name := 'unknown'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6085
    ] ifFalse:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6086
	"/ on some systems, the hostname already contains the domain.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6087
	"/ decompose it here.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6088
	idx := name indexOf:$..
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6089
	idx ~~ 0 ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6090
	    DomainName := name copyFrom:(idx+1).
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6091
	    name := name copyTo:(idx-1).
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6092
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6093
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6094
    HostName := name.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6095
    ^ name
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6096
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6097
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6098
     OperatingSystem getHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6099
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6100
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6101
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6102
getLocaleInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6103
    "return a dictionary filled with values from the locale information;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6104
     Not all fields may be present, depending on the OS's setup and capabilities.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6105
     Possible fields are:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6106
	decimalPoint                    <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6107
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6108
	thousandsSep                    <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6109
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6110
	internationalCurrencySymbol     <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6111
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6112
	currencySymbol                  <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6113
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6114
	monetaryDecimalPoint            <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6115
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6116
	monetaryThousandsSeparator      <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6117
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6118
	positiveSign                    <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6119
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6120
	negativeSign                    <String>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6121
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6122
	internationalFractionalDigits   <Integer>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6123
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6124
	fractionalDigits                <Integer>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6125
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6126
	positiveSignPrecedesCurrencySymbol      <Boolean>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6127
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6128
	negativeSignPrecedesCurrencySymbol      <Boolean>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6129
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6130
	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6131
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6132
	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6133
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6134
	positiveSignPosition                            <Symbol>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6135
							one of: #parenthesesAround, 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6136
								#signPrecedes, 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6137
								#signSuceeds, 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6138
								#signPrecedesCurrencySymbol,
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6139
								#signSuceedsCurrencySymbol
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6140
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6141
	negativeSignPosition                            <like above>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6142
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6143
     it is up to the application to deal with undefined values.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6144
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6145
     Notice, that (for now), the system does not use this information;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6146
     it should be used by applications as required.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6147
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6148
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6149
    |info val|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6150
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6151
    LocaleInfo notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6152
	"/ return the internal info; useful on systems which do not
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6153
	"/ support this.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6154
	^ LocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6155
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6156
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6157
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6158
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6159
    char *decimalPoint;         /* something like "." (US) or "," (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6160
    char *thousandsSep;         /* something like "," (US) or "." (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6161
    char *intCurrencySymbol;    /* international currency symbol; something like "USD "  "DM  " */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6162
    char *currencySymbol;       /* local currency symbol;         something like "USD "  "DM  " */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6163
    char *monDecimalPoint;      /* money: decimal point */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6164
    char *monThousandsSep;      /* money: thousands sep */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6165
    char *positiveSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6166
    char *negativeSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6167
    int   intFractDigits;       /* money: international digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6168
    int   fractDigits;          /* money: local digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6169
    int   csPosPrecedes;        /* money: 1 if currency symbol precedes a positive value; 0 if it sceeds */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6170
    int   csNegPrecedes;        /* money: 1 if currency symbol precedes a negative value; 0 if it sceeds */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6171
    int   csPosSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a positive value; 0 if no space */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6172
    int   csNegSepBySpace;      /* money: 1 if currency symbol should be separated by a space from a negative value; 0 if no space */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6173
    int   csPosSignPosition;    /* money: 0: ()'s around the value & currency symbol */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6174
    int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6175
				/*        2: sign succeeds the value & currency symbol */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6176
				/*        3: sign immediately precedes the currency symbol */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6177
				/*        4: sign immediately suceeds the currency symbol */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6178
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6179
#if defined(HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6180
    struct lconv *conf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6181
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6182
    conf = localeconv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6183
    if (conf) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6184
	decimalPoint = conf->decimal_point;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6185
	thousandsSep = conf->thousands_sep;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6186
	intCurrencySymbol = conf->int_curr_symbol;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6187
	currencySymbol = conf->currency_symbol;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6188
	monDecimalPoint = conf->mon_decimal_point;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6189
	monThousandsSep = conf->mon_thousands_sep;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6190
	positiveSign = conf->positive_sign;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6191
	negativeSign = conf->negative_sign;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6192
	intFractDigits = conf->int_frac_digits;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6193
	fractDigits = conf->frac_digits;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6194
	csPosPrecedes = conf->p_cs_precedes; 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6195
	csNegPrecedes = conf->n_cs_precedes; 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6196
	csPosSepBySpace = conf->p_sep_by_space; 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6197
	csNegSepBySpace = conf->n_sep_by_space; 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6198
	csPosSignPosition = conf->p_sign_posn;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6199
	csNegSignPosition = conf->n_sign_posn;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6200
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6201
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6202
    decimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6203
    thousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6204
    intCurrencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6205
    currencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6206
    monDecimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6207
    monThousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6208
    positiveSign =  (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6209
    negativeSign =(char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6210
    intFractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6211
    fractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6212
    csPosPrecedes = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6213
    csNegPrecedes = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6214
    csPosSepBySpace = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6215
    csNegSepBySpace = -1; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6216
    csPosSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6217
    csNegSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6218
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6219
    if (decimalPoint) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6220
	val = __MKSTRING(decimalPoint);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6221
	__AT_PUT_(info, @symbol(decimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6222
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6223
    if (thousandsSep) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6224
	val = __MKSTRING(thousandsSep);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6225
	__AT_PUT_(info, @symbol(thousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6226
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6227
    if (intCurrencySymbol) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6228
	val = __MKSTRING(intCurrencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6229
	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6230
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6231
    if (currencySymbol) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6232
	val = __MKSTRING(currencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6233
	__AT_PUT_(info, @symbol(currencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6234
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6235
    if (monDecimalPoint) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6236
	val = __MKSTRING(monDecimalPoint);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6237
	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6238
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6239
    if (monThousandsSep) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6240
	val = __MKSTRING(monThousandsSep);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6241
	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6242
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6243
    if (positiveSign) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6244
	val = __MKSTRING(positiveSign);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6245
	__AT_PUT_(info, @symbol(positiveSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6246
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6247
    if (negativeSign) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6248
	val = __MKSTRING(negativeSign);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6249
	__AT_PUT_(info, @symbol(negativeSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6250
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6251
    if (intFractDigits >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6252
	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __MKSMALLINT(intFractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6253
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6254
    if (fractDigits >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6255
	__AT_PUT_(info, @symbol(fractionalDigits),  __MKSMALLINT(fractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6256
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6257
    if (csPosPrecedes >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6258
	if (csPosPrecedes == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6259
	    val = false;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6260
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6261
	    val = true;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6262
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6263
	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6264
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6265
    if (csNegPrecedes >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6266
	if (csNegPrecedes == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6267
	    val = false;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6268
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6269
	    val = true;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6270
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6271
	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6272
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6273
    if (csPosSepBySpace >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6274
	if (csPosSepBySpace == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6275
	    val = false;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6276
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6277
	    val = true;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6278
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6279
	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6280
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6281
    if (csNegSepBySpace >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6282
	if (csNegSepBySpace == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6283
	    val = false;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6284
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6285
	    val = true;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6286
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6287
	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6288
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6289
    switch (csPosSignPosition) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6290
	case 0:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6291
	    val = @symbol(parenthesesAround);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6292
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6293
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6294
	case 1:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6295
	    val = @symbol(signPrecedes);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6296
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6297
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6298
	case 2:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6299
	    val = @symbol(signSuceeds);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6300
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6301
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6302
	case 3:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6303
	    val = @symbol(signPrecedesCurrencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6304
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6305
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6306
	case 4:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6307
	    val = @symbol(signSuceedsCurrencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6308
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6309
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6310
	default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6311
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6312
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6313
    if (val != nil) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6314
	__AT_PUT_(info, @symbol(positiveSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6315
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6316
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6317
    switch (csNegSignPosition) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6318
	case 0:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6319
	    val = @symbol(parenthesesAround);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6320
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6321
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6322
	case 1:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6323
	    val = @symbol(signPrecedes);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6324
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6325
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6326
	case 2:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6327
	    val = @symbol(signSuceeds);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6328
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6329
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6330
	case 3:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6331
	    val = @symbol(signPrecedesCurrencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6332
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6333
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6334
	case 4:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6335
	    val = @symbol(signSuceedsCurrencySymbol);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6336
	    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6337
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6338
	default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6339
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6340
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6341
    if (val != nil) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6342
	__AT_PUT_(info, @symbol(negativeSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6343
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6344
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6345
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6346
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6347
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6348
     OperatingSystem getLocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6349
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6350
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6351
    "Created: 23.12.1995 / 14:19:20 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6352
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6353
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6354
getProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6355
    "return the (unix-)processId"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6356
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6357
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6358
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6359
    int pid = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6360
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6361
    pid = getpid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6362
    RETURN ( __MKSMALLINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6363
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6364
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6365
     OperatingSystem getProcessId
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6366
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6367
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6368
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6369
getSystemID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6370
    "if supported by the OS, return the systemID;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6371
     a unique per machine identification.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6372
     WARNING:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6373
	not all systems support this; on some, 'unknown' is returned."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6374
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6375
%{  /* NO_CONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6376
#if defined(IRIX5) && !defined(HAS_GETHOSTID)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6377
    char idBuffer[MAXSYSIDSIZE];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6378
    int retVal;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6379
    OBJ arr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6380
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6381
    if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6382
	arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6383
	bcopy(idBuffer, __ByteArrayInstPtr(arr)->ba_element, MAXSYSIDSIZE);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6384
	RETURN (arr);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6385
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6386
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6387
#if defined(HAS_GETHOSTID)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6388
    int runningId;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6389
    OBJ arr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6390
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6391
    runningId = gethostid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6392
    arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6393
    *(int *)(__ByteArrayInstPtr(arr)->ba_element) = runningId;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6394
    RETURN (arr);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6395
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6396
#if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6397
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6398
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6399
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6400
	buffer[0] = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6401
	if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6402
	    buffer[127] = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6403
	    if (strlen(buffer) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6404
		RETURN(__MKSTRING(buffer));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6405
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6406
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6407
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6408
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6409
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6410
    ^ 'unknown'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6411
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6412
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6413
     OperatingSystem getSystemID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6414
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6415
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6416
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6417
getSystemInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6418
    "return info on the system weare running on.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6419
     If the system supports the uname system call, that info is returned;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6420
     otherwise, some simulated info is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6421
 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6422
     WARNING:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6423
       Do not depend on the amount and contents of the returned information, some
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6424
       systems may return more/less than others. Also, the contents depends on the
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6425
       OS, for example, linux returns 'ix86', while WIN32 returns 'x86'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6426
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6427
       This method is mainly provided to augment error reports with some system
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6428
       information. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6429
       (in case of system/version specific OS errors, conditional workarounds and patches
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6430
	may be based upon this info).
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6431
       Also, applications could enable/disable buffering or otherwise reduce
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6432
       their memory usage depending upon the amount of memory installed.
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6433
       Your application may make use of available information for tuning,
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6434
       but should NEVER DEPEND upon this in any way.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6435
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6436
     The returned info may (or may not) contain:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6437
	#system -> some operating system identification (irix, Linux, nt, win32s ...) 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6438
	#version -> OS version (some os version identification)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6439
	#release -> OS release (3.5, 1.2.1 ...)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6440
	#node   -> some host identification (hostname)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6441
	#domain  -> domain name (hosts domain)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6442
	#machine -> type of CPU (i586, mips ...)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6443
     
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6444
     those are currently returned on some machines (no warranty)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6445
     linux:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6446
	#totalRam         -> total amount of memory available
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6447
	#sharedRam        -> amount of memory which is shared among processes
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6448
			     (i.e. shared code)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6449
	#bufferRam        -> amount used for buffers
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6450
	#swapSize         -> total size of swap space
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6451
	#freeSwap         -> free amount in swapSpace
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6452
	#extendedInstructions -> extended instruction set info
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6453
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6454
     osf:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6455
	#physicalRam      -> total amount of physical memory
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6456
	#cpuType          -> type of cpu (more detailed than machine)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6457
	#numberOfCPUs     -> number of cpus in box
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6458
        
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6459
     solaris:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6460
	#physicalRam      -> total amount of physical memory
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6461
	#availableRam     -> total available amount of physical memory (i.e. unused ram)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6462
	#freeRam          -> amount of free memory
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6463
	#numberOfCPUs     -> number of cpus in box (online CPUS)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6464
	[#dCacheSize]     -> bytes in data cache (only available on some solaris versions)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6465
	[#iCacheSize]     -> bytes in data cache (only available on some solaris versions)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6466
	[#instructionSets]-> instruction sets available (only available on some solaris versions)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6467
	[#platform]       -> platform name (only available on some solaris versions)
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6468
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6469
     hpux:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6470
	#physicalRam      -> total amount of physical memory in box
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6471
	#activeRealMemory -> ? - read pstat documentation
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6472
	#activeVirtualRam -> ? - read pstat documentation
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6473
	#freeMemory       -> ? - read pstat documentation
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6474
	#realMemory       -> ? (amount of memory left to user programs)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6475
	#virtualRam       -> ? - read pstat documentation
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6476
    "
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6477
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6478
    |sys node rel ver mach dom mtyp brel info arch cpuType cpuSpeed
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6479
     physicalRam availableRam totalRam sharedRam bufferRam swapSize freeSwap
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6480
     numberOfCPUs pageSize physicalPages availablePages dCacheSize iCacheSize
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6481
     virtualRam activeVirtualRam realMemory activeRealMemory freeMemory
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6482
     instructionSets extendedInstructions platform|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6483
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6484
%{  /* STACK: 4096 */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6485
#ifdef LINUX
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  6486
# ifdef ELF /* old a.out unixes do not have this ... */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6487
    /* 
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6488
     * additional info available ...
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6489
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6490
    struct sysinfo infoBuffer;
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6491
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6492
    if (sysinfo(&infoBuffer) >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6493
	totalRam   = __MKUINT(infoBuffer.totalram);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6494
	sharedRam = __MKUINT(infoBuffer.sharedram);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6495
	bufferRam = __MKUINT(infoBuffer.bufferram);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6496
	swapSize  = __MKUINT(infoBuffer.totalswap);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6497
	freeSwap  = __MKUINT(infoBuffer.freeswap);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6498
    }
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  6499
# endif
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6500
#endif /* LINUX */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6501
4088
622551d3c0d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  6502
#if defined(hpux) && !defined(__GNUC__)
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6503
# include <sys/pstat.h>
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6504
    struct pst_static stat_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6505
    struct pst_dynamic dynam_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6506
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6507
    pstat(PSTAT_STATIC,&stat_buf,sizeof(stat_buf),0,0);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6508
    pstat(PSTAT_DYNAMIC,&dynam_buf,sizeof(dynam_buf),0,0);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6509
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6510
    physicalRam        = __MKUINT(stat_buf.physical_memory/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6511
    virtualRam         = __MKUINT(dynam_buf.psd_vm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6512
    activeVirtualRam   = __MKUINT(dynam_buf.psd_avm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6513
    realMemory         = __MKUINT(dynam_buf.psd_rm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6514
    activeRealMemory   = __MKUINT(dynam_buf.psd_arm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6515
    freeMemory         = __MKUINT(dynam_buf.psd_free/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6516
#endif
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  6517
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6518
#if defined(HAS_UNAME)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6519
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6520
	struct utsname ubuff;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6521
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6522
	if (uname(&ubuff) >= 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6523
	    sys  = __MKSTRING(ubuff.sysname);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6524
	    node = __MKSTRING(ubuff.nodename);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6525
	    rel  = __MKSTRING(ubuff.release);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6526
	    ver  = __MKSTRING(ubuff.version);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6527
	    mach = __MKSTRING(ubuff.machine);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6528
# ifdef HAS_UTS_DOMAINNAME
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6529
	    dom  = __MKSTRING(ubuff.domainname);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6530
# endif /* no HAS_UTS_DOMAINNAME */
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6531
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6532
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6533
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6534
#else /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6535
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6536
    /*
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6537
     * use fallBack code below
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6538
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6539
#endif /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6540
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6541
#if defined(HAS_SYSINFO)
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6542
# if defined(SI_ARCHITECTURE)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6543
    if (arch == nil) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6544
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6545
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6546
	if (sysinfo(SI_ARCHITECTURE, buffer, sizeof(buffer))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6547
	    arch = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6548
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6549
    }
4923
1cacdcfc82c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4922
diff changeset
  6550
# endif /* SI_ARCHITECTURE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6551
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6552
# if defined(SI_ISALIST)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6553
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6554
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6555
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6556
	if (sysinfo(SI_ISALIST, buffer, sizeof(buffer))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6557
	    instructionSets = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6558
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6559
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6560
# endif /* SI_ISALIST */
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6561
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6562
# if defined(SI_PLATFORM)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6563
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6564
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6565
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6566
	if (sysinfo(SI_PLATFORM, buffer, sizeof(buffer))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6567
	    platform = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6568
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6569
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6570
# endif /* SI_PLATFORM */
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6571
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6572
# if defined(SI_RELEASE)
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6573
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6574
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6575
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6576
	if (sysinfo(SI_RELEASE, buffer, sizeof(buffer))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6577
	    rel = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6578
	}
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6579
    }
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  6580
# endif /* SI_RELEASE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6581
#endif /* HAS_SYSINFO */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6582
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6583
#if defined(HAS_GETDOMAINNAME)
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6584
    if (dom == nil) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6585
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6586
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6587
	if (getdomainname(buffer, sizeof(buffer)) == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6588
	    dom = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6589
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6590
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6591
#endif /* HAS_GETDOMAINNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  6592
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6593
#if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6594
# ifdef _SC_NPROCESSORS_ONLN
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6595
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6596
	long val;
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6597
 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6598
	val = sysconf(_SC_NPROCESSORS_ONLN);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6599
	if (val > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6600
	    numberOfCPUs = __MKINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6601
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6602
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6603
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6604
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6605
# if defined(_SC_PAGESIZE)
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6606
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6607
	long val;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6608
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6609
	val = sysconf(_SC_PAGESIZE);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6610
	if (val != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6611
	    pageSize = __MKUINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6612
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6613
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6614
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6615
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6616
# if defined(_SC_PHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6617
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6618
	long val;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6619
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6620
	val = sysconf(_SC_PHYS_PAGES);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6621
	if (val != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6622
	    physicalPages = __MKUINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6623
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6624
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6625
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6626
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6627
# if defined(_SC_AVPHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  6628
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6629
	long val;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6630
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6631
	val = sysconf(_SC_AVPHYS_PAGES);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6632
	if (val != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6633
	    availablePages = __MKUINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6634
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6635
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6636
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6637
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6638
# if defined(_SC_ICACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6639
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6640
	long val;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6641
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6642
	val = sysconf(_SC_ICACHE_SZ);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6643
	if (val != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6644
	    iCacheSize = __MKUINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6645
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6646
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6647
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  6648
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6649
# if defined(_SC_DCACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6650
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6651
	long val;
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6652
 
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6653
	val = sysconf(_SC_DCACHE_SZ);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6654
	if (val != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6655
	    dCacheSize = __MKUINT(val);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6656
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6657
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6658
# endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6659
#endif /* HAS_SYSCONF */
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  6660
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6661
#if defined(HAS_GETSYSINFO)
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6662
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6663
	INT index;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6664
	int retInt32 = 0;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6665
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6666
# if defined(GSI_CPU)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6667
	index = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6668
	if (getsysinfo(GSI_CPU, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6669
	    switch (retInt32) {
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6670
#  ifdef VAX_780
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6671
		case VAX_780:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6672
		    cpuType = __MKSTRING("VAX_780");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6673
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6674
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6675
#  ifdef VAX_750
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6676
		case VAX_750:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6677
		    cpuType = __MKSTRING("VAX_750");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6678
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6679
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6680
#  ifdef VAX_730
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6681
		case VAX_730:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6682
		    cpuType = __MKSTRING("VAX_730");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6683
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6684
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6685
#  ifdef VAX_8600
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6686
		case VAX_8600:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6687
		    cpuType = __MKSTRING("VAX_8600");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6688
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6689
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6690
#  ifdef VAX_8200
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6691
		case VAX_8200:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6692
		    cpuType = __MKSTRING("VAX_8200");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6693
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6694
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6695
#  ifdef VAX_8800
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6696
		case VAX_8800:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6697
		    cpuType = __MKSTRING("VAX_8800");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6698
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6699
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6700
#  ifdef MVAX_I
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6701
		case MVAX_I:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6702
		    cpuType = __MKSTRING("MVAX_I");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6703
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6704
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6705
#  ifdef MVAX_II
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6706
		case MVAX_II:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6707
		    cpuType = __MKSTRING("MVAX_II");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6708
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6709
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6710
#  ifdef V_VAX
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6711
		case V_VAX:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6712
		    cpuType = __MKSTRING("V_VAX");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6713
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6714
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6715
#  ifdef VAX_3600
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6716
		case VAX_3600:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6717
		    cpuType = __MKSTRING("VAX_3600");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6718
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6719
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6720
#  ifdef VAX_6200
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6721
		case VAX_6200:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6722
		    cpuType = __MKSTRING("VAX_6200");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6723
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6724
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6725
#  ifdef VAX_3400
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6726
		case VAX_3400:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6727
		    cpuType = __MKSTRING("VAX_3400");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6728
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6729
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6730
#  ifdef C_VAXSTAR
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6731
		case C_VAXSTAR:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6732
		    cpuType = __MKSTRING("C_VAXSTAR");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6733
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6734
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6735
#  ifdef VAX_60
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6736
		case VAX_60:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6737
		    cpuType = __MKSTRING("VAX_60");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6738
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6739
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6740
#  ifdef VAX_3900
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6741
		case VAX_3900:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6742
		    cpuType = __MKSTRING("VAX_3900");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6743
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6744
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6745
#  ifdef DS_3100
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6746
		case DS_3100:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6747
		    cpuType = __MKSTRING("DS_3100");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6748
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6749
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6750
#  ifdef VAX_8820
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6751
		case VAX_8820:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6752
		    cpuType = __MKSTRING("VAX_8820");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6753
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6754
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6755
#  ifdef DS_5400
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6756
		case DS_5400:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6757
		    cpuType = __MKSTRING("DS_5400");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6758
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6759
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6760
#  ifdef DS_5800
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6761
		case DS_5800:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6762
		    cpuType = __MKSTRING("DS_5800");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6763
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6764
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6765
#  ifdef DS_5000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6766
		case DS_5000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6767
		    cpuType = __MKSTRING("DS_5000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6768
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6769
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6770
#  ifdef DS_CMAX
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6771
		case DS_CMAX:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6772
		    cpuType = __MKSTRING("DS_CMAX");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6773
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6774
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6775
#  ifdef VAX_6400
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6776
		case VAX_6400:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6777
		    cpuType = __MKSTRING("VAX_6400");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6778
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6779
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6780
#  ifdef VAXSTAR
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6781
		case VAXSTAR:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6782
		    cpuType = __MKSTRING("VAXSTAR");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6783
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6784
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6785
#  ifdef DS_5500
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6786
		case DS_5500:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6787
		    cpuType = __MKSTRING("DS_5500");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6788
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6789
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6790
#  ifdef DS_5100
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6791
		case DS_5100:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6792
		    cpuType = __MKSTRING("DS_5100");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6793
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6794
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6795
#  ifdef VAX_9000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6796
		case VAX_9000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6797
		    cpuType = __MKSTRING("VAX_9000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6798
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6799
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6800
#  ifdef DS_500_100
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6801
		case DS_500_100:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6802
		    cpuType = __MKSTRING("DS_500_100");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6803
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6804
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6805
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6806
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6807
#  ifdef ALPHA_ADU
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6808
		case ALPHA_ADU:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6809
		    cpuType = __MKSTRING("ALPHA_ADU");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6810
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6811
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6812
#  ifdef DEC_4000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6813
		case DEC_4000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6814
		    cpuType = __MKSTRING("DEC_4000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6815
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6816
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6817
#  ifdef DEC_3000_500
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6818
		case DEC_3000_500:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6819
		    cpuType = __MKSTRING("DEC_3000_500");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6820
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6821
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6822
#  ifdef DEC_7000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6823
		case DEC_7000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6824
		    cpuType = __MKSTRING("DEC_7000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6825
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6826
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6827
#  ifdef DS_5000_300
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6828
		case DS_5000_300:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6829
		    cpuType = __MKSTRING("DS_5000_300");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6830
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6831
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6832
#  ifdef DEC_3000_300
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6833
		case DEC_3000_300:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6834
		    cpuType = __MKSTRING("DEC_3000_300");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6835
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6836
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6837
#  ifdef DEC_2000_300
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6838
		case DEC_2000_300:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6839
		    cpuType = __MKSTRING("DEC_2000_300");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6840
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6841
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6842
#  ifdef DEC_2100_A500
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6843
		case DEC_2100_A500:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6844
		    cpuType = __MKSTRING("DEC_2100_A500");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6845
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6846
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6847
#  ifdef DEC_2100_A50
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6848
		case DEC_2100_A50:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6849
		    cpuType = __MKSTRING("DEC_2100_A50");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6850
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6851
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6852
#  ifdef ALPHA_KN20AA
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6853
		case ALPHA_KN20AA:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6854
		    cpuType = __MKSTRING("ALPHA_KN20AA");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6855
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6856
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6857
#  ifdef DEC_21000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6858
		case DEC_21000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6859
		    cpuType = __MKSTRING("DEC_21000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6860
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6861
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6862
#  ifdef DEC_AXPVME_64
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6863
		case DEC_AXPVME_64:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6864
		    cpuType = __MKSTRING("DEC_AXPVME_64");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6865
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6866
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6867
#  ifdef DEC_2100_C500
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6868
		case DEC_2100_C500:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6869
		    cpuType = __MKSTRING("DEC_2100_C500");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6870
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6871
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6872
#  ifdef DEC_AXPPCI_33
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6873
		case DEC_AXPPCI_33:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6874
		    cpuType = __MKSTRING("DEC_AXPPCI_33");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6875
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6876
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6877
#  ifdef DEC_1000
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6878
		case DEC_1000:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6879
		    cpuType = __MKSTRING("DEC_1000");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6880
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6881
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6882
#  ifdef EB64_PLUS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6883
		case EB64_PLUS:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6884
		    cpuType = __MKSTRING("EB64_PLUS");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6885
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6886
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6887
#  ifdef LCA_EB66
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6888
		case LCA_EB66:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6889
		    cpuType = __MKSTRING("LCA_EB66");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6890
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6891
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6892
#  ifdef ALPHA_EB164
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6893
		case ALPHA_EB164:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6894
		    cpuType = __MKSTRING("ALPHA_EB164");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6895
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6896
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6897
#  ifdef DEC_EV45_PBP
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6898
		case DEC_EV45_PBP:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6899
		    cpuType = __MKSTRING("DEC_EV45_PBP");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6900
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6901
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6902
#  ifdef DEC_1000A
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6903
		case DEC_1000A:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6904
		    cpuType = __MKSTRING("DEC_1000A");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6905
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6906
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6907
#  ifdef DEC_4100
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6908
		case DEC_4100:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6909
		    cpuType = __MKSTRING("DEC_4100");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6910
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6911
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6912
#  ifdef DEC_ALPHAVME_224
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6913
		case DEC_ALPHAVME_224:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6914
		    cpuType = __MKSTRING("DEC_ALPHAVME_224");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6915
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6916
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6917
#  ifdef DEC_1000_5
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6918
		case DEC_1000_5:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6919
		    cpuType = __MKSTRING("DEC_1000_5");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6920
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6921
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6922
#  ifdef DEC_1000A_5
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6923
		case DEC_1000A_5:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6924
		    cpuType = __MKSTRING("DEC_1000A_5");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6925
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6926
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6927
#  ifdef DEC_EV56_PBP
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6928
		case DEC_EV56_PBP:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6929
		    cpuType = __MKSTRING("DEC_EV56_PBP");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6930
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6931
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6932
#  ifdef ALPHABOOK
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6933
		case ALPHABOOK:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6934
		    cpuType = __MKSTRING("ALPHABOOK");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6935
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6936
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6937
#  ifdef DEC_ALPHAVME_320
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6938
		case DEC_ALPHAVME_320:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6939
		    cpuType = __MKSTRING("DEC_ALPHAVME_320");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6940
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6941
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6942
#  ifdef DEC_550
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6943
		case DEC_550:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6944
		    cpuType = __MKSTRING("DEC_550");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6945
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6946
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6947
#  ifdef DEC_6600
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6948
		case DEC_6600:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6949
		    cpuType = __MKSTRING("DEC_6600");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6950
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6951
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6952
#  ifdef UNKN_SYSTEM
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6953
		case UNKN_SYSTEM:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6954
		    cpuType = __MKSTRING("UNKN_SYSTEM");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6955
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6956
#  endif
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6957
		default:
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6958
		    cpuType = __MKSTRING("OTHER_DEC_SYSTEM");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6959
		    break;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6960
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6961
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6962
# endif /* GSI_CPU */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6963
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6964
# if defined(GSI_CPU_INFO)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6965
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6966
	 * stupid: OSF1 pre V4.0 has no mhz, but V4.0 has it.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6967
	 * use the GSI_PLATFORM_NAME as a hint - it is only defined in
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6968
	 * V4.0 and higher ... (sigh)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6969
	 */
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  6970
#  if defined GSI_PLATFORM_NAME
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6971
	{
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6972
	    struct cpu_info cpuInfo;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6973
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6974
	    index = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6975
	    if (getsysinfo(GSI_CPU_INFO, &cpuInfo, sizeof(cpuInfo), &index, NULL) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6976
		cpuSpeed   = __MKUINT(cpuInfo.mhz);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6977
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6978
	}
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  6979
#  endif
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6980
# endif /* GSI_CPU_INFO */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6981
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6982
# if defined(GSI_CPUS_IN_BOX)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6983
	index = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6984
	if (getsysinfo(GSI_CPUS_IN_BOX, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6985
	    numberOfCPUs   = __MKUINT(retInt32);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6986
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6987
# endif /* GSI_CPUS_IN_BOX */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6988
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6989
# if defined(GSI_PHYSMEM)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6990
	index = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6991
	if (getsysinfo(GSI_PHYSMEM, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6992
	    INT bytes = retInt32 * 1024;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6993
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6994
	    physicalRam   = __MKUINT(bytes);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  6995
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6996
# endif /* GSI_PHYSMEM */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  6997
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6998
# if defined(GSI_PLATFORM_NAME) && (!defined(HAS_SYSINFO) || !defined(SI_PLATFORM))
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  6999
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7000
	char buffer[128];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7001
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7002
	index = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7003
	if (getsysinfo(GSI_PLATFORM_NAME, buffer, sizeof(buffer), &index, NULL) > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7004
	    platform = __MKSTRING(buffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7005
	}
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7006
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7007
# endif /* GSI_PLATFORM_NAME */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7008
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7009
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7010
#endif /* HAS_GETSYSINFO */
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7011
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7012
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7013
	extern OBJ __getInstructionSetInfo();
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7014
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7015
	extendedInstructions = __getInstructionSetInfo();
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7016
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7017
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7018
    sys isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7019
	sys := self getSystemType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7020
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7021
    node isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7022
	node := self getHostName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7023
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7024
    dom isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7025
	dom := self getDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7026
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7027
    mach isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7028
	mach := self getCPUType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7029
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7030
    arch isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7031
	arch := sys.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7032
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7033
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7034
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7035
    info at:#system put:sys.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7036
    info at:#node put:node.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7037
    rel notNil ifTrue:[info at:#release put:rel].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7038
    ver notNil ifTrue:[info at:#version put:ver].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7039
    mach notNil ifTrue:[info at:#machine put:mach].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7040
    arch notNil ifTrue:[info at:#architecture put:arch].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7041
    dom notNil ifTrue:[info at:#domain put:dom].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7042
    (pageSize notNil and:[physicalPages notNil]) ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7043
	physicalRam := pageSize * physicalPages. "/ done here - could be largeInt.
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7044
    ].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7045
    physicalRam notNil ifTrue:[info at:#physicalRam put:physicalRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7046
    (pageSize notNil and:[availablePages notNil]) ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7047
	availableRam := pageSize * availablePages. "/ done here - could be largeInt.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7048
	availableRam notNil ifTrue:[info at:#availableRam put:availableRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7049
    ].
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7050
    totalRam notNil ifTrue:[info at:#totalRam put:totalRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7051
    sharedRam notNil ifTrue:[info at:#sharedRam put:sharedRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7052
    bufferRam notNil ifTrue:[info at:#bufferRam put:bufferRam].
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7053
    virtualRam notNil ifTrue:[info at:#virtualRam put:virtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7054
    activeVirtualRam notNil ifTrue:[info at:#activeVirtualRam put:activeVirtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7055
    realMemory notNil ifTrue:[info at:#realMemory put:realMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7056
    activeRealMemory notNil ifTrue:[info at:#activeRealMemory put:activeRealMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7057
    freeMemory notNil ifTrue:[info at:#freeMemory put:freeMemory].
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7058
    swapSize notNil ifTrue:[info at:#swapSize put:swapSize].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7059
    freeSwap notNil ifTrue:[info at:#freeSwap put:freeSwap].
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7060
    numberOfCPUs notNil ifTrue:[info at:#numberOfCPUs put:numberOfCPUs].
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7061
    cpuType notNil ifTrue:[info at:#cpuType put:cpuType].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7062
    cpuSpeed notNil ifTrue:[info at:#cpuSpeed put:cpuSpeed].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7063
    dCacheSize notNil ifTrue:[info at:#dCacheSize put:dCacheSize].
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7064
    iCacheSize notNil ifTrue:[info at:#iCacheSize put:iCacheSize].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7065
    instructionSets notNil ifTrue:[info at:#instructionSets put:instructionSets].
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7066
    extendedInstructions notNil ifTrue:[info at:#extendedInstructions put:(extendedInstructions asOrderedCollection select:[:e | e notNil])].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7067
    platform notNil ifTrue:[info at:#platform put:platform].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7068
    info at:#osType put:(self getOSType).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7069
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7070
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7071
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7072
     OperatingSystem getSystemInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7073
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7074
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7075
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7076
getSystemType
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7077
    "return a string giving the type of system we're running on.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7078
     This is almost the same as getOSType, but the returned string
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7079
     is slightly different for some systems (i.e. iris vs. irix).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7080
     Dont depend on this - use getOSType. I dont really see a point
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7081
     here ... 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7082
     (except for slight differences between next/mach and other machs)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7083
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7084
    |sys|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7085
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7086
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7087
#   ifdef NEXT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7088
#    define SYS_STRING "next"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7089
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7090
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7091
#   ifdef IRIS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7092
#    define SYS_STRING "iris"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7093
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7094
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7095
#   ifdef SYS_STRING
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7096
     sys = __MKSTRING(SYS_STRING);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7097
#    undef SYS_STRING
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7098
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7099
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7100
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7101
    sys isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7102
	^ self getOSType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7103
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7104
    ^ sys
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7105
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7106
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7107
     OperatingSystem getSystemType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7108
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7109
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7110
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7111
isBSDlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7112
    "return true, if the OS we're running on is a 'real' unix."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7113
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7114
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7115
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7116
#if defined(BSD) || defined(MACH) || defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7117
    RETURN ( true );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7118
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7119
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7120
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7121
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7122
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7123
isUNIXlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7124
    "return true, if the OS we're running on is a unix like."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7125
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7126
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7127
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7128
    "Modified: / 5.6.1998 / 18:40:39 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7129
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7130
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7131
maxFileNameLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7132
    "return the max number of characters in a filename.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7133
     CAVEAT:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7134
	 Actually, the following is somewhat wrong - some systems
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7135
	 support different sizes, depending on the volume.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7136
	 We return a somewhat conservative number here.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7137
	 Another entry, to query for volume specific max
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7138
	 will be added in the future."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7139
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7140
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7141
 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7142
    /*
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7143
     * TODO: new systems provide a query function for this ... use it
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7144
     */
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7145
#   if defined(MAXFILENAMELEN)
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7146
      RETURN ( __MKSMALLINT(MAXFILENAMELEN) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7147
#   else
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7148
#    if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES)
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7149
      RETURN ( __MKSMALLINT(255) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7150
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7151
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7152
#    ifdef realIX
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7153
       RETURN ( __MKSMALLINT(127) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7154
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7155
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7156
#    ifdef SYSV
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7157
       RETURN ( __MKSMALLINT(14) );
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7158
#    endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7159
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7160
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7161
    "unix default"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7162
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7163
    ^ 14
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7164
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7165
    "
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7166
     OperatingSystem maxFileNameLength
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7167
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7168
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7169
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7170
maxPathLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7171
    "return the max number of characters in a pathName."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7172
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7173
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7174
    RETURN ( __MKSMALLINT(MAXPATHLEN) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7175
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7176
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7177
     OperatingSystem maxPathLength   
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7178
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7179
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7180
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7181
pathSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7182
    "return the character which separates items in the PATH variable"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7183
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7184
    ^ $:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7185
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7186
    "Created: / 2.5.1997 / 11:36:47 / cg"
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7187
    "Modified: / 5.6.1998 / 18:41:01 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7188
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7190
platformName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7191
    "return a string describing the OS platform very we're running on.
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7192
     This returns #unix for all unix derivatives,
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7193
     #os2, #win32, #vms or #mac for the others.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7194
     I.e. it is much less specific than getOSType or getSystemType."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7195
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7196
    ^ #unix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7197
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7198
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7199
     OperatingSystem platformName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7200
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7201
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7202
    "Modified: / 5.6.1998 / 18:41:32 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7203
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7204
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7205
primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7206
    "return the domain this host is in.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7207
     Notice:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7208
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7209
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7210
%{  /* STACK: 2048 */
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7211
#if defined(HAS_GETDOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7212
    char buffer[128];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7213
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7214
    if (getdomainname(buffer, sizeof(buffer)) == 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7215
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7216
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7217
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7218
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7219
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7220
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7221
    if (uname(&ubuff) >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7222
	RETURN (__MKSTRING(ubuff.domainname));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7223
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7224
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7225
#  if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7226
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7227
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7228
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7229
    if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7230
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7231
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7232
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7233
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7234
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7235
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7236
    ^ nil
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7237
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7238
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7239
     OperatingSystem primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7240
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7241
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7242
    "Modified: 26.4.1996 / 10:04:54 / stefan"
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7243
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7244
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7245
primGetHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7246
    "return the hostname we are running on - if there is
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7247
     a HOST environment variable, we are much faster here ...
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7248
     Notice:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7249
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7250
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7251
%{  /* STACK: 2048 */
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7252
#if defined(HAS_GETHOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7253
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7254
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7255
    if (gethostname(buffer, sizeof(buffer)) == 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7256
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7257
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7258
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7259
# if defined(HAS_UNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7260
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7261
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7262
    if (uname(&ubuff) >= 0) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7263
	RETURN (__MKSTRING(ubuff.nodename));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7264
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7265
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7266
#  if defined(HAS_SYSINFO) && defined(SI_HOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7267
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7268
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7269
 
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7270
    if ((ret = sysinfo(SI_HOSTNAME, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7271
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7272
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7273
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7274
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7275
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7276
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7277
    ^ nil 
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7278
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7279
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7280
     OperatingSystem getHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7281
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7282
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7283
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7284
setLocaleInfo:anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7285
    "set the locale information; if set, this oerrides the OS's settings.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7286
     (internal in ST/X only - the OS's settings remain unaffected)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7287
     See description of fields in #getLocaleInfo.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7288
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7289
     Notice, that (for now), the system does not use this information;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7290
     it should be used by applications as required."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7291
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7292
    LocaleInfo := anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7293
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7294
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7295
     |d|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7296
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7297
     d := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7298
     d at:#decimalPoint                 put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7299
     d at:#thousandsSeparator           put:','         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7300
     d at:#currencySymbol               put:'USD'       .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7301
     d at:#monetaryDecimalPoint         put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7302
     d at:#monetaryThousandsSeparator   put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7303
     d at:#fractionalDigits             put:2           .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7304
     d at:#positiveSign                 put:'+'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7305
     d at:#negativeSign                 put:'-'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7306
     d at:#positiveSignPrecedesCurrencySymbol put:true          .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7307
     d at:#negativeSignPrecedesCurrencySymbol put:false         .
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7308
     OperatingSystem setLocaleInfo:d
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7309
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7310
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7311
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7312
supportsChildInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7313
    "return true, if the OS supports childProcess termination signalling
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7314
     through interrupts (i.e. SIGCHILD)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7315
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7316
%{  /* NOCONTEXT */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  7317
#if defined(SIGCHLD) || defined(SIGCLD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7318
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7319
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7320
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7321
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7322
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7323
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7324
     OperatingSystem supportsChildInterrupts 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7325
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7326
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7327
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7328
supportsIOInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7329
    "return true, if the OS supports IO availability interrupts 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7330
     (i.e. SIGPOLL/SIGIO).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7332
     Currently, this mechanism does not work on all
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7333
     systems ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7334
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7335
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7336
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7337
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7338
  /* positive defines here
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7339
   *  - irix5.2 does not work
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7340
   */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7341
#if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7342
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7343
# if defined(SIGIO) || defined(SIGPOLL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7344
#  if defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7345
#   if defined(F_SETOWN) || defined(FIOSETOWN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7346
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7347
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7348
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7349
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7350
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7351
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7352
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7353
#endif /* machines where it works */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7354
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7355
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7356
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7357
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7358
     OperatingSystem supportsIOInterrupts 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7359
    "
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7360
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7361
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7362
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7363
supportsNonBlockingIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7364
    "return true, if the OS supports nonblocking IO."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7365
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7366
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7367
#if defined(F_GETFL) && defined(F_SETFL) && defined(FNDELAY)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7368
       RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7369
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7370
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7371
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7372
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7373
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7374
     OperatingSystem supportsNonBlockingIO  
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7375
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7376
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7377
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7378
supportsSelect
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7379
    "return true, if the OS supports selecting on multiple
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7380
     filedescriptors via select.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7381
     If false is returned, ProcessorScheduler will poll in 50ms
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7382
     intervals for I/O becoming ready."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7383
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7384
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7386
#if defined(sco)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7387
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7388
     * sco has a select, but its broken: always waiting 1 second
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7389
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7390
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7391
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7392
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7393
    ^ true
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7394
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7395
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7396
     OperatingSystem supportsSelect 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7397
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7398
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7399
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7400
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7401
supportsSymbolicLinks
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7402
    "return true, if the OS supports symbolic (soft) links;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7403
     most UNIX'es do; many other OS's do not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7404
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7405
%{  /* NOCONTEXT */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7406
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7407
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7408
    /*
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7409
     * assume yes - if that is defined.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7410
     */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7411
    RETURN(true);
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7412
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7413
%}.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7414
    ^ false
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7415
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7416
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7417
     OperatingSystem supportsSymbolicLinks 
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7418
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  7419
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7420
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7421
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7422
!UnixOperatingSystem class methodsFor:'path queries'!
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7423
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7424
defaultSystemPath
5647
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  7425
    "add additional directories to the systemPath 
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  7426
     (but only, if the major version is the same)"
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  7427
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  7428
    |sysPath majorVersionNr minorVersionNr releaseFile s v|
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  7429
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  7430
    majorVersionNr := Smalltalk majorVersionNr.
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7431
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7432
    sysPath := super defaultSystemPath.
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7433
    #(
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7434
	'/usr/local/lib/smalltalk'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7435
	'/usr/lib/smalltalk'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7436
	'/lib/smalltalk'
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7437
	'/opt/smalltalk'
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7438
    ) do:[:d |
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7439
	(d asFilename isDirectory) ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7440
	    "/ try to guess a gnu-smalltalk; skip it
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7441
	    (d asFilename construct:'initialize.st') exists ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7442
		releaseFile := d asFilename construct:'RELEASE'.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7443
		releaseFile exists ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7444
		    s := releaseFile readStream.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7445
		    s notNil ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7446
			v := Integer readFrom:s onError:-1.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7447
			s close.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7448
			v == majorVersionNr ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7449
			    sysPath add:d
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7450
			] ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7451
			    ('UnixOperatingSystem [info]: ignore files in ' , d asFilename pathName , ' (RELEASE mismatch)') infoPrintCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7452
			]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7453
		    ] ifFalse:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7454
			('UnixOperatingSystem [info]: ignore files in ' , d asFilename pathName , ' (RELEASE missing)') infoPrintCR.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7455
		    ]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7456
		]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7457
	    ]
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7458
	]
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7459
    ].
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7460
    ^ sysPath
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7461
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7462
    "
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7463
     OperatingSystem defaultSystemPath
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  7464
    "
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7465
! !
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  7466
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7467
!UnixOperatingSystem class methodsFor:'private'!
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7468
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7469
osProcessStatusClass
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7470
    ^ OSProcessStatus
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7471
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7472
    "Created: / 12.6.1998 / 16:30:43 / cg"
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7473
! !
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  7474
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7475
!UnixOperatingSystem class methodsFor:'shared memory access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7476
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7477
shmAttach:id address:addr flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7478
    "low level entry to shmat()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7479
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7480
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7481
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7482
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7483
    void *address, *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7484
    int shmflg, shmid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7485
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7486
    if (__isSmallInteger(addr)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7487
     && __bothSmallInteger(flags, id)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7488
	shmaddr = (void *) __intVal(addr);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7489
	shmflg = __intVal(flags);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7490
	shmid = __intVal(id);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7491
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7492
	address = shmat(shmid, shmaddr, shmflg);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7493
	if (address != (void *)-1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7494
	    RETURN (__MKEXTERNALBYTES(addr));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7495
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7496
	@global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7497
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7498
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7499
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7500
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7501
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7502
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7503
    "Modified: 22.4.1996 / 13:15:12 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7504
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7505
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7506
shmDetach:addr
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7507
    "low level entry to shmdt()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7508
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7509
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7510
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7511
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7512
    void *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7513
    int rslt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7514
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7515
    if (__isSmallInteger(addr)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7516
	shmaddr = (void *) __intVal(addr);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7517
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7518
	rslt = shmdt(shmaddr);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7519
	if (rslt != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7520
	    RETURN (true);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7521
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7522
	@global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7523
	RETURN (false);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7524
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7525
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7526
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7527
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7528
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7529
    "Modified: 22.4.1996 / 13:15:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7530
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7531
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7532
shmGet:key size:size flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7533
    "low level entry to shmget()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7534
     This is not for public use and not supported with all operatingSystems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7535
     - use the provided wrapper class SharedExternalBytes instead."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7536
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7537
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7538
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7539
    if (__bothSmallInteger(key, size)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7540
     && __isSmallInteger(flags)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7541
	int rslt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7542
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7543
	rslt = shmget(__intVal(key), __intVal(size), __intVal(flags));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7544
	if (rslt != -1) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7545
	    RETURN (__MKSMALLINT(rslt));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7546
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7547
	@global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7548
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7549
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7550
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7551
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7552
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7553
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7554
    "Modified: 22.4.1996 / 13:14:46 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7555
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7556
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7557
!UnixOperatingSystem class methodsFor:'time and date'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7558
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7559
computeDatePartsOf:osTime for:aBlock
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7560
    "compute year, month and day from the OS time, osTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7561
     and evaluate the argument, a 3-arg block with these.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7562
     Conversion is to localtime including any daylight saving adjustments."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7563
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7564
    |year month day osSeconds i|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7565
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7566
    osSeconds := osTime // 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7567
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7568
    struct tm* tmPtr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7569
    INT t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7570
    TIME_T tt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7571
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7572
    t = __longIntVal(osSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7573
    tt = (TIME_T)t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7574
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7575
    tmPtr = localtime(&tt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7576
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7577
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7578
    day = __MKSMALLINT(tmPtr->tm_mday);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7579
%}.
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7580
    year isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7581
	i := self computeTimeAndDateFrom:osTime.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7582
	year := i at:1.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7583
	month := i at:2.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7584
	day := i at:3.
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7585
    ].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7586
    aBlock value:year value:month value:day
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7587
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7588
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7589
     OperatingSystem computeDatePartsOf:0 for:[:y :m :d |
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7590
	y printCR. m printCR. d printCR
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7591
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7592
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7593
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7594
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7595
computeOSTimeFromUTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7596
    "return the OS-dependent time for the given time and day. 
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7597
     The arguments are assumed to be in UTC Time"
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7598
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7599
    |osSeconds|
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7600
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7601
%{
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7602
    struct tm tm;
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7603
    TIME_T t;
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7604
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7605
    if (__bothSmallInteger(y, m) 
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7606
     && __bothSmallInteger(d, h)
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7607
     && __bothSmallInteger(min, s)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7608
	tm.tm_hour = __intVal(h);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7609
	tm.tm_min = __intVal(min);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7610
	tm.tm_sec = __intVal(s);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7611
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7612
	tm.tm_year = __intVal(y) - 1900;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7613
	tm.tm_mon = __intVal(m) - 1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7614
	tm.tm_mday = __intVal(d);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7615
	tm.tm_isdst = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7616
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7617
	t = mktime(&tm);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7618
	osSeconds = __MKUINT((INT)t+TIMEZONE(&tm));
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7619
    }
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7620
%}.
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7621
    osSeconds notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7622
	^ osSeconds * 1000 + millis
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7623
    ].    
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7624
    ^ self primitiveFailed
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7625
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7626
    "
5639
2e750f87b419 Fix UTC Time handling when daylight saving time applies.
Stefan Vogel <sv@exept.de>
parents: 5625
diff changeset
  7627
     OperatingSystem computeOSTimeFromUTCYear:1970 month:1 day:1 hour:0 minute:0 second:0 millisecond:0
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7628
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
5639
2e750f87b419 Fix UTC Time handling when daylight saving time applies.
Stefan Vogel <sv@exept.de>
parents: 5625
diff changeset
  7629
     OperatingSystem computeOSTimeFromUTCYear:2000 month:7 day:1 hour:0 minute:0 second:0 millisecond:0
2e750f87b419 Fix UTC Time handling when daylight saving time applies.
Stefan Vogel <sv@exept.de>
parents: 5625
diff changeset
  7630
     OperatingSystem computeOSTimeFromYear:2000 month:7 day:1 hour:0 minute:0 seconds:0 millis:0
2e750f87b419 Fix UTC Time handling when daylight saving time applies.
Stefan Vogel <sv@exept.de>
parents: 5625
diff changeset
  7631
    "
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7632
!
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  7633
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7634
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7635
    "return the OS-dependent time for the given time and day. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7636
     The arguments are assumed to be in localtime including
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7637
     any daylight saving adjustings."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7638
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7639
    |osSeconds|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7640
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7641
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7642
    struct tm tm;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7643
    TIME_T t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7644
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7645
    if (__bothSmallInteger(y, m) 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7646
     && __bothSmallInteger(d, h)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7647
     && __bothSmallInteger(min, s)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7648
	tm.tm_hour = __intVal(h);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7649
	tm.tm_min = __intVal(min);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7650
	tm.tm_sec = __intVal(s);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7651
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7652
	tm.tm_year = __intVal(y) - 1900;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7653
	tm.tm_mon = __intVal(m) - 1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7654
	tm.tm_mday = __intVal(d);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7655
	tm.tm_isdst = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7656
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7657
	t = mktime(&tm);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7658
	osSeconds = __MKUINT((INT)t);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7659
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7660
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7661
    osSeconds notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7662
	^ osSeconds * 1000 + millis
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7663
    ].    
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7664
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7665
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7666
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7667
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7668
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7669
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7670
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7671
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7672
computeTimeAndDateFrom:osTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7673
    "given an OS-dependent time in osTime, return an Array
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7674
     containing (full-) year, month, day, hour, minute and seconds,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7675
     offset to UTC, daylight savings time flag, milliseconds,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7676
     dayInYear (1..) and dayInWeek (1..).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7677
     Conversion is to localtime including any daylight saving adjustments."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7678
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7679
    |millis osSeconds ret|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7680
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7681
    millis := osTime \\ 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7682
    osSeconds := osTime // 1000.
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7683
    ret := self fillTimeAndDateFromSeconds:osSeconds into:(Array new:11).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7684
    ret at:9 put:millis.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7685
    ^ ret
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7686
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7687
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7688
     OperatingSystem computeTimeAndDateFrom:0
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7689
     OperatingSystem computeTimeAndDateFrom:1011
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7690
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7691
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7692
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7693
computeTimePartsOf:osTime for:aBlock
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7694
    "compute hours, minutes, seconds and milliseconds from the local osTime 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7695
     and evaluate the argument, a 4-arg block with these.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7696
     Conversion is to localtime including any daylight saving adjustments."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7697
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7698
    |hours minutes seconds millis osSeconds i|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7699
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7700
    i := self computeTimeAndDateFrom:osTime.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7701
    hours := i at:4.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7702
    minutes := i at:5.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7703
    seconds := i at:6.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7704
    millis := i at:9.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7705
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7706
"/    osSeconds := osTime // 1000.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7707
"/    millis := osTime \\ 1000.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7708
"/%{
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7709
"/    struct tm *tmPtr;
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7710
"/    INT t;
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7711
"/    TIME_T tt;
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7712
"/
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7713
"/    t = __longIntVal(osSeconds);
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7714
"/    tt = (TIME_T)t;
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7715
"/
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7716
"/    tmPtr = localtime(&tt);
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7717
"/    hours = __MKSMALLINT(tmPtr->tm_hour);
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7718
"/    minutes = __MKSMALLINT(tmPtr->tm_min);
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7719
"/    seconds = __MKSMALLINT(tmPtr->tm_sec);
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7720
"/%}.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7721
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7722
    aBlock value:hours value:minutes value:seconds value:millis
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7723
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7724
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7725
     OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli |
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7726
	Transcript show:h; space; show:m; space; show:s; space; showCR:milli.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7727
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7728
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7729
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7730
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7731
computeUTCTimeAndDateFrom:osTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7732
    "given an OS-dependent time in osTime, return an Array
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7733
     containing:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7734
	(full-) year, 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7735
	month,                          (1..)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7736
	day,                            (1..)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7737
	hour,                           (0..23)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7738
	minute                          (0..59)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7739
	seconds,                        (0..59)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7740
	offset to UTC,                  (seconds)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7741
	daylight savings time flag, 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7742
	milliseconds,                   (0..999)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7743
	dayInYear                       (1..)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7744
	dayInWeek                       (1..).
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7745
     Conversion is to utc."
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7746
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7747
    |millis osSeconds ret|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7748
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7749
    millis := osTime \\ 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7750
    osSeconds := osTime // 1000.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7751
    ret := self fillTimeAndDateFromUTCSeconds:osSeconds into:(Array new:11).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7752
    ret at:9 put:millis.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7753
    ^ ret
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7754
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7755
    "
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7756
     OperatingSystem computeUTCTimeAndDateFrom:0     
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7757
     OperatingSystem computeUTCTimeAndDateFrom:1011
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7758
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7759
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7760
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7761
computeUTCTimePartsOf:osTime for:aBlock
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7762
    "compute hours, minutes, seconds and milliseconds from the osTime 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7763
     and evaluate the argument, a 4-arg block with these.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7764
     Conversion is to UTC."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7765
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7766
    |hours minutes seconds millis osSeconds|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7767
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7768
    osSeconds := osTime // 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7769
    millis := osTime \\ 1000.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7770
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7771
    struct tm *tmPtr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7772
    long t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7773
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7774
    t = __longIntVal(osSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7775
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7776
    tmPtr = gmtime(&t);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7777
    hours = __MKSMALLINT(tmPtr->tm_hour);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7778
    minutes = __MKSMALLINT(tmPtr->tm_min);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7779
    seconds = __MKSMALLINT(tmPtr->tm_sec);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7780
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7781
    aBlock value:hours value:minutes value:seconds value:millis
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7782
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7783
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7784
     OperatingSystem computeUTCTimePartsOf:100 for:[:h :m :s :milli |
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7785
	h printCR. m printCR. s printCR. milli printCR
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7786
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7787
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7788
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7789
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7790
fillTimeAndDateFromSeconds:osSeconds into:timeArray
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7791
    "fill the array with os-time components.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7792
     An internal helper"
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7793
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7794
    ^ self fillTimeAndDateFromSeconds:osSeconds isLocal:true into:timeArray
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7795
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7796
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7797
fillTimeAndDateFromSeconds:osSeconds isLocal:isLocalTime into:timeArray
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7798
    "fill the array with os-time components.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7799
     An internal helper"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7800
5855
dead3acb2abf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5854
diff changeset
  7801
    |low hi year month day hours minutes seconds utcOffset 
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7802
     dst yDay wDay |
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7803
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7804
%{
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7805
    struct tm *tmPtr;
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7806
    INT t;
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7807
    TIME_T tt;
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7808
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7809
    t = __longIntVal(osSeconds);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7810
    tt = (TIME_T)t;
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7811
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7812
    if (isLocalTime == true) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7813
	tmPtr = localtime(&tt);
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7814
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7815
	tmPtr = gmtime(&tt);
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7816
    }
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7817
    hours = __MKSMALLINT(tmPtr->tm_hour);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7818
    minutes = __MKSMALLINT(tmPtr->tm_min);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7819
    seconds = __MKSMALLINT(tmPtr->tm_sec);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7820
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7821
    year = __MKSMALLINT(tmPtr->tm_year + 1900);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7822
    month = __MKSMALLINT(tmPtr->tm_mon + 1);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7823
    day = __MKSMALLINT(tmPtr->tm_mday);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7824
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7825
    yDay = __MKSMALLINT(tmPtr->tm_yday+1);
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7826
    wDay = __MKSMALLINT(tmPtr->tm_wday == 0 ? 7 : tmPtr->tm_wday);
5656
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
  7827
    utcOffset = __MKSMALLINT(TIMEZONE(tmPtr));
dbc52ea02716 Fix UTC Time w.r.t. Daylight saving time.
Stefan Vogel <sv@exept.de>
parents: 5649
diff changeset
  7828
    dst = (tmPtr->tm_isdst == 0 ? false : true);
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7829
%}.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7830
    "I would love to have SELF-like inline objects ..."
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7831
    timeArray at:1 put:year.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7832
    timeArray at:2 put:month.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7833
    timeArray at:3 put:day.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7834
    timeArray at:4 put:hours.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7835
    timeArray at:5 put:minutes.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7836
    timeArray at:6 put:seconds.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7837
    timeArray at:7 put:utcOffset.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7838
    timeArray at:8 put:dst.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7839
    timeArray at:9 put:nil.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7840
    timeArray at:10 put:yDay.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7841
    timeArray at:11 put:wDay.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7842
    ^ timeArray
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7843
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7844
    "
5855
dead3acb2abf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5854
diff changeset
  7845
     OperatingSystem fillTimeAndDateFromSeconds:0 isLocal:false into:(Array new:11)
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7846
    "
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7847
!
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7848
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7849
fillTimeAndDateFromUTCSeconds:osSeconds into:timeArray
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7850
    "fill the array with os-time components.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7851
     An internal helper"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7852
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7853
    ^ self fillTimeAndDateFromSeconds:osSeconds isLocal:false into:timeArray
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7855
    "
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7856
     OperatingSystem fillTimeAndDateFromUTCSeconds:0 into:(Array new:11)
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7857
    "
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7858
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  7859
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7860
getMicrosecondTime
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7861
    "This returns the microsecond timers value - if available. 
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7862
     On some machines, times with this precision may not be available,
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7863
     on those, the returned value may be rounded towards some internal
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7864
     clock resolution value."
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7865
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7866
    |seconds millis micros|
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7867
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7868
%{
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7869
    long _seconds = 0;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7870
    long _millis = 0;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7871
    long _micros = 0;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7872
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7873
#if !defined(HAS_GETTIMEOFDAY)
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7874
# if defined(HAS_FTIME)
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7875
    struct timeb timebuffer;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7876
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7877
    ftime(&timebuffer);
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7878
     _seconds = timebuffer.time;
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7879
    _millis = timebuffer.millitm;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7880
#   define HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7881
# endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7882
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7883
# ifndef HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7884
#  if defined(SYSV) && defined(HZ)
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7885
    /* 
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7886
     * sys5 time - in ticks
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7887
     */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7888
    long ticks;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7889
    struct tms tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7890
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7891
    ticks = times(&tb);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7892
    _seconds = ticks / HZ;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7893
    ticks -= (_seconds * HZ);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7894
    _millis = ticks * 1000 / HZ;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7895
#   define HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7896
#  endif /* old SYSV stuff */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7897
# endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7898
#endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7899
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7900
#ifndef HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7901
    /* assume HAS_GETTIMEOFDAY 
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7902
     * - will result in a linkage error
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7903
     * if not fixed.
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7904
     */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7905
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7906
    /*
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7907
     * bsd time
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7908
     */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7909
    struct timeval tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7910
    /* struct timezone tzb; */
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7911
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7912
    gettimeofday(&tb, NULL /* &tzb */);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7913
    _seconds = tb.tv_sec;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7914
    _micros = tb.tv_usec;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7915
    if (_micros >= (1000*1000)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7916
	printf("oops\n");
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7917
    }
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7918
#endif
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7919
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7920
#undef HAVE_TIME
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7921
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7922
    seconds = __MKINT(_seconds);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7923
    millis = __MKINT(_millis);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7924
    micros = __MKINT(_micros);
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7925
%}.
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7926
    ^ (((seconds * 1000) + millis) * 1000) + micros
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7927
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7928
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7929
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7930
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7931
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7932
!
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  7933
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7934
getMillisecondTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7935
    "This returns the millisecond timers value. 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7936
     The range is limited to 0..1fffffff (i.e. the SmallInteger range) to avoid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7937
     LargeInteger arithmetic when doing timeouts and delays.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7938
     Since this value is wrapping around in regular intervals, this can only be used for 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7939
     short relative time deltas.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7940
     Use the millisecondTimeXXX:-methods to compare and add time deltas - these know about the wrap.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7941
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7942
     BAD DESIGN:
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7943
	This should be changed to return some instance of RelativeTime,
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7944
	and these computations moved there.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7945
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7946
     Dont use this method in application code since it is an internal (private)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7947
     interface. For compatibility with ST-80, use Time millisecondClockValue.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7948
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7949
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7950
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7951
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7952
    long t = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7953
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7954
#if !defined(HAS_GETTIMEOFDAY)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7955
# if defined(HAS_FTIME)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7956
    struct timeb timebuffer;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7957
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7958
    ftime(&timebuffer);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7959
    t = (timebuffer.time * 1000) + timebuffer.millitm;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7960
#   define HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7961
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7962
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7963
# ifndef HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7964
#  if defined(SYSV) && defined(HZ)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7965
    /* 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7966
     * sys5 time
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7967
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7968
    long ticks;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7969
    struct tms tb;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7970
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7971
    ticks = times(&tb);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7972
    t = (ticks * 1000) / HZ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7973
#   define HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7974
#  endif /* old SYSV stuff */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7975
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7976
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7977
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7978
#ifndef HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7979
    /* assume HAS_GETTIMEOFDAY 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7980
     * - will result in a linkage error
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7981
     * if not fixed.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7982
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7983
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7984
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7985
     * bsd time
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7986
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7987
    struct timeval tb;
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7988
    /* struct timezone tzb; */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7989
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  7990
    gettimeofday(&tb, NULL /* &tzb */);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7991
    t = tb.tv_sec*1000 + tb.tv_usec/1000;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7992
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7993
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7994
#undef HAVE_TIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7995
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7996
    RETURN ( __MKSMALLINT(t & 0x1FFFFFFF) );
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7997
%}.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  7998
    self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7999
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8000
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8001
getOSTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8002
    "This returns the OS time.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8003
     The base of the returned value is not consistent across
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8004
     different OS's - some return the number of millis since jan, 1st 1970;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8005
     others since 1900. The Time classes are prepared for this, and 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8006
     converts as appropriate (by using my fromOSTime: conversion methods).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8007
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8008
     Dont use this method in application code since it is an internal (private)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8009
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8010
     or use instances of Time, Date or AbsoluteTime to work with.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8011
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8012
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8013
    |time seconds millis|
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8014
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8015
    time := self primGetOSTime.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8016
    time isArray ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8017
	seconds := time at:1.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8018
	millis := time at:2.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8019
	time := (seconds * 1000) + millis
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8020
    ].
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8021
    ^ time
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8022
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8023
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8024
     OperatingSystem getOSTime printCR.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8025
     Delay waitForSeconds:0.2.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8026
     OperatingSystem getOSTime printCR.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8027
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8028
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8029
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8030
millisecondDelay:millis
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8031
    "delay execution for millis milliseconds or until the next event
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8032
     arrives.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8033
     All lower priority threads will also sleep for the duration, 
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8034
     interrupts (and therefore, higher prio processes) are still handled. 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8035
     Better use a Delay, to only delay the calling thread.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8036
     (however, a delay cannot be used in the event handler or scheduler)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8037
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8038
    |now then delta|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8039
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8040
    now := UnixOperatingSystem getMillisecondTime.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8041
    then := UnixOperatingSystem millisecondTimeAdd:now and:millis.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8042
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8043
    [UnixOperatingSystem millisecondTime:then isAfter:now] whileTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8044
	delta := UnixOperatingSystem millisecondTimeDeltaBetween:then and:now.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8045
	self selectOnAnyReadable:nil writable:nil exception:nil withTimeOut:delta.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8046
	now := UnixOperatingSystem getMillisecondTime.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8047
    ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8048
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8049
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8050
     OperatingSystem millisecondDelay:2000
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8051
    "
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8052
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8053
    "Modified: / 5.6.1998 / 18:42:17 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8054
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8055
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8056
primGetOSTime
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8057
    "This returns the OS time.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8058
     The base of the returned value is not consistent across
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8059
     different OS's - some return the number of millis since jan, 1st 1970;
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8060
     others since 1900. The Time classes are prepared for this, and 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8061
     converts as appropriate (by using my fromOSTime: conversion methods).
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8062
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8063
     Dont use this method in application code since it is an internal (private)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8064
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8065
     or use instances of Time, Date or AbsoluteTime to work with.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8066
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8067
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8068
    |seconds millis|
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8069
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8070
%{
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8071
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8072
    long t;
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8073
    long _secs, _millis;
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8074
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8075
#if !defined(HAS_GETTIMEOFDAY) 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8076
# if defined(HAS_FTIME)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8077
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8078
	struct timeb timebuffer;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8079
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8080
	ftime(&timebuffer);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8081
	_secs = timebuffer.time;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8082
	_millis = timebuffer.millitm;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8083
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8084
#   define HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8085
# endif /* HAS_FTIME */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8086
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8087
# ifndef HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8088
#  if defined(SYSV) && defined(HZ)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8089
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8090
	/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8091
	 * sys5 time; we have to fake the information
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8092
	 * the returned value is inexact.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8093
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8094
	long ticks;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8095
	struct tms tb;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8096
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8097
	_secs = time(0);   /* seconds since 1970 ... */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8098
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8099
	ticks = times(&tb);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8100
	t = (ticks * 1000) / HZ;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8101
	t = t % 1000;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8102
	_millis = __MKSMALLINT(t);
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8103
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8104
#   define HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8105
#  endif /* OLD SYSV stuff */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8106
# endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8107
#endif /* no HAS_GETTIMEOFDAY */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8108
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8109
#ifndef HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8110
    /*
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8111
     * use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8112
     * Will result in a linkage error if not fixed and neither ftime() nor time() is used.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8113
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8114
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8115
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8116
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8117
	 * bsd time
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8118
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8119
	struct timeval tb;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8120
	/* struct timezone tzb; */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8121
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8122
	gettimeofday(&tb, NULL /* &tzb */);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8123
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8124
	_secs = tb.tv_sec;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8125
	_millis = tb.tv_usec / 1000;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8126
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8127
#endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8128
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8129
    /* 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8130
     * mhmh long-long stuff seems not to work correctly 
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8131
     * on all machines (sparc)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8132
     * being conservative here ...
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8133
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8134
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8135
#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(i386) && defined(LINUX)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8136
# define HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8137
#endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8138
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8139
#ifdef alpha64
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8140
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8141
	unsigned INT _lsecs, _lmillis, rslt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8142
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8143
	_lsecs = (INT)_secs;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8144
	_lmillis = (INT)_millis;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8145
	rslt = _lsecs * 1000 + _lmillis;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8146
	RETURN (__MKUINT(rslt));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8147
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8148
#else
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8149
# ifdef HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8150
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8151
	unsigned long long _lsecs, _lmillis, rslt;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8152
	unsigned low, hi;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8153
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8154
	_lsecs = (long long)_secs;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8155
	_lmillis = (long long)_millis;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8156
	rslt = _lsecs * 1000 + _lmillis;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8157
	low = rslt & 0xFFFFFFFF;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8158
	hi = rslt >> 32;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8159
	RETURN (__MKLARGEINT64(1, low, hi));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8160
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8161
# else
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8162
    seconds = __MKUINT(_secs);
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8163
    millis = __MKUINT(_millis);
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8164
    RETURN (__ARRAY_WITH2(seconds, millis));
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8165
# endif /* long long */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8166
#endif /* alpha64 */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8167
%}.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8168
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8169
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8170
     OperatingSystem primGetOSTime printCR.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8171
     Delay waitForSeconds:0.2.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8172
     OperatingSystem primGetOSTime printCR.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8173
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8174
!
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8175
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8176
sleep:numberOfSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8177
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8178
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8179
    "cease ANY action for some time. This suspends the whole smalltalk
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8180
     (unix-) process for some time if running threadless;
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8181
     if running with threads (which is the default), this will 
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8182
     only block until the next clock tick and return with the next
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8183
     timer interrupt.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8184
     Use either OperatingSystem>>millisecondDelay: (which makes all
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8185
     threads sleep, but handles interrupts) or use a Delay (which makes
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8186
     only the calling thread sleep)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8187
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8188
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8190
    if (__isSmallInteger(numberOfSeconds)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8191
	sleep(__intVal(numberOfSeconds));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8192
	RETURN ( self );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8193
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8194
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8195
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8196
     argument not integer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8197
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8198
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8199
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8200
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8201
     OperatingSystem sleep:2
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8202
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8203
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8204
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8205
!UnixOperatingSystem class methodsFor:'users & groups'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8206
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8207
getEffectiveGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8208
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8209
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8210
    "return the current users (thats you) effective numeric group id.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8211
     This is only different from getGroupID, if you have ST/X running
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8212
     as a setuid program (of which you should think about twice)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8213
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8214
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8215
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8216
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8217
    uid = getegid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8218
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8219
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8220
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8221
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8222
     OperatingSystem getEffectiveGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8223
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8224
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8225
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8226
getEffectiveUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8227
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8228
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8229
    "return the current users (thats you) effective numeric user id.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8230
     This is only different from getUserID, if you have ST/X running
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8231
     as a setuid program (of which you should think about twice)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8232
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8233
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8234
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8235
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8236
    uid = geteuid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8237
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8238
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8239
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8240
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8241
     OperatingSystem getEffectiveUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8242
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8243
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8244
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8245
getFullUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8246
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8247
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8248
    "return a string with the users full name - if available.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8249
     If not, return the login name as a fallBack."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8250
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8251
    |info gecos|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8252
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8253
    info := self userInfoOf:userID.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8254
    (info notNil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8255
    and:[info includesKey:#gecos]) ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8256
	gecos := info at:#gecos.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8257
	(gecos includes:$,) ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8258
	    ^ gecos copyTo:(gecos indexOf:$,) - 1
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8259
	].
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8260
	^ gecos
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8261
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8262
    ^ self getUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8263
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8264
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8265
     OperatingSystem getFullUserNameFromID:0 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8266
     OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID)  
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8267
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8268
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)  
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8269
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8270
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8271
    "Modified: 15.7.1996 / 12:44:21 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8272
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8273
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8274
getGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8275
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8276
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8277
    "return the current users (thats you) numeric group id"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8278
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8279
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8280
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8281
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8282
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8283
    uid = getgid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8284
    RETURN ( __MKSMALLINT(uid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8285
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8286
    ^ 1 "just a dummy for systems which do not have userIDs"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8287
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8288
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8289
     OperatingSystem getGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8290
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8291
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8292
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8293
getGroupNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8294
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8295
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8296
    "return the group-name-string for a given numeric group-id"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8297
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8298
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8299
    struct group *g;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8300
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8301
    if (__isSmallInteger(aNumber)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8302
	g = getgrgid(__intVal(aNumber));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8303
	if (g) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8304
	    RETURN ( __MKSTRING(g->gr_name) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8305
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8306
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8307
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8308
    ^ '???'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8309
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8310
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8311
     OperatingSystem getGroupNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8312
     OperatingSystem getGroupNameFromID:10
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8313
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8314
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8315
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8316
getHomeDirectory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8317
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8318
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8319
    "return the name of the users home directory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8320
     (i.e. yours)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8321
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8322
    ^ UnixOperatingSystem getEnvironment:'HOME'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8323
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8324
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8325
     OperatingSystem getHomeDirectory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8326
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8327
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8328
    "Modified: 24.1.1997 / 11:32:13 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8329
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8330
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8331
getLoginName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8332
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8333
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8334
    "return a string with the users login name (thats yours)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8335
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8336
%{  /* NOCONTEXT */
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  8337
    static char cachedName[128];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8338
    static firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8339
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8340
    extern char *getlogin();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8341
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8342
    char *name = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8343
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8344
    if (firstCall) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8345
	name = getlogin();
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8346
	if (! name || (name[0] == 0)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8347
	    name = getenv("LOGNAME");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8348
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8349
	if (name && (strlen(name) < sizeof(cachedName))) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8350
	    strcpy(cachedName, name);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8351
	    firstCall = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8352
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8353
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8354
	name = cachedName;
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8355
    }
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8356
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8357
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8358
     * try a few common environment variables ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8359
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8360
    if (! name || (name[0] == 0) ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8361
	name = getenv("LOGIN");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8362
	if (! name || (name[0] == 0) ) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8363
	    name = getenv("LOGNAME");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8364
	    if (! name || (name[0] == 0) ) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8365
		name = getenv("USER");
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8366
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8367
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8368
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8369
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8370
     * nope - I really font know who you are.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8371
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8372
    if (! name || (name[0] == 0) ) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8373
	name = "you";
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8374
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8375
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8376
    RETURN ( __MKSTRING(name) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8377
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8378
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8379
     OperatingSystem getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8380
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8381
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8382
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8383
getUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8384
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8386
    "return the current users (thats you) numeric user id"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8387
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8388
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8389
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8390
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8391
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8392
    uid = getuid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8393
    RETURN ( __MKSMALLINT(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8394
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8395
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8396
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8397
     OperatingSystem getUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8398
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8399
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8401
getUserNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8402
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8403
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8404
    "return the user-name-string for a given numeric user-id.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8405
     This is the login name, not the fullName."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8406
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8407
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8408
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8409
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8410
    struct passwd *p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8411
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8412
    if (__isSmallInteger(aNumber)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8413
	p = getpwuid(__intVal(aNumber));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8414
	if (p) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8415
	    RETURN ( __MKSTRING(p->pw_name) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8416
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8417
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8418
#endif /* unix-like */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8419
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8420
    aNumber == self getUserID ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8421
	^ self getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8422
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8423
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8424
    ^ '? (' , aNumber printString , ')'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8425
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8426
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8427
     OperatingSystem getUserNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8428
     OperatingSystem getUserNameFromID:100
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8429
     OperatingSystem getUserNameFromID:9991 
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8430
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8431
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8432
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8433
userInfoOf:aNameOrID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8434
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8435
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8436
    "return a dictionary filled with userinfo. The argument can be either
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8437
     a string with the users name or its numeric id.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8438
     Notice, that not all systems provide (all of) this info;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8439
     DOS systems return nothing; 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8440
     non-SYSV4 systems have no age/comment.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8441
     Portable applications may want to check the systemType and NOT depend
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8442
     on all keys to be present in the returned dictionary.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8443
     Another notice: on some systems (SYSV4), the gecos field includes multiple
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8444
     entries (i.e. not just the name), separated by commas. You may want to
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8445
     extract any substring, up to the first comma to get the real life name."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8446
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8447
    |info name passw uid gid age comment
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8448
     gecos dir shell|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8449
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8450
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8451
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8452
    struct passwd *buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8453
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8454
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8455
    if (__isString(aNameOrID)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8456
	buf = getpwnam(__stringVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8457
    } else if (__isSmallInteger(aNameOrID)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8458
	buf = getpwuid(__intVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8459
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8460
	buf = (struct passwd *)0;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8461
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8462
    if (buf) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8463
	name = __MKSTRING(buf->pw_name);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8464
#  ifndef NO_PWD_PASSWD
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8465
	passw = __MKSTRING(buf->pw_passwd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8466
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8467
#  ifdef SYSV4
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8468
	age = __MKSTRING(buf->pw_age);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8469
	comment = __MKSTRING(buf->pw_comment);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8470
#  endif
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8471
	dir = __MKSTRING(buf->pw_dir);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8472
#  ifndef NO_PWD_GECOS
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8473
	gecos = __MKSTRING(buf->pw_gecos);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8474
#  endif
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8475
	shell = __MKSTRING(buf->pw_shell);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8476
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8477
	uid = __MKSMALLINT(buf->pw_uid);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8478
	gid = __MKSMALLINT(buf->pw_gid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8479
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8480
# endif /* has PWD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8481
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8482
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8483
    name isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8484
	aNameOrID == self getUserID ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8485
	    name := self getLoginName
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8486
	].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8487
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8488
    name notNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8489
	info at:#name put:name.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8490
    ] ifFalse:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8491
	info at:#name put:'unknown'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8492
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8493
    passw notNil ifTrue:[info at:#passwd put:passw].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8494
    age notNil ifTrue:[info at:#age put:age].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8495
    comment notNil ifTrue:[info at:#comment put:comment].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8496
    gecos notNil ifTrue:[info at:#gecos put:gecos].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8497
    shell notNil ifTrue:[info at:#shell put:shell].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8498
    dir isNil ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8499
	aNameOrID == self getUserID ifTrue:[
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8500
	    dir := self getHomeDirectory
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8501
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8502
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8503
    dir notNil ifTrue:[info at:#dir put:dir].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8504
    uid notNil ifTrue:[info at:#uid put:uid].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8505
    gid  notNil ifTrue:[info at:#gid put:gid].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8506
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8507
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8508
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8509
     OperatingSystem userInfoOf:'root'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8510
     OperatingSystem userInfoOf:1
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8511
     OperatingSystem userInfoOf:'claus' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8512
     OperatingSystem userInfoOf:'fooBar' 
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8513
     OperatingSystem userInfoOf:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8514
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8515
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8516
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8517
!UnixOperatingSystem class methodsFor:'waiting for events'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8518
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8519
blockingChildProcessWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8520
     "return true, if childProcessWait: blocks, if no children are ready.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8521
      On those systems, we must be somewhat careful when looking out for
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8522
      a subprocesses status (to avoid blocking)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8523
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8524
%{ /*NOCONTEXT*/
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  8525
#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8526
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8527
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8528
    RETURN(true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8529
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8530
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8531
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8532
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8533
childProcessWait:blocking pid:pidToWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8534
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8535
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8536
    "get status changes from child processes.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8537
     Return an OSProcessStatus or nil, if no process has terminated.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8538
     If blocking is true, we wait until a process changed state, 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8539
     otherwise we return immediately.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8540
     Note that win32 needs to know the HANDLE of the process on which 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8541
     it waits.  In case of an error, THIS ALWAYS WAITS and then times out."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8542
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8543
    |pid status code core|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8544
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8545
    int p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8546
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8547
#if defined(HAS_WAITPID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8548
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8549
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8550
#   define __WAIT     waitpid(-1, &s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8551
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8552
#else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8553
# if defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8554
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8555
    union wait s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8556
#   define __WAIT      wait3(&s, blocking == true ? WUNTRACED : WNOHANG|WUNTRACED, 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8557
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8558
# else /* neither waitpid, nor wait3; use wait, which is blocking */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8559
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8560
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8561
#   define __WAIT      wait(&s)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8562
#   define __BLOCKING_WAIT__ 1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8563
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8564
    if (blocking != true) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8565
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8566
	 * We do not support nonBlocking waits, so signal an error
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8567
	 * Sorry about the goto, but with all these ifdefs ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8568
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8569
	goto done;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8570
    }
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8571
# endif /*!HAS_WAIT3*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8572
#endif  /*!HAS_WAITPID*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8573
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8574
#if !defined(WIFEXITED)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8575
# define WIFEXITED(stat)      (((int)((stat)&0377))==0)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8576
# define WIFSIGNALED(stat)    (((int)((stat)&0377))>0&&((int)(((stat)>>8)&0377))==0)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8577
# define WIFSTOPPED(stat)     (((int)((stat)&0377))==0177&&((int)(((stat)>>8)&0377))!=0)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8578
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8579
# define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8580
# define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8581
# define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8582
#endif /*!WIFEXITED*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8583
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8584
#if !defined(WCOREDUMP)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8585
   /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8586
    * some systems lack that definition, although the field is there ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8587
    */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8588
# if defined(HAS_WAIT3)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8589
#  define WCOREDUMP(status)    (((union __wait*)&(status))->__w_coredump)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8590
# else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8591
#  define WCOREDUMP(status)    ((int)(((status)>>8)&0200))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8592
# endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8593
#endif /*!WCOREDUMP*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8594
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8595
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8596
    __BEGIN_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8597
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8599
    do {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8600
	p = __WAIT;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8601
    } while (p == -1 && errno == EINTR);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8602
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8603
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8604
    __END_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8605
#  undef __BLOCKING_WAIT__
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8606
#endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8607
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8608
#undef __WAIT
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8609
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8610
    if (p == 0)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8611
	RETURN(nil)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8612
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8613
    if (p == -1) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8614
	if (errno == ECHILD)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8615
	    RETURN(nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8616
    } else {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8617
	pid = __MKSMALLINT(p);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8618
	if (WIFEXITED(s)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8619
	    status = @symbol(exit);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8620
	    code = __MKSMALLINT(WEXITSTATUS(s));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8621
	    core = WCOREDUMP(s) ? true : false;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8622
	} else if (WIFSIGNALED(s)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8623
	    status = @symbol(signal);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8624
	    code = __MKSMALLINT(WTERMSIG(s));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8625
	} else if (WIFSTOPPED(s)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8626
	    status = @symbol(stop);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8627
	    code = __MKSMALLINT(WSTOPSIG(s));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8628
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8629
#if defined(WIFCONTINUED)
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8630
	else if (WIFCONTINUED(s)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8631
	    status = @symbol(continue);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8632
	} 
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8633
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8634
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8635
done: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8636
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8637
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8638
    (status isNil or:[pid isNil]) ifTrue:[
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8639
	^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8640
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8641
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8642
"/ Transcript show:'pid: '; show:pid; show:' status: '; show:status;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8643
"/ show:' code: '; show:code; show:' core:'; showCR:core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8644
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8645
    ^ OSProcessStatus pid:pid status:status code:code core:core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8646
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8647
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8648
     OperatingSystem childProcessWait:false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8649
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8650
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8651
    "Created: 5.1.1996 / 16:39:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8652
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8653
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8654
numAvailableForReadOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8655
    "return the number of bytes available for reading, without blocking."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8656
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8657
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8658
#ifdef NOTDEF   /* does not work ... */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8659
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8660
     * if available, try FIONREAD first, which is usually done faster.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8661
     */
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  8662
# if defined(FIONREAD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8663
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8664
	int n;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8665
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8666
	if (__isSmallInteger(fd)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8667
	    if (ioctl(__intVal(fd), FIONREAD, &n) >= 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8668
		RETURN (__MKINT(n));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8669
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8670
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8671
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8672
# endif /* FIONREAD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8673
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8674
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8675
    ^ (self readCheck:fd) ifTrue:[1] ifFalse:[0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8676
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8677
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8678
readCheck:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8679
    "return true, if data is available on a filedescriptor 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8680
     (i.e. read is possible without blocking).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8681
     This depends on a working select or FIONREAD to be provided by the OS."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8682
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8683
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8684
#ifdef NOTDEF   /* does not work ... */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8685
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8686
     * if available, try FIONREAD first, which is usually done faster.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8687
     */
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  8688
# if defined(FIONREAD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8689
    {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8690
	int n;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8691
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8692
	if (__isSmallInteger(fd)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8693
	    if (n = ioctl(__intVal(fd), FIONREAD)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8694
		printf("FIONREAD returns %d\n", n);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8695
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8696
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8697
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8698
# endif /* FIONREAD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8699
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8700
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8701
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8702
    ^ super readCheck:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8703
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8704
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8705
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8706
    "wait for any fd in readFdArray (an Array of integers) to become ready for 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8707
     reading, writeFdArray to become ready for writing, or exceptFdArray to 
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8708
     arrive exceptional data (i.e. out-of-band data).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8709
     Timeout after t milliseconds or, if the timeout time is 0, immediately..
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8710
     Empty fd-sets will always wait. Zero time can be used to poll file-
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8711
     descriptors (i.e. to check if I/O possible without blocking).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8712
     Return first ready fd if I/O ok, nil if timed-out or interrupted."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8713
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8714
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8715
    fd_set rset, wset, eset;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8716
    struct timeval wt, et;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8717
    int f, maxF, i, lX, bX;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8718
    INT t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8719
    OBJ fd, retFd;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8720
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8721
    int count;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8722
    int numFds = 0;
3801
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  8723
#ifndef __isArrayLike
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  8724
# define __isArrayLike __isArray
b4b3d6a6e48f oops - isArrayLike is not yet defined
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
  8725
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8726
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8727
    if (__isSmallInteger(millis)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8728
	FD_ZERO(&rset);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8729
	FD_ZERO(&wset);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8730
	FD_ZERO(&eset);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8731
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8732
	maxF = -1;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8733
	if (__isNonNilObject(readFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8734
	    if (! __isArrayLike(readFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8735
		goto fail;    
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8736
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8737
	    count = __arraySize(readFdArray);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8738
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8739
	    for (i=0; i<count;i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8740
		fd = __ArrayInstPtr(readFdArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8741
		if (fd != nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8742
		    if (! __isSmallInteger(fd)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8743
			if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8744
			    fprintf(stderr, "[OS] warning: funny read-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8745
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8746
		    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8747
			f = __intVal(fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8748
			if ((unsigned)f < FD_SETSIZE) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8749
			    FD_SET(f, &rset);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8750
			    if (f > maxF) maxF = f;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8751
			    numFds++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8752
			} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8753
			    if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8754
				fprintf(stderr, "[OS] warning: huge read-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8755
			    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8756
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8757
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8758
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8759
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8760
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8761
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8762
	if (__isNonNilObject(writeFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8763
	    if (! __isArrayLike(writeFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8764
		goto fail;    
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8765
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8766
	    count = __arraySize(writeFdArray);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8767
	    for (i=0; i<count;i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8768
		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8769
		if (fd != nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8770
		    if (! __isSmallInteger(fd)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8771
			if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8772
			    fprintf(stderr, "[OS] warning: funny write-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8773
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8774
		    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8775
			f = __intVal(fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8776
			if ((unsigned)f < FD_SETSIZE) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8777
			    FD_SET(f, &wset);       
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8778
			    if (f > maxF) maxF = f;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8779
			    numFds++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8780
			} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8781
			    if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8782
				fprintf(stderr, "[OS] warning: huge write-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8783
			    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8784
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8785
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8786
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8787
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8788
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8789
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8790
	if (__isNonNilObject(exceptFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8791
	    if (! __isArrayLike(exceptFdArray)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8792
		goto fail;    
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8793
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8794
	    count = __arraySize(exceptFdArray);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8795
	    for (i=0; i<count;i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8796
		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8797
		if (fd != nil) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8798
		    if (! __isSmallInteger(fd)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8799
			if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8800
			    fprintf(stderr, "[OS] warning: funny except-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8801
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8802
		    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8803
			f = __intVal(fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8804
			if ((unsigned)f < FD_SETSIZE) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8805
			    FD_SET(f, &eset);       
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8806
			    if (f > maxF) maxF = f;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8807
			    numFds++;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8808
			} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8809
			    if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8810
				fprintf(stderr, "[OS] warning: huge except-fd (0x%x) given to select\n", fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8811
			    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8812
			}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8813
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8814
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8815
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8816
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8817
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8818
	t = __intVal(millis);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8819
	if (t) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8820
	    wt.tv_sec = t / 1000;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8821
	    wt.tv_usec = (t % 1000) * 1000;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8822
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8823
	    wt.tv_sec = wt.tv_usec = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8824
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8825
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8826
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8827
	 * make certain, that interrupt gets us out of the select
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8828
	 * However, we must then care for moved objects.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8829
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8830
	__BEGIN_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8831
	errno = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8832
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8833
	if (t == 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8834
	    /* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8835
	     * if there is no timeout time, we can stay here interruptable.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8836
	     */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8837
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8838
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8839
	    } while ((ret < 0) && (errno == EINTR));
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8840
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8841
	    do {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8842
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8843
		/* 
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8844
		 * for now: dont loop; if we did, we had to adjust the vt-timeval;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8845
		 * could otherwise stay in this loop forever ...
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8846
		 * Premature ret (before the time expired) must be handled by the caller.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8847
		 * A good solution is to update the wt-timeval and redo the select.
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8848
		 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8849
	    } while (0 /* (ret < 0) && (errno == EINTR) */ );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8850
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8851
	__END_INTERRUPTABLE__
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8852
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8853
	if (ret > 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8854
	    for (i=0; i <= maxF; i++) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8855
		if (FD_ISSET(i, &rset)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8856
		 || FD_ISSET(i, &wset)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8857
		 || FD_ISSET(i, &eset)) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8858
		    RETURN ( __MKSMALLINT(i) );
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8859
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8860
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8861
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8862
	    if (ret < 0) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8863
		if (errno == EINTR) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8864
		    errno = 0;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8865
		    @global(LastErrorNumber) = nil;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8866
		} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8867
		    if (@global(InfoPrinting) == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8868
			fprintf(stderr, "OS [info]: select errno = %d\n", errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8869
		    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8870
		    @global(LastErrorNumber) = __MKSMALLINT(errno);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8871
		}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8872
	    } else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8873
		@global(LastErrorNumber) = nil;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8874
	    }
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8875
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8876
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8877
	/*
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8878
	 * Return nil (means time expired or interrupted)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8879
	 */
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8880
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8881
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8882
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8883
fail: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8884
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8885
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8886
     timeout argument not integer,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8887
     or any fd-array nonNil and not an array
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8888
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8889
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8890
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8891
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8892
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8893
setBlocking:aBoolean on:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8894
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8895
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8896
    "set/clear the blocking attribute - if set (which is the default)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8897
     a read on the fileDescriptor will block until data is available.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8898
     If cleared, a read operation will immediately return with a value of
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8899
     nil."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8900
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8901
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8902
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8903
    int ret, flags;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8904
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8905
#if defined(F_GETFL) && defined(F_SETFL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8906
# if defined(FNDELAY)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8907
    if (__isSmallInteger(fd)) {
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8908
	int f = __intVal(fd);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8909
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8910
	flags = fcntl(f, F_GETFL, 0);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8911
	if (aBoolean == true) {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8912
	    ret = fcntl(f, F_SETFL, flags & ~FNDELAY);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8913
	} else {
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8914
	    ret = fcntl(f, F_SETFL, flags | FNDELAY);
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8915
	}
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8916
	if (ret >= 0) ret = flags;
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  8917
	RETURN ( __MKSMALLINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8918
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8919
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8920
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8921
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8922
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8923
     fd argument not integer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8924
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8925
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8926
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8927
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8928
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'change & update'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8929
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8930
update:aspect with:argument from:anObject
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8931
    "one of our registered handles has been collected"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8932
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8933
    aspect == #ElementExpired ifTrue:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8934
        OpenFiles keysAndValuesDo:[:fd :handle |
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8935
            handle == 0 ifTrue:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8936
                "Have to close the file descriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8937
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8938
                OperatingSystem closeFd:fd.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8939
                OpenFiles at:fd put:nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8940
            ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8941
        ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8942
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8943
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8944
    "Created: 30.9.1997 / 12:57:35 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8945
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8946
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8947
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8948
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8949
initialize
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8950
     OpenFiles := WeakArray new:10.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8951
     OpenFiles addDependent:self. 
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8952
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8953
     "self initialize"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8954
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8955
    "Created: 26.9.1997 / 17:15:50 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8956
    "Modified: 30.9.1997 / 12:40:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8957
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8958
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8959
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'instance creation'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8960
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8961
for:aFileDescriptor
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8962
    "create an instance of myself for a given fileDescriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8963
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8964
    ^ self new for:aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8965
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8966
    "Created: 30.9.1997 / 14:00:00 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8967
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8968
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8969
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'error handling'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8970
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8971
error:anError
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8972
    "got an error with anInteger as error number"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8973
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8974
    anError isInteger ifTrue:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8975
        ^ UnixOperatingSystem errorHolderForNumber:anError
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8976
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8977
    self primitiveFailed:anError.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8978
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8979
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8980
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'file access'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8981
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8982
close
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8983
    "close the descriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8984
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8985
    |desc|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8986
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8987
    desc := fd.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8988
    self invalidate.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8989
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8990
    ^ OperatingSystem closeFd:desc.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8991
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8992
    "Modified: 30.9.1997 / 13:06:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8993
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8994
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8995
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8996
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8997
for:aFileDescriptor
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8998
    "create file for a handle"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  8999
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9000
    |oldHandle|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9001
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9002
    fd := aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9003
    oldHandle := OpenFiles at:aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9004
    (oldHandle notNil and:[oldHandle ~~ self]) ifTrue:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9005
        oldHandle invalidate.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9006
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9007
    self register.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9008
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9009
    "Created: 26.9.1997 / 17:14:40 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9010
    "Modified: 30.9.1997 / 12:41:43 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9011
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9012
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9013
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'input/output'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9014
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9015
readBytes:count into:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9016
    "read count bytes into a byte-buffer;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9017
     Return the number of bytes read.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9018
     The read is non-blocking. If the operation would block
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9019
     either an incomplete count or nil will be returned.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9020
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9021
     An exception is raised on any other error"
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9022
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9023
    |error|
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9024
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9025
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9026
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9027
    int nRead = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9028
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9029
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9030
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9031
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9032
    if (! __isSmallInteger(__INST(fd))) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9033
        error = @symbol(errorNotOpen);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9034
        goto bad;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9035
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9036
    if (! __bothSmallInteger(count, firstIndex)) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9037
        error = @symbol(badArgument);
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9038
        goto bad;
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9039
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9040
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9041
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9042
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9043
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9044
    if (fd < 0) {
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9045
        error = @symbol(internalError);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9046
        goto bad;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9047
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9048
    if (__isExternalBytes(aByteBuffer)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9049
        OBJ sz;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9050
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9051
        nInstBytes = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9052
        extPtr = (char *)(__externalBytesAddress(aByteBuffer));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9053
        sz = __externalBytesSize(aByteBuffer);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9054
        if (__isSmallInteger(sz)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9055
            objSize = __smallIntegerVal(sz);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9056
        } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9057
            objSize = -1; /* unknown */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9058
        }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9059
    } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9060
        OBJ oClass;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9061
        int nInstVars;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9062
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9063
        oClass = __Class(aByteBuffer);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9064
        switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9065
            case BYTEARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9066
            case WORDARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9067
            case LONGARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9068
            case SWORDARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9069
            case SLONGARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9070
            case FLOATARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9071
            case DOUBLEARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9072
                break;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9073
            default:
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9074
                error = @symbol(badArgument1);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9075
                goto bad;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9076
        }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9077
        extPtr = (char *)0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9078
        nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9079
        nInstBytes = __OBJS2BYTES__(nInstVars);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9080
        objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9081
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9082
    if ((offs >= 0)
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9083
        && (cnt >= 0)
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9084
        && ((objSize == -1) || (objSize >= (cnt + offs)))) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9085
        nRead = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9086
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9087
        do {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9088
            int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9089
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9090
            if (extPtr) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9091
                n = read(fd, extPtr+offs, cnt);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9092
            } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9093
                char *bp;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9094
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9095
                /*
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9096
                 * on interrupt, anObject may be moved to another location.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9097
                 * So we recompute the byte-address here.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9098
                 */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9099
                bp = __ByteArrayInstPtr(aByteBuffer)->ba_element + nInstBytes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9100
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9101
                n = read(fd, bp + offs, cnt);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9102
            }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9103
            if (n > 0) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9104
                cnt -= n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9105
                offs += n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9106
                nRead += n;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9107
            } else if (n == 0) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9108
                break;
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9109
            } else if (n < 0) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9110
                if (0
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9111
#ifdef EWOULDBLOCK
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9112
                    || errno == EWOULDBLOCK
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9113
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9114
#ifdef EAGAIN
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9115
                    || errno == EAGAIN
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9116
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9117
                ) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9118
                     RETURN(nil);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9119
                }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9120
                if (errno != EINTR) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9121
                     error = __mkSmallInteger(errno);
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9122
                     goto bad;
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9123
                }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9124
                __HANDLE_INTERRUPTS__;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9125
            }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9126
        } while (cnt > 0);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9127
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9128
        RETURN (__mkSmallInteger(nRead));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9129
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9130
bad: ;   
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9131
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9132
    ^ self error:error.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9133
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9134
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9135
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9136
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9137
     h := OperatingSystem openFileForRead:'/etc/hosts'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9138
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9139
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9140
     Transcript show:n; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9141
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9142
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9143
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9144
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9145
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9146
     h := OperatingSystem openFileForRead:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9147
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9148
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9149
     Transcript show:n printString; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9150
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9151
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9152
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9153
writeBytes:count from:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9154
    "write count bytes from a byte-buffer;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9155
     Return the number of bytes written (negative on error)"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9156
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9157
    |error|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9158
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9159
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9160
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9161
    int nWritten = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9162
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9163
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9164
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9165
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9166
    if (! __isSmallInteger(__INST(fd))) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9167
        error = @symbol(errorNotOpen);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9168
        goto bad;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9169
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9170
    if (! __bothSmallInteger(count, firstIndex)) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9171
        error = @symbol(badArgument);
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9172
        goto bad;
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9173
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9174
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9175
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9176
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9177
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9178
    if (fd < 0) {
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9179
        error = @symbol(internalError);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9180
        goto bad;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9181
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9182
    if (__isExternalBytes(aByteBuffer)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9183
        OBJ sz;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9184
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9185
        nInstBytes = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9186
        extPtr = (char *)(__externalBytesAddress(aByteBuffer));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9187
        sz = __externalBytesSize(aByteBuffer);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9188
        if (__isSmallInteger(sz)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9189
            objSize = __smallIntegerVal(sz);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9190
        } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9191
            objSize = -1; /* unknown */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9192
        }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9193
    } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9194
        OBJ oClass;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9195
        int nInstVars;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9196
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9197
        oClass = __Class(aByteBuffer);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9198
        switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9199
            case BYTEARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9200
            case WORDARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9201
            case LONGARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9202
            case SWORDARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9203
            case SLONGARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9204
            case FLOATARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9205
            case DOUBLEARRAY:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9206
                break;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9207
            default:
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9208
                error = @symbol(badArgument1);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9209
                goto bad;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9210
        }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9211
        extPtr = (char *)0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9212
        nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9213
        nInstBytes = __OBJS2BYTES__(nInstVars);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9214
        objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9215
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9216
    if ((offs >= 0)
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9217
        && (cnt >= 0)
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9218
        && ((objSize == -1) || (objSize >= (cnt + offs)))) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9219
        nWritten = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9220
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9221
        do {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9222
            int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9223
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9224
            if (extPtr) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9225
                n = write(fd, extPtr+offs, cnt);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9226
            } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9227
                char *bp;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9228
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9229
                /*
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9230
                 * on interrupt, anObject may be moved to another location.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9231
                 * So we recompute the byte-address here.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9232
                 */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9233
                bp = __ByteArrayInstPtr(aByteBuffer)->ba_element + nInstBytes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9234
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9235
                n = write(fd, bp + offs, cnt);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9236
            }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9237
            if (n > 0) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9238
                cnt -= n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9239
                offs += n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9240
                nWritten += n;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9241
            } else if (n == 0) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9242
                break;
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9243
            } else if (n < 0) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9244
                if (0
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9245
#ifdef EWOULDBLOCK
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9246
                    || errno == EWOULDBLOCK
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9247
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9248
#ifdef EAGAIN
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9249
                    || errno == EAGAIN
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9250
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9251
                ) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9252
                     RETURN(nil);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9253
                }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9254
                if (errno != EINTR) {
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9255
                     error = __mkSmallInteger(errno);
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9256
                     goto bad;
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9257
                }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9258
                __HANDLE_INTERRUPTS__;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9259
            }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9260
        } while (cnt > 0);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9261
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9262
        RETURN (__mkSmallInteger(nWritten));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9263
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9264
bad: ;   
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9265
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9266
    ^ self error:error
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9267
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9268
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9269
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9270
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9271
     h := OperatingSystem createFileForReadWrite:'/tmp/xx'.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9272
     buff := '12345678901234567890'.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9273
     n := h writeBytes:10 from:buff startingAt:1.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9274
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9275
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9276
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9277
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9278
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9279
     h := OperatingSystem createFileForReadWrite:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9280
     buff := '12345678901234567890'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9281
     n := h writeBytes:10 from:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9282
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9283
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9284
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9285
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'misc functions'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9286
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9287
readCheck
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9288
    "return true, if data is available on a filedescriptor 
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9289
     (i.e. read is possible without blocking).
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9290
     This depends on a working select or FIONREAD to be provided by the OS."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9291
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9292
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9293
    /*
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9294
     * if available, try FIONREAD first, which is usually done faster.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9295
     */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9296
# ifdef FIONREAD
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9297
    {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9298
        int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9299
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9300
        if (__isSmallInteger(__INST(fd))) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9301
            if (n = ioctl(__intVal(__INST(fd)), FIONREAD)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9302
                printf("FIONREAD returns %d\n", n);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9303
            }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9304
        }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9305
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9306
# endif /* FIONREAD */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9307
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9308
# ifdef __VMS__
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9309
#  ifdef DOES_NOT_WORK_YET
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9310
    {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9311
        /*
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9312
         * do a sys$qio ..
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9313
         * fd here is suposed to be a channel nr.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9314
         */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9315
        struct IOSB iosb;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9316
        int status;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9317
        int channel;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9318
        struct typahdask sensebuf;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9319
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9320
        if (__isSmallInteger(fd)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9321
            channel = __intVal(fd);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9322
            status = SYS$QIO(0, /* efn */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9323
                             channel,
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9324
                             IO$_SENSEMODE | IO$M_TYPEAHDCNT,
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9325
                             &iosb,
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9326
                             0, /* ast */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9327
                             0, /* ast arg */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9328
                             &sensebuf,         /* data */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9329
                             sizeof(sensebuf),  /* data size */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9330
                             0, 0, 0, 0);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9331
            if (status != SS$_NORMAL) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9332
                fprintf(stderr, "OS [info]: SYS$QIO failed on %d\n", channel);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9333
            } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9334
                fprintf(stderr, "sys$QIO -> %d\n", sensebuf.typcnt);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9335
            }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9336
        }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9337
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9338
#  endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9339
# endif /* __VMS__ */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9340
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9341
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9342
    OperatingSystem supportsSelect ifFalse:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9343
        "/ mhmh - what should we do then ?
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9344
        "/ For now, return true as if data was present,
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9345
        "/ and let the thread fall into the read.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9346
        "/ It will then (hopefully) be desceduled there and
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9347
        "/ effectively polling for input.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9348
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9349
        ^ true
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9350
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9351
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9352
    (OperatingSystem selectOnAnyReadable:(Array with:fd)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9353
                     writable:nil
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9354
                    exception:nil
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9355
                  withTimeOut:0) == fd
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9356
        ifTrue:[^ true].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9357
    ^ false
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9358
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9359
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9360
selectWithTimeOut:millis
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9361
    "wait for aFileDesriptor to become ready; timeout after t milliseconds.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9362
     Return true, if i/o ok, false if timed-out or interrupted.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9363
     With 0 as timeout argument, this can be used to check for availability
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9364
     of read-data.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9365
     Experimental."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9366
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9367
    ^ OperatingSystem selectOnAnyReadable:(Array with:fd)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9368
                      writable:(Array with:fd)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9369
                     exception:nil
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9370
                   withTimeOut:millis
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9371
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9372
    "Created: 1.10.1997 / 08:51:11 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9373
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9374
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9375
setBlocking:aBoolean
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9376
    "{ Pragma: +optSpace }"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9377
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9378
    "set/clear the blocking attribute - if set (which is the default)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9379
     a read on the fileDescriptor will block until data is available.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9380
     If cleared, a read operation will immediately return with a value of
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9381
     nil if no data is available."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9382
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9383
    |err|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9384
%{  
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9385
    int ret, flags;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9386
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9387
#if defined(F_GETFL) && defined(F_SETFL)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9388
# if defined(O_NDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9389
#  define DELAY O_NDELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9390
# else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9391
#  if defined(FNDELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9392
#   define DELAY FNDELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9393
#  endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9394
# endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9395
# if defined(DELAY)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9396
    if (__isSmallInteger(__INST(fd))) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9397
        int f = __intVal(__INST(fd));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9398
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9399
        flags = fcntl(f, F_GETFL, 0);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9400
        if (aBoolean == true) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9401
            ret = fcntl(f, F_SETFL, flags & ~DELAY);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9402
        } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9403
            ret = fcntl(f, F_SETFL, flags | DELAY);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9404
        }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9405
        if (ret >= 0) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9406
            RETURN(__MKSMALLINT(flags)); 
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9407
        } else {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9408
            err = __MKSMALLINT(errno);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9409
        }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9410
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9411
# undef DELAY
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9412
# endif /* DELAY */
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9413
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9414
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9415
    err notNil ifTrue:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9416
        self error:err
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9417
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9418
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9419
     fd argument not integer
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9420
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9421
    ^ self primitiveFailed
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9422
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9423
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9424
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9425
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9426
writeCheck
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9427
    "return true, if filedescriptor can be written without blocking"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9428
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9429
    OperatingSystem supportsSelect ifFalse:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9430
        "/ mhmh - what should we do then ?
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9431
        "/ For now, return true as if data was present,
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9432
        "/ and let the thread fall into the write.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9433
        "/ It will then (hopefully) be desceduled there and
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9434
        "/ effectively polling for output.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9435
        ^ true
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9436
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9437
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9438
    (OperatingSystem selectOnAnyReadable:nil
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9439
                     writable:(Array with:fd)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9440
                    exception:nil
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9441
                  withTimeOut:0) == fd
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9442
        ifTrue:[^ true].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9443
    ^ false
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9444
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9445
    "Created: 1.10.1997 / 08:49:24 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9446
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9447
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9448
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'private accessing'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9449
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9450
setFileDescriptor:anInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9451
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9452
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9453
    if (__isSmallInteger(anInteger)) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9454
        __externalAddressVal(self) = (OBJ)(__smallIntegerVal(anInteger));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9455
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9456
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9457
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9458
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9459
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9460
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9461
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'queries'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9462
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9463
isValid
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9464
    "answer true, if the handle is valid, i.e. connected to
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9465
     a file or some other OS object"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9466
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9467
    ^ fd notNil
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9468
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9469
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9470
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'registering'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9471
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9472
register
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9473
    "register myself as an open file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9474
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9475
    |sz old|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9476
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9477
    sz := OpenFiles size.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9478
    fd > sz ifTrue:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9479
        "grow for more descriptors"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9480
        old := OpenFiles.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9481
        OpenFiles := WeakArray new:(sz * 2).
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9482
        old removeDependent:(self class).
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9483
        OpenFiles addDependent:(self class).
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9484
        old keysAndValuesDo:[:index :elem|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9485
            "be careful to not overwrite new entries in OpenFiles"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9486
            elem notNil ifTrue:[
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9487
                OpenFiles at:index put:elem.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9488
            ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9489
        ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9490
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9491
    OpenFiles at:fd put:self.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9492
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9493
    "Created: 30.9.1997 / 12:51:48 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9494
    "Modified: 30.9.1997 / 12:58:37 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9495
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9496
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9497
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'releasing'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9498
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9499
invalidate
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9500
    "a file handle has become invalid"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9501
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9502
    OpenFiles at:fd put:nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9503
    fd := nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9504
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9505
    "Created: 30.9.1997 / 12:37:26 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9506
    "Modified: 30.9.1997 / 12:42:16 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9507
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9508
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9509
!UnixOperatingSystem::FilePointerHandle class methodsFor:'documentation'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9510
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9511
version
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9512
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.104 2001-12-11 20:21:45 stefan Exp $'
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9513
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9514
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9515
!UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9516
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9517
closeFile
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9518
    "close the underlying file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9519
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9520
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9521
    FILE *f = (FILE *)(__externalAddressVal(self));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9522
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9523
    if (f) {
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9524
        __externalAddressVal(self) = NULL;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9525
        fclose(f);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9526
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9527
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9528
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9529
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9530
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9531
!UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9532
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9533
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9534
    ^ self basicNew
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9535
	type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP 
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9536
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9537
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9538
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9539
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9540
accessed
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9541
    "return accessed"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9542
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9543
    ^ accessed
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9544
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9545
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9546
alternativeName
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9547
    "return the files other name (DOS name on windows).
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9548
     Nil if there is no other name"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9549
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9550
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9551
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9552
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9553
fixedHeaderSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9554
    "return the fixedHeaderSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9555
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9556
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9557
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9558
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9559
gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9560
    "return gid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9561
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9562
    ^ gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9563
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9564
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9565
id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9566
    "return id"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9567
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9568
    ^ id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9569
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9570
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9571
mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9572
    "return mode"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9573
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9574
    ^ mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9575
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9576
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9577
modified
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9578
    "return modified"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9579
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9580
    ^ modified
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9581
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9582
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9583
path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9584
    "for symbolic links only: return the path where the symbolic link points to"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9585
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9586
    ^ path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9587
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9588
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9589
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9590
recordAttributes
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9591
    "return the recordAttributes (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9592
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9593
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9594
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9595
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9596
recordFormat
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9597
    "return the recordFormat (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9598
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9599
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9600
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9601
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9602
recordFormatNumeric
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9603
    "return the recordFormat as numeric (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9604
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9605
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9606
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9607
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9608
recordSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9609
    "return the recordSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9610
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9611
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9612
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9613
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9614
size
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9615
    "return size"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9616
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9617
    ^ size
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9618
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9619
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9620
statusChanged
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9621
    "return statusChanged"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9622
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9623
    ^ statusChanged
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9624
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9625
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9626
type
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9627
    "return type"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9628
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9629
    ^ type
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9630
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9631
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9632
uid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9633
    "return uid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9634
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9635
    ^ uid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9636
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9637
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9638
!UnixOperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9639
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9640
at:key
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9641
    "backward compatibility access: in previous releases, IdentityDictionaries
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9642
     were used to hold my information. Allow access via key messages.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9643
     This method will vanish - use the proper access protocol."
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9644
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9645
    ^ self perform:key
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9646
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9647
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9648
!UnixOperatingSystem::FileStatusInfo methodsFor:'private accessing'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9649
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9650
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9651
    type := t.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9652
    mode := m.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9653
    uid := u.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9654
    gid := g.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9655
    size := s.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9656
    id := i.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9657
    accessed := aT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9658
    modified := mT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9659
    statusChanged := sT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9660
    path := lP.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9661
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
  9662
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9663
!UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9664
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9665
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9666
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9667
    This is an auxillary class, that holds information about status changes of
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9668
    operating system processes (these are no smalltalk processes!!).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9669
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9670
    [Instance variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9671
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9672
	pid     <Integer>       OS-Process identifier
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9673
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9674
	status  <Symbol>        either #exit #signal #stop #continue
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9675
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9676
	code    <Integer>       either exitcode or signalnumber
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9677
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9678
	core    <Boolean>       true if core has been dumped
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9679
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9680
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9681
    [author:]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9682
	Stefan Vogel
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9683
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9684
    [see also:]
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
  9685
	OperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9686
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9687
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9688
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9689
!UnixOperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9690
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9691
pid:pid status:status code:code core:core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9692
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9693
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9694
    ^ self new pid:pid status:status code:code core:core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9695
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9696
    "Created: 28.12.1995 / 14:16:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9697
    "Modified: 30.4.1996 / 18:25:00 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9698
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9699
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9700
processCreationFailure
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9701
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9702
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9703
    ^ self new pid:-1 status:#failure code:-1 core:false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9704
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9705
    "Created: 28.12.1995 / 14:35:29 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9706
    "Modified: 30.4.1996 / 18:25:05 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9707
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9708
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9709
!UnixOperatingSystem::OSProcessStatus methodsFor:'accessing'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9710
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9711
code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9712
    "return the exitcode / signalNumber"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9713
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9714
    ^ code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9715
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9716
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9717
    "Modified: 30.4.1996 / 18:26:23 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9718
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9719
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9720
core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9721
    "return true if core has been dumped, false otherwise"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9722
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9723
    ^ core == true
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9725
    "Modified: 28.12.1995 / 14:14:38 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9726
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9727
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9728
pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9729
    "return the pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9730
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9731
    ^ pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9732
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9733
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9734
    "Modified: 30.4.1996 / 18:26:30 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9735
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9736
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9737
status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9738
    "return status as a Symbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9739
     one of #exit #signal #stop #continue"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9740
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9741
    ^ status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9742
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9743
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9744
    "Modified: 30.4.1996 / 18:26:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9745
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9746
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9747
!UnixOperatingSystem::OSProcessStatus methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9748
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9749
pid:newPid status:newStatus code:newCode core:newCore
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9750
    pid := newPid.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9751
    status := newStatus.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9752
    code := newCode.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9753
    core := newCore.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9754
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9755
    "Created: 28.12.1995 / 14:18:22 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9756
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9757
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9758
!UnixOperatingSystem::OSProcessStatus methodsFor:'private-OS interface'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9759
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9760
code:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9761
    "set the exitCode"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9762
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9763
    code := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9764
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9765
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9766
    "Modified: 30.4.1996 / 18:25:18 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9767
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9768
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9769
core:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9770
    "set core"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9771
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9772
    core := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9773
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9774
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9775
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9776
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9777
pid:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9778
    "set pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9779
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9780
    pid := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9781
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9782
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9783
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9784
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9785
status:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9786
    "set status"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9787
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9788
    status := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9789
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9790
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9791
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9792
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9793
!UnixOperatingSystem::OSProcessStatus methodsFor:'queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9794
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9795
couldNotExecute
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9796
    "return true when a command could not be executed"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9797
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9798
    ^ status == #exit and:[code = 127].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9799
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9800
    "Created: 28.12.1995 / 15:43:17 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9801
    "Modified: 30.4.1996 / 18:27:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9802
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9803
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9804
stillAlive
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9805
    "true if process is still alive"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9806
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9807
    ^ status == #stop or:[status == #continue]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9808
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9809
    "Created: 28.12.1995 / 14:27:26 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9810
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9811
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9812
success
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9813
    "true if process terminated successfully"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9814
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9815
    ^ status == #exit and:[code = 0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9816
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9817
    "Created: 28.12.1995 / 14:13:05 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9818
    "Modified: 28.12.1995 / 14:13:41 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9819
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9820
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9821
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9822
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9823
version
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9824
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.104 2001-12-11 20:21:45 stefan Exp $'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9825
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9826
UnixOperatingSystem initialize!