UnixOperatingSystem.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 25 Nov 2013 10:37:44 +0000
branchjv
changeset 18107 d46c13a0795b
parent 18105 3a3a3e0ac47f
parent 15802 f2a9e65c3f8c
child 18112 0d7ac9096619
permissions -rw-r--r--
Merged 48ba10eeb21c and 3c118b86a6db (branch default - CVS HEAD)
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
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
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
"
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    12
"{ Package: 'stx:libbasic' }"
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
    13
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
AbstractOperatingSystem subclass:#UnixOperatingSystem
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    15
	instanceVariableNames:''
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
    16
	classVariableNames:'HostName DomainName SlowFork ForkFailed CurrentDirectory
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
    17
		LastTimeInfo LastTimeInfoSeconds LastTimeInfoMilliseconds
14590
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
    18
		LastTimeInfoIsLocal CachedMountPoints CacheMountPointsTimeStamp
18015
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
    19
		Codeset CodesetEncoder'
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    20
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    21
	category:'OS-Unix'
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    22
!
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    23
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    24
Object subclass:#FileDescriptorHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    25
	instanceVariableNames:'fd'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    26
	classVariableNames:'OpenFiles'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    27
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    28
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    29
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    30
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    31
OSFileHandle subclass:#FilePointerHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    32
	instanceVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    33
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    34
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    35
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    36
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    37
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    38
Object subclass:#FileStatusInfo
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    39
	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    40
		numLinks'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    41
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    42
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    43
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    46
Object subclass:#MountInfo
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    47
	instanceVariableNames:'mountPointPath deviceOrRemotePath fsType attributeString'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    48
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    49
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    50
	privateIn:UnixOperatingSystem
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    51
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    52
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    53
Object subclass:#OSProcessStatus
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    54
	instanceVariableNames:'pid status code core'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    55
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    56
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    57
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    60
UnixOperatingSystem::FileDescriptorHandle subclass:#SocketHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    61
	instanceVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    62
	classVariableNames:'ProtocolCache'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    63
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    64
	privateIn:UnixOperatingSystem
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    65
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    66
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
!UnixOperatingSystem primitiveDefinitions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
#if defined(_AIX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
# ifndef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
#  define WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
#ifdef LINUX
8618
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
    79
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    80
# define __xxUSE_GNU      /* new */
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    81
# undef HAS_UTS_DOMAINNAME
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
    82
# define NET_IF_SUPPORT
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    83
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    84
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    85
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    86
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    87
# endif
3956
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    88
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    89
# ifndef _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    90
#  include <sys/types.h>
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    91
#  define _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    92
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
  /* use inline string macros */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
# define __STRINGDEFS__
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
    95
# include "linuxIntern.h"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
# endif
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   100
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
# define WANT_SHM
3544
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
   102
# define HAS_SETENV
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
   103
# define HAS_UNSETENV
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
   104
# include <time.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
12832
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   107
#if defined(IRIX5) || defined(ultrix) || defined(hpux) || defined(solaris)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
8901
824a89d0b5c7 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 8883
diff changeset
   111
#if defined(SYSV4) && defined(__i386__) /* e.g. unixware */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
#endif
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
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
 * notice: although many systems' include files
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
 * already block against multiple inclusion, some
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
 * do not. Therefore, this is done here again.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
 * (it does not hurt)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   120
 */
3496
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
#ifdef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
# ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
#  include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
#  define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
# endif
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
# include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
# define _ERRNO_H_INCLUDED_
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
# include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
# define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
#endif /* WANT_REALPATH */
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
# include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
# define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
# include <sys/ipc.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
# define _SYS_IPC_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
# include <sys/shm.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
# define _SYS_SHM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
#endif /* WANT_SHM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
#ifdef IRIX5
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
# include <sys/syssgi.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
#endif
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
#ifdef transputer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
# define unlink(f)      ((remove(f) == 0) ? 0 : -1)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
#else /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
# ifdef SYSV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
#  ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
#   include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
#   define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
#  ifndef _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
#   ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
#    include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
#    define _SYS_PARAM_H_INCLUDED_
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
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
#  ifndef _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
#   include <sys/times.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
#   define _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
#  ifndef _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
#   include <sys/file.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
#   define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
12832
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   186
#  ifndef _UNISTD_H_INCLUDED_
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   187
#   include <unistd.h>
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   188
#   define _UNISTD_H_INCLUDED_
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   189
#  endif
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   190
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   191
#  ifndef _TIME_H_INCLUDED_
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   192
#   include <time.h>
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   193
#   define _TIME_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
# else /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   198
#  ifndef _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   199
#   include <sys/time.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   200
#   define _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   201
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   202
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   203
#  ifndef _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   204
#   include <sys/types.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   205
#   define _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   206
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   207
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
# endif /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
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
# ifdef aix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
#  ifndef _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
#   include <time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
#   define _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
#  ifndef _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
#   include <sys/select.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
#   define _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
# endif /* aix */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   222
# ifdef __osx__
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   223
#  include <time.h>
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   224
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   225
struct tm {
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   226
        int     tm_sec;         /* seconds after the minute [0-60] */
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   227
        int     tm_min;         /* minutes after the hour [0-59] */
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   228
        int     tm_hour;        /* hours since midnight [0-23] */
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   229
        int     tm_mday;        /* day of the month [1-31] */
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   230
        int     tm_mon;         /* months since January [0-11] */
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   231
        int     tm_year;        /* years since 1900 */
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   232
        int     tm_wday;        /* days since Sunday [0-6] */
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   233
        int     tm_yday;        /* days since January 1 [0-365] */
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   234
        int     tm_isdst;       /* Daylight Savings Time flag */
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   235
        long    tm_gmtoff;      /* offset from CUT in seconds */
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   236
        char    *tm_zone;       /* timezone abbreviation */
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   237
};
14707
1831c2cfe742 environment for osx
Claus Gittinger <cg@exept.de>
parents: 14694
diff changeset
   238
1831c2cfe742 environment for osx
Claus Gittinger <cg@exept.de>
parents: 14694
diff changeset
   239
#  include <crt_externs.h>
1831c2cfe742 environment for osx
Claus Gittinger <cg@exept.de>
parents: 14694
diff changeset
   240
12832
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   241
# endif /* __osx__ */
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
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
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   281
# ifndef _SYS_IOCTL_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   282
#  include <sys/ioctl.h>
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   283
#  define _SYS_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
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   301
/*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   302
 * posix systems should define these ...
3496
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
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
   335
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
#  ifndef MAXPATHLEN
14370
66a4b9c492b9 Fixed: bad definition of MAXPATHLEN from PATH_MAX
Stefan Vogel <sv@exept.de>
parents: 13801
diff changeset
   337
#   ifdef PATH_MAX
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
   338
#    define MAXPATHLEN PATH_MAX
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
#   else
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
   340
#    define MAXPATHLEN 1024
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
#  endif
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
   343
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
# if defined(HAS_UNAME)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
#  include <sys/utsname.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
# if defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
#  include <stropts.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   352
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
4285
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   354
# ifndef aix
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   355
#  include <sys/termios.h>
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   356
# endif
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   357
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
 * NeXT has no pid_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
 * and no sigemptyset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
# ifdef NEXT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
   typedef int pid_t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
#  define sigemptyset(set)      ((*(set) = 0L), 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
#  define HAS_GETDOMAINNAME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
#  define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
# ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
#  undef NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
#  undef HAS_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
#  define HAS_WAIT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
#  define HAS_SIGACTION
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
 * some (BSD ?) have no timezone global,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
 * but provide the info in struct timezone.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
# if defined(ultrix) || defined(sunos) || defined(NEXT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
#  define HAS_NO_TIMEZONE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
# endif
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
   383
# if defined(__osx__)
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
   384
#  define HAS_NO_TIMEZONE
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
   385
# endif
3496
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
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
 * 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
   389
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
# ifndef SA_RESTART
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
#  define SA_RESTART    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
# ifndef SA_SIGINFO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
#  define SA_SIGINFO    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
# if defined(HAS_WAITPID) || defined(HAS_WAIT3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
#  include <sys/wait.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
# if defined(HAS_SYSINFO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
#  include <sys/systeminfo.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   405
# ifdef LINUX
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   406
#  include <linux/kernel.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
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
   422
# if defined(HAS_SYSCTL)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
   423
#  include <sys/types.h>
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
   424
#  include <sys/sysctl.h>
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
   425
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
   426
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
#endif /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
7709
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   429
#ifndef NO_SOCKET
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   430
# define __USE_GNU      // For AI_IDN in netdb.h
7709
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   431
# include <netdb.h>
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   432
#endif
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   433
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
 * 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
   436
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
#ifndef errno
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
 extern errno;
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
 * some (old ?) systems do not define this ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
#if !defined(R_OK) && !defined(_AIX)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   445
# define R_OK    4       /* Test for Read permission */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
# define W_OK    2       /* Test for Write permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
# define X_OK    1       /* Test for eXecute permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
# 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
   449
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   451
#define SIGHANDLER_ARG
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   452
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
#ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   456
#ifdef NEXT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
 * where is the timezone info ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
 */
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   463
#ifdef HAS_TM_GMTOFF
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   464
# define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   465
#else
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   466
# if defined(HAS_NO_TIMEZONE)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   467
#  if defined(HAS_NO_TM_GMTOFF)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   468
#   define TIMEZONE(tmPtr)       0
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   469
#  else
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   470
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   471
#  endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
# else
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   473
#  if defined(HAS_ALTZONE)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   474
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : altzone)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   475
#  else  /*!HAS_ALTZONE*/
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   476
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : timezone-3600)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   477
#  endif /*!HAS_ALTZONE*/
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   478
# endif
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   479
#endif
3595
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   480
#ifndef CONST
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   481
# ifdef __GNUC__
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   482
#  define CONST const
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   483
# else
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   484
#  define CONST /* nothing */
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   485
# endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   486
#endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   487
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   488
#ifndef        FORK
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   489
# if defined(HAS_VFORK)
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   490
#  define     FORK            vfork
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   491
# else
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   492
#  define     FORK            fork
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   493
# endif
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   494
#endif
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   495
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   496
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   497
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   498
/*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   499
 * Socket defines
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   500
 */
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
   501
#include "stxOSDefs.h"
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
   502
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   503
#ifdef NET_IF_SUPPORT  /* for mac address of interfaces */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   504
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   505
# ifndef _NET_IF_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   506
#  include <net/if.h>
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   507
#  define _NET_IF_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   508
# endif
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   509
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   510
# ifndef _SYS_IOCTL_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   511
#  include <sys/ioctl.h>
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   512
#  define _SYS_IOCTL_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   513
# endif
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   514
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   515
#endif /* NET_IF_SUPPORT */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   516
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   517
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   518
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   519
#if defined(TRY_AGAIN) || defined(HOST_NOT_FOUND)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   520
# define USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   521
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   522
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   523
#ifdef USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   524
# ifndef h_errno
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   525
 extern h_errno;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   526
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   527
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   528
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
%}
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
copyright
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
 COPYRIGHT (c) 1988 by Claus Gittinger
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   537
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   538
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
 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
   540
 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
   541
 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
   542
 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
   543
 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
   544
 hereby transferred.
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
    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
   551
    some of it is very specific for unix, so do not depend on
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   552
    things available here in your applications
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
    - 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
   554
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   555
    (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
   556
     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
   557
     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
   558
     You decide - portability vs. functionality)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
    [Class variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   562
	HostName        <String>        remembered hostname
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   563
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   564
	DomainName      <String>        remembered domainname
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   565
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   566
	SlowFork        <Boolean>       if set, fork and popen are avoided;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   567
					(more or less obsolete now)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   568
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   569
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   570
	CurrentDirectory <String>       remembered currentDirectories path
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
    [author:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   573
	Claus Gittinger
3496
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
    [see also:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   576
	OSProcessStatus
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   577
	Filename Date Time
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   578
	ExternalStream FileStream PipeStream Socket
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
examples
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
  various queries
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   585
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   586
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   587
	showCR:'hello ' , (OperatingSystem getLoginName)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   588
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   589
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   590
								[exBegin]
3793
aff27e755ffd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   591
    OperatingSystem isUNIXlike ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   592
	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
   593
    ] ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   594
	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
   595
    ]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   596
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   597
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   598
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   599
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   600
	showCR:'this machine is called ' , OperatingSystem getHostName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   601
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   602
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   603
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   604
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   605
	showCR:('this machine is in the '
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   606
	       , OperatingSystem getDomainName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   607
	       , ' domain')
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   608
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   609
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   610
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   611
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   612
	showCR:('this machine''s CPU is a '
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   613
	       , OperatingSystem getCPUType
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   614
	       )
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   615
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   616
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   617
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
    Transcript showCR:'executing ls command ...'.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
   619
    OperatingSystem executeCommand:'ls'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
    Transcript showCR:'... done.'.
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   621
								[exEnd]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   623
  locking a file
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
  (should be executed on two running smalltalks - not in two threads):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   625
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
    |f|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
    f := 'testFile' asFilename readWriteStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
    10 timesRepeat:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   631
	'about to lock ...' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   632
	[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   633
	  OperatingSystem
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   634
	    lockFD:(f fileDescriptor)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   635
	    shared:false
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   636
	    blocking:false
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   637
	] whileFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   638
	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   639
	    Delay waitForSeconds:1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   640
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   641
	'LOCKED ...' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   642
	Delay waitForSeconds:10.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   643
	'unlock ...' printCR.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   644
	(OperatingSystem
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   645
	    unlockFD:(f fileDescriptor)) printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   646
	Delay waitForSeconds:3.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
    ]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   648
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
!UnixOperatingSystem class methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
initialize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
    "initialize the class"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
    ObjectMemory addDependent:self.
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   658
    self initializeCachedData.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   659
!
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   660
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   661
initializeCachedData
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
    HostName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   663
    DomainName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
    LastErrorNumber := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
    PipeFailed := false.
4395
53122eb3ce70 clear ForkFailed flag; made it a classVar
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
   666
    ForkFailed := false.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   667
    SlowFork := false.
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   668
    CurrentDirectory := nil.
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   669
    self initializeCodeset.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   670
!
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   671
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   672
initializeCodeset
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   673
    "initialize the codeset, we are running under.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   674
     The codeset is determined from the environment.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   675
     The LC_CTYPE locale is set from the environment as a side effect."
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   676
    
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   677
    |codeset|
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   678
    
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   679
%{
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   680
#include <langinfo.h>
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   681
    char *__codeset;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   682
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   683
    setlocale(LC_CTYPE, "");
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   684
    __codeset = nl_langinfo(CODESET);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   685
    if (strlen(__codeset) > 0) {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   686
        codeset = __MKSTRING(__codeset);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   687
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   688
%}.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   689
    codeset notNil ifTrue:[
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   690
        codeset := codeset asLowercase.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   691
        codeset = 'utf-8' ifTrue:[
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   692
            codeset := #utf8.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   693
        ] ifFalse:[
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   694
            codeset := codeset asSymbol.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   695
        ].
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   696
    ].
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   697
    Codeset := codeset.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   698
    ^ codeset.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   699
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   700
    "
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   701
     OperatingSystem initializeCodeset
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   702
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
!
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
update:something with:aParameter from:changedObject
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
    "catch image restart and flush some cached data"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
    something == #earlyRestart ifTrue:[
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
   709
        self initializeCachedData
3496
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
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   712
    "Created: / 15.6.1996 / 15:22:37 / cg"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   713
    "Modified: / 7.1.1997 / 19:36:11 / stefan"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   714
    "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
   715
! !
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
!UnixOperatingSystem class methodsFor:'OS signal constants'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
sigABRT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
    "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
   721
     (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
   722
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   723
    ^ self signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   724
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   725
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   726
     OperatingSystem sigABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   727
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   728
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   729
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   730
sigALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
    "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
   732
     (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
   733
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   734
    ^ self signalNamed:#SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   735
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   736
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   737
     OperatingSystem sigALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   738
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   739
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   740
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   741
sigBREAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
    "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
   743
     This is an MSDOS specific signal"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   745
    ^ self signalNamed:#SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   746
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   747
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   748
     OperatingSystem sigBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   749
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
sigBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
    "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
   754
     (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
   755
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   756
    ^ self signalNamed:#SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   757
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   758
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   759
     OperatingSystem sigBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   760
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
sigCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   764
    "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
   765
     (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
   766
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   767
    ^ self signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   768
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   769
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   770
     OperatingSystem sigCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   771
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
sigCONT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
    "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
   776
     (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
   777
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   778
    ^ self signalNamed:#SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   779
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   780
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   781
     OperatingSystem sigCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   782
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
sigDANGER
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
    "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
   787
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   789
    ^ self signalNamed:#SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   790
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   791
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   792
     OperatingSystem sigDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   793
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
sigEMT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
    "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
   798
     (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
   799
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   800
    ^ self signalNamed:#SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   801
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   802
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   803
     OperatingSystem sigEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   804
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
sigFP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
    "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
   809
     (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
   810
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   811
    ^ self signalNamed:#SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   812
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   813
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   814
     OperatingSystem sigFP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   815
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
sigGRANT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
    "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
   820
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   822
    ^ self signalNamed:#SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   823
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   824
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   825
     OperatingSystem sigGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   826
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
!
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
sigHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
    "return the signal number for SIGHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
     (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
   832
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   833
    ^ self signalNamed:#SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   834
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   835
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   836
     OperatingSystem sigHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   837
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   838
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
sigILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
    "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
   843
     (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
   844
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   845
    ^ self signalNamed:#SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   846
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   847
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   848
     OperatingSystem sigILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   849
    "
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
sigINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
    "return the signal number for SIGINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
     (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
   855
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   856
    ^ self signalNamed:#SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   857
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   858
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   859
     OperatingSystem sigINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   860
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
!
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
sigIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
    "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
   865
     (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
   866
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   867
    ^ self signalNamed:#SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   868
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   869
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   870
     OperatingSystem sigIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   871
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
sigIOT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
    "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
   876
     (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
   877
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   878
    ^ self signalNamed:#SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   879
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   880
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   881
     OperatingSystem sigIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   882
    "
3496
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
sigKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
    "return the signal number for SIGKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
     (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
   888
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   889
    ^ self signalNamed:#SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   890
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   891
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   892
     OperatingSystem sigKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   893
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
sigLOST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
    "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
   898
     (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
   899
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   900
    ^ self signalNamed:#SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   901
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   902
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   903
     OperatingSystem sigLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   904
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   905
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   906
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   907
sigMIGRATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   908
    "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
   909
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   910
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   911
    ^ self signalNamed:#SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   912
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   913
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   914
     OperatingSystem sigMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   915
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   916
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   917
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
sigMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   919
    "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
   920
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   922
    ^ self signalNamed:#SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   923
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   924
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   925
     OperatingSystem sigMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   926
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   928
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   929
sigPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   930
    "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
   931
     (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
   932
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   933
    ^ self signalNamed:#SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   934
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   935
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   936
     OperatingSystem sigPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   937
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   938
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   939
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   940
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   941
sigPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
    "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
   943
     (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
   944
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   945
    ^ self signalNamed:#SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   946
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   947
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   948
     OperatingSystem sigPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   949
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   950
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
sigPRE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
    "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
   954
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   956
    ^ self signalNamed:#SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   957
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   958
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   959
     OperatingSystem sigPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   960
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   961
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
sigPROF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
    "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
   965
     (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
   966
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   967
    ^ self signalNamed:#SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   968
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   969
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   970
     OperatingSystem sigPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   971
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
sigPWR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
    "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
   976
     (not available on all systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   978
    ^ self signalNamed:#SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   979
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   980
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   981
     OperatingSystem sigPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   982
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
sigQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
    "return the signal number for SIGQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
     (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
   988
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   989
    ^ self signalNamed:#SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   990
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   991
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   992
     OperatingSystem sigQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
   993
    "
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
sigRETRACT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
    "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
   998
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1000
    ^ self signalNamed:#SIGRETRACT
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
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1003
     OperatingSystem sigRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1004
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1005
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
sigSAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
    "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
  1010
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1011
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1012
    ^ self signalNamed:#SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1013
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1014
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1015
     OperatingSystem sigSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1016
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1017
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
sigSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
    "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
  1022
     (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
  1023
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1024
    ^ self signalNamed:#SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1025
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1026
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1027
     OperatingSystem sigSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1028
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1029
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
sigSOUND
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1033
    "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
  1034
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1035
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1036
    ^ self signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1037
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1038
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1039
     OperatingSystem sigSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1040
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1041
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
sigSTOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
    "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
  1046
     (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
  1047
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1048
    ^ self signalNamed:#SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1049
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1050
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1051
     OperatingSystem sigSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1052
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1055
sigSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1056
    "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
  1057
     (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
  1058
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1059
    ^ self signalNamed:#SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1060
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1061
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1062
     OperatingSystem sigSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1063
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
sigTERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
    "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
  1068
     (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
  1069
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1070
    ^ self signalNamed:#SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1071
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1072
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1073
     OperatingSystem sigTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1074
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1075
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1076
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1077
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1078
sigTRAP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1079
    "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
  1080
     (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
  1081
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1082
    ^ self signalNamed:#SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1083
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1084
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1085
     OperatingSystem sigTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1086
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
sigTSTP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
    "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
  1091
     (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
  1092
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1093
    ^ self signalNamed:#SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1094
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1095
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1096
     OperatingSystem sigTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1097
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
sigTTIN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
    "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
  1102
     (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
  1103
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1104
    ^ self signalNamed:#SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1105
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1106
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1107
     OperatingSystem sigTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1108
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
sigTTOU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
    "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
  1113
     (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
  1114
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1115
    ^ self signalNamed:#SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1116
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1117
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1118
     OperatingSystem sigTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1119
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
sigURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
    "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
  1124
     (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
  1125
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1126
    ^ self signalNamed:#SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1127
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1128
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1129
     OperatingSystem sigURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1130
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
sigUSR1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
    "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
  1135
     (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
  1136
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1137
    ^ self signalNamed:#SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1138
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1139
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1140
     OperatingSystem sigUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1141
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1144
sigUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1145
    "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
  1146
     (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
  1147
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1148
    ^ self signalNamed:#SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1149
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1150
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1151
     OperatingSystem sigUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1152
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1154
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
sigVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
    "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
  1157
     (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
  1158
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1159
    ^ self signalNamed:#SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1160
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1161
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1162
     OperatingSystem sigVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1163
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1166
sigWINCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1167
    "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
  1168
     (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
  1169
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1170
    ^ self signalNamed:#SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1171
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1172
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1173
     OperatingSystem sigWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1174
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1175
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1176
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1177
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1178
sigXCPU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
    "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
  1180
     (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
  1181
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1182
    ^ self signalNamed:#SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1183
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1184
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1185
     OperatingSystem sigXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1186
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1187
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
sigXFSZ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1191
    "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
  1192
     (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
  1193
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1194
    ^ self signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1195
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1196
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1197
     OperatingSystem sigXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1198
    "
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
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1202
signalNamed:signalName
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1203
    "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
  1204
     Return 0 if that signal is not supported by the OS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1205
     (NOTICE: the numeric value is not the same across unix-systems,
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1206
      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
  1207
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1208
%{  /* NOCONTEXT */
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1209
#ifdef SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1210
    if (signalName == @symbol(SIGABRT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1211
	RETURN ( __mkSmallInteger(SIGABRT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1212
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1213
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1214
#ifdef SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1215
    if (signalName == @symbol(SIGALRM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1216
	RETURN ( __mkSmallInteger(SIGALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1217
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1218
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1219
#ifdef SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1220
    if (signalName == @symbol(SIGBREAK)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1221
	RETURN ( __mkSmallInteger(SIGBREAK) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1224
#ifdef SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1225
    if (signalName == @symbol(SIGBUS)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1226
	RETURN ( __mkSmallInteger(SIGBUS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1227
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1228
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1229
#ifdef SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1230
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1231
     || (signalName == @symbol(SIGCLD)) ) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1232
	RETURN ( __mkSmallInteger(SIGCHLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1233
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1234
#else
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1235
# if defined(SIGCLD)
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1236
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1237
     || (signalName == @symbol(SIGCLD)) ) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1238
	RETURN ( __mkSmallInteger(SIGCLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1239
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1240
# endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1241
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1242
#ifdef SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1243
    if (signalName == @symbol(SIGCONT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1244
	RETURN ( __mkSmallInteger(SIGCONT) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1247
#ifdef SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1248
    if (signalName == @symbol(SIGDANGER)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1249
	RETURN ( __mkSmallInteger(SIGDANGER) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1250
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1251
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1252
#ifdef SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1253
    if (signalName == @symbol(SIGEMT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1254
	RETURN ( __mkSmallInteger(SIGEMT) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1257
#ifdef SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1258
    if (signalName == @symbol(SIGFPE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1259
	RETURN ( __mkSmallInteger(SIGFPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1260
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1261
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1262
#ifdef SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1263
    if (signalName == @symbol(SIGGRANT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1264
	RETURN ( __mkSmallInteger(SIGGRANT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1265
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1266
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1267
#ifdef SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1268
    if (signalName == @symbol(SIGHUP)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1269
	RETURN ( __mkSmallInteger(SIGHUP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1270
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1271
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1272
#ifdef SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1273
    if (signalName == @symbol(SIGILL)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1274
	RETURN ( __mkSmallInteger(SIGILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1275
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1276
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1277
#ifdef SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1278
    if (signalName == @symbol(SIGINT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1279
	RETURN ( __mkSmallInteger(SIGINT) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1282
#ifdef SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1283
    if (signalName == @symbol(SIGIO)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1284
	RETURN ( __mkSmallInteger(SIGIO) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1285
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1286
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1287
#ifdef SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1288
    if (signalName == @symbol(SIGIOT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1289
	RETURN ( __mkSmallInteger(SIGIOT) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1292
#ifdef SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1293
    if (signalName == @symbol(SIGKILL)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1294
	RETURN ( __mkSmallInteger(SIGKILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1295
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1296
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1297
#ifdef SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1298
    if (signalName == @symbol(SIGLOST)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1299
	RETURN ( __mkSmallInteger(SIGLOST) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1300
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1301
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1302
#ifdef SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1303
    if (signalName == @symbol(SIGMIGRATE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1304
	RETURN ( __mkSmallInteger(SIGMIGRATE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1305
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1306
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1307
#ifdef SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1308
    if (signalName == @symbol(SIGMSG)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1309
	RETURN ( __mkSmallInteger(SIGMSG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1310
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1311
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1312
#ifdef SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1313
    if (signalName == @symbol(SIGPIPE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1314
	RETURN ( __mkSmallInteger(SIGPIPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1315
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1316
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1317
#ifdef SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1318
    if (signalName == @symbol(SIGPOLL)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1319
	RETURN ( __mkSmallInteger(SIGPOLL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1320
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1321
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1322
#ifdef SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1323
    if (signalName == @symbol(SIGPRE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1324
	RETURN ( __mkSmallInteger(SIGPRE) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1327
#ifdef SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1328
    if (signalName == @symbol(SIGPROF)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1329
	RETURN ( __mkSmallInteger(SIGPROF) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1330
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1331
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1332
#ifdef SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1333
    if (signalName == @symbol(SIGPWR)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1334
	RETURN ( __mkSmallInteger(SIGPWR) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1335
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1336
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1337
#ifdef SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1338
    if (signalName == @symbol(SIGQUIT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1339
	RETURN ( __mkSmallInteger(SIGQUIT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1340
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1341
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1342
#ifdef SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1343
    if (signalName == @symbol(SIGRETRACT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1344
	RETURN ( __mkSmallInteger(SIGRETRACT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1345
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1346
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1347
#ifdef SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1348
    if (signalName == @symbol(SIGSAK)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1349
	RETURN ( __mkSmallInteger(SIGSAK) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1352
#ifdef SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1353
    if (signalName == @symbol(SIGSEGV)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1354
	RETURN ( __mkSmallInteger(SIGSEGV) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1355
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1356
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1357
#ifdef SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1358
    if (signalName == @symbol(SIGSOUND)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1359
	RETURN ( __mkSmallInteger(SIGSOUND) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1362
#ifdef SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1363
    if (signalName == @symbol(SIGSTOP)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1364
	RETURN ( __mkSmallInteger(SIGSTOP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1365
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1366
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1367
#ifdef SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1368
    if (signalName == @symbol(SIGSYS)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1369
	RETURN ( __mkSmallInteger(SIGSYS) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1372
#ifdef SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1373
    if (signalName == @symbol(SIGTERM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1374
	RETURN ( __mkSmallInteger(SIGTERM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1375
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1376
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1377
#ifdef SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1378
    if (signalName == @symbol(SIGTRAP)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1379
	RETURN ( __mkSmallInteger(SIGTRAP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1380
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1381
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1382
#ifdef SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1383
    if (signalName == @symbol(SIGTSTP)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1384
	RETURN ( __mkSmallInteger(SIGTSTP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1385
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1386
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1387
#ifdef SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1388
    if (signalName == @symbol(SIGTTIN)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1389
	RETURN ( __mkSmallInteger(SIGTTIN) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1390
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1391
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1392
#ifdef SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1393
    if (signalName == @symbol(SIGTTOU)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1394
	RETURN ( __mkSmallInteger(SIGTTOU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1395
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1396
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1397
#ifdef SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1398
    if (signalName == @symbol(SIGURG)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1399
	RETURN ( __mkSmallInteger(SIGURG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1400
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1401
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1402
#ifdef SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1403
    if (signalName == @symbol(SIGUSR1)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1404
	RETURN ( __mkSmallInteger(SIGUSR1) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1405
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1406
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1407
#ifdef SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1408
    if (signalName == @symbol(SIGUSR2)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1409
	RETURN ( __mkSmallInteger(SIGUSR2) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1410
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1411
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1412
#ifdef SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1413
    if (signalName == @symbol(SIGVTALRM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1414
	RETURN ( __mkSmallInteger(SIGVTALRM) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1417
#ifdef SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1418
    if (signalName == @symbol(SIGWINCH)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1419
	RETURN ( __mkSmallInteger(SIGWINCH) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1420
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1421
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1422
#ifdef SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1423
    if (signalName == @symbol(SIGXCPU)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1424
	RETURN ( __mkSmallInteger(SIGXCPU) );
5404
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
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1427
#ifdef SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1428
    if (signalName == @symbol(SIGXFSZ)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1429
	RETURN ( __mkSmallInteger(SIGXFSZ) );
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1430
    }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1431
#endif
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1432
#ifdef SIGINFO
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1433
    if (signalName == @symbol(SIGINFO)) {
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1434
	RETURN ( __mkSmallInteger(SIGINFO) );
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1435
    }
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  1436
#endif
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1437
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1438
    RETURN ( __mkSmallInteger(0) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1439
%}
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1440
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1441
     OperatingSystem signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1442
     OperatingSystem signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1443
     OperatingSystem signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1444
     OperatingSystem signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1445
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1446
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1447
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1448
!UnixOperatingSystem class methodsFor:'error messages'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1449
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1450
currentErrorNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
    "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
  1452
     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
  1453
     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
  1454
     request to the OS.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1455
     Use lastErrorNumber - currentErrorNumber is invalidated by
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1456
     many, many internal calls."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1457
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1458
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1459
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1460
     RETURN ( __mkSmallInteger(errno) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1462
     "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  1463
      OperatingSystem currentErrorNumber
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
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1467
errorHolderForNumber:errNr
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1468
    "return an osErrorHolder for the given error number (as returned by a system call)."
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1469
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1470
    |sym typ holder|
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1471
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1472
%{
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1473
    /* claus:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1474
     * I made this primitive code, since errnos are not
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1475
     * standard across unixes
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1476
     */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1477
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1478
    typ = @symbol(defaultOsErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1479
    sym = @symbol(ERROR_OTHER);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1480
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1481
    if (__isSmallInteger(errNr)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1482
	switch ( __intVal(errNr)) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1483
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1484
	     * POSIX errnos - these should be defined
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1485
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1486
#ifdef EPERM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1487
	    case EPERM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1488
		sym = @symbol(EPERM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1489
		typ = @symbol(noPermissionsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1490
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1491
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1492
#ifdef ENOENT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1493
	    case ENOENT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1494
		sym = @symbol(ENOENT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1495
		typ = @symbol(nonexistentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1496
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1497
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1498
#ifdef ESRCH
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1499
	    case ESRCH:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1500
		sym = @symbol(ESRCH);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1501
		typ = @symbol(unavailableReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1502
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1503
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1504
#ifdef EINTR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1505
	    case EINTR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1506
		sym = @symbol(EINTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1507
		typ = @symbol(transientErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1508
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1509
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1510
#ifdef EIO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1511
	    case EIO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1512
		sym = @symbol(EIO);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1513
		typ = @symbol(transferFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1514
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1515
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1516
#ifdef ENXIO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1517
	    case ENXIO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1518
		sym = @symbol(ENXIO);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1519
		typ = @symbol(unavailableReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1520
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1521
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1522
#ifdef E2BIG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1523
	    case E2BIG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1524
		sym = @symbol(E2BIG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1525
		typ = @symbol(invalidArgumentsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1526
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1527
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1528
#ifdef ENOEXEC
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1529
	    case ENOEXEC:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1530
		sym = @symbol(ENOEXEC);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1531
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1532
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1533
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1534
#ifdef EBADF
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1535
	    case EBADF:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1536
		sym = @symbol(EBADF);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1537
		typ = @symbol(badAccessorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1538
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1539
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1540
#ifdef ECHILD
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1541
	    case ECHILD:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1542
		sym = @symbol(ECHILD);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1543
		typ = @symbol(informationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1544
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1545
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1546
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1547
	    case EAGAIN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1548
		sym = @symbol(EAGAIN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1549
		typ = @symbol(notReadySignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1550
		break;
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  1551
#endif
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  1552
#ifdef EOVERFLOW
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1553
	    case EOVERFLOW:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1554
		sym = @symbol(EOVERFLOW);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1555
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1556
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1557
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1558
#ifdef ENOMEM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1559
	    case ENOMEM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1560
		sym = @symbol(ENOMEM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1561
		typ = @symbol(noMemorySignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1562
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1563
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1564
#ifdef EACCES
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1565
	    case EACCES:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1566
		sym = @symbol(EACCES);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1567
		typ = @symbol(noPermissionsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1568
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1569
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1570
#ifdef EFAULT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1571
	    case EFAULT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1572
		sym = @symbol(EFAULT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1573
		typ = @symbol(invalidArgumentsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1574
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1575
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1576
#ifdef EBUSY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1577
	    case EBUSY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1578
		sym = @symbol(EBUSY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1579
		typ = @symbol(unavailableReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1580
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1581
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1582
#ifdef EEXIST
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1583
	    case EEXIST:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1584
		sym = @symbol(EEXIST);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1585
		typ = @symbol(existingReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1586
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1587
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1588
#ifdef EXDEV
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1589
	    case EXDEV:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1590
		sym = @symbol(EXDEV);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1591
		typ = @symbol(inappropriateReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1592
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1593
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1594
#ifdef ENODEV
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1595
	    case ENODEV:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1596
		sym = @symbol(ENODEV);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1597
		typ = @symbol(inaccessibleSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1598
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1599
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1600
#ifdef ENOTDIR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1601
	    case ENOTDIR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1602
		sym = @symbol(ENOTDIR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1603
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1604
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1605
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1606
#ifdef EISDIR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1607
	    case EISDIR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1608
		sym = @symbol(EISDIR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1609
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1610
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1611
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1612
#ifdef EINVAL
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1613
	    case EINVAL:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1614
		sym = @symbol(EINVAL);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1615
		typ = @symbol(invalidArgumentsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1616
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1617
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1618
#ifdef ENFILE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1619
	    case ENFILE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1620
		sym = @symbol(ENFILE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1621
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1622
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1623
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1624
#ifdef EMFILE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1625
	    case EMFILE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1626
		sym = @symbol(EMFILE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1627
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1628
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1629
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1630
#ifdef ENOTTY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1631
	    case ENOTTY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1632
		sym = @symbol(ENOTTY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1633
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1634
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1635
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1636
#ifdef EFBIG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1637
	    case EFBIG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1638
		sym = @symbol(EFBIG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1639
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1640
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1641
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1642
#ifdef ENOSPC
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1643
	    case ENOSPC:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1644
		sym = @symbol(ENOSPC);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1645
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1646
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1647
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1648
#ifdef ESPIPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1649
	    case ESPIPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1650
		sym = @symbol(ESPIPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1651
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1652
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1653
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1654
#ifdef EROFS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1655
	    case EROFS:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1656
		sym = @symbol(EROFS);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1657
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1658
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1659
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1660
#ifdef EMLINK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1661
	    case EMLINK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1662
		sym = @symbol(EMLINK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1663
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1664
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1665
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1666
#ifdef EPIPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1667
	    case EPIPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1668
		sym = @symbol(EPIPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1669
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1670
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1671
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1672
#ifdef EDOM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1673
	    case EDOM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1674
		sym = @symbol(EDOM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1675
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1676
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1677
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1678
#ifdef ERANGE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1679
	    case ERANGE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1680
		sym = @symbol(ERANGE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1681
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1682
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1683
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1684
#ifdef EDEADLK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1685
# if EDEADLK != EWOULDBLOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1686
	    case EDEADLK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1687
		sym = @symbol(EDEADLK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1688
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1689
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1690
# endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1691
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1692
#ifdef ENAMETOOLONG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1693
	    case ENAMETOOLONG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1694
		sym = @symbol(ENAMETOOLONG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1695
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1696
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1697
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1698
#ifdef ENOLCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1699
	    case ENOLCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1700
		sym = @symbol(ENOLCK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1701
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1702
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1703
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1704
#ifdef ENOSYS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1705
	    case ENOSYS:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1706
		sym = @symbol(ENOSYS);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1707
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1708
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1709
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1710
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1711
	    case ENOTEMPTY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1712
		sym = @symbol(ENOTEMPTY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1713
		typ = @symbol(inappropriateReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1714
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1715
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1716
#ifdef EILSEQ
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1717
	    case EILSEQ:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1718
		sym = @symbol(EILSEQ);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1719
		typ = @symbol(transferFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1720
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1721
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1722
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1723
	     * XPG3 errnos - defined on most systems
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1724
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1725
#ifdef ENOTBLK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1726
	    case ENOTBLK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1727
		sym = @symbol(ENOTBLK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1728
		typ = @symbol(inappropriateReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1729
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1730
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1731
#ifdef ETXTBSY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1732
	    case ETXTBSY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1733
		sym = @symbol(ETXTBSY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1734
		typ = @symbol(inaccessibleSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1735
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1736
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1737
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1738
	     * some others
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1739
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1740
#ifdef EWOULDBLOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1741
	    case EWOULDBLOCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1742
		sym = @symbol(EWOULDBLOCK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1743
		typ = @symbol(notReadySignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1744
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1745
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1746
#ifdef ENOMSG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1747
	    case ENOMSG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1748
		sym = @symbol(ENOMSG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1749
		typ = @symbol(noDataSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1750
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1751
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1752
#ifdef ELOOP
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1753
	    case ELOOP:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1754
		sym = @symbol(ELOOP);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1755
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1756
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1757
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1758
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1759
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1760
	     * some stream errors
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1761
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1762
#ifdef ETIME
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1763
	    case ETIME:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1764
		sym = @symbol(ETIME);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1765
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1766
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1767
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1768
#ifdef ENOSR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1769
	    case ENOSR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1770
		sym = @symbol(ENOSR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1771
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1772
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1773
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1774
#ifdef ENOSTR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1775
	    case ENOSTR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1776
		sym = @symbol(ENOSTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1777
		typ = @symbol(inappropriateReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1778
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1779
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1780
#ifdef ECOMM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1781
	    case ECOMM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1782
		sym = @symbol(ECOMM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1783
		typ = @symbol(transferFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1784
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1785
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1786
#ifdef EPROTO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1787
	    case EPROTO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1788
		sym = @symbol(EPROTO);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1789
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1790
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1791
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1792
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1793
	     * nfs errors
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1794
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1795
#ifdef ESTALE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1796
	    case ESTALE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1797
		sym = @symbol(ESTALE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1798
		typ = @symbol(unavailableReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1799
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1800
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1801
#ifdef EREMOTE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1802
	    case EREMOTE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1803
		sym = @symbol(EREMOTE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1804
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1805
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1806
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1807
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1808
	     * some networking errors
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1809
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1810
#ifdef EINPROGRESS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1811
	    case EINPROGRESS:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1812
		sym = @symbol(EINPROGRESS);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1813
		typ = @symbol(operationStartedSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1814
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1815
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1816
#ifdef EALREADY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1817
	    case EALREADY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1818
		sym = @symbol(EALREADY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1819
		typ = @symbol(operationStartedSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1820
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1821
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1822
#ifdef ENOTSOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1823
	    case ENOTSOCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1824
		sym = @symbol(ENOTSOCK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1825
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1826
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1827
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1828
#ifdef EDESTADDRREQ
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1829
	    case EDESTADDRREQ:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1830
		sym = @symbol(EDESTADDRREQ);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1831
		typ = @symbol(underspecifiedSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1832
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1833
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1834
#ifdef EMSGSIZE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1835
	    case EMSGSIZE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1836
		sym = @symbol(EMSGSIZE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1837
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1838
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1839
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1840
#ifdef EPROTOTYPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1841
	    case EPROTOTYPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1842
		sym = @symbol(EPROTOTYPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1843
		typ = @symbol(wrongSubtypeForOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1844
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1845
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1846
#ifdef ENOPROTOOPT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1847
	    case ENOPROTOOPT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1848
		sym = @symbol(ENOPROTOOPT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1849
		typ = @symbol(unsupportedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1850
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1851
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1852
#ifdef EPROTONOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1853
	    case EPROTONOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1854
		sym = @symbol(EPROTONOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1855
		typ = @symbol(unsupportedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1856
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1857
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1858
#ifdef ESOCKTNOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1859
	    case ESOCKTNOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1860
		sym = @symbol(ESOCKTNOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1861
		typ = @symbol(unsupportedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1862
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1863
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1864
#ifdef EOPNOTSUPP
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1865
	    case EOPNOTSUPP:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1866
		sym = @symbol(EOPNOTSUPP);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1867
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1868
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1869
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1870
#ifdef EPFNOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1871
	    case EPFNOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1872
		sym = @symbol(EPFNOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1873
		typ = @symbol(unsupportedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1874
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1875
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1876
#ifdef EAFNOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1877
	    case EAFNOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1878
		sym = @symbol(EAFNOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1879
		typ = @symbol(unsupportedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1880
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1881
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1882
#ifdef EADDRINUSE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1883
	    case EADDRINUSE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1884
		sym = @symbol(EADDRINUSE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1885
		typ = @symbol(existingReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1886
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1887
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1888
#ifdef EADDRNOTAVAIL
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1889
	    case EADDRNOTAVAIL:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1890
		sym = @symbol(EADDRNOTAVAIL);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1891
		typ = @symbol(noPermissionsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1892
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1893
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1894
#ifdef ETIMEDOUT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1895
	    case ETIMEDOUT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1896
		sym = @symbol(ETIMEDOUT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1897
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1898
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1899
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1900
#ifdef ECONNREFUSED
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1901
	    case ECONNREFUSED:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1902
		sym = @symbol(ECONNREFUSED);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1903
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1904
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1905
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1906
#ifdef ENETDOWN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1907
	    case ENETDOWN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1908
		sym = @symbol(ENETDOWN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1909
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1910
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1911
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1912
#ifdef ENETUNREACH
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1913
	    case ENETUNREACH:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1914
		sym = @symbol(ENETUNREACH);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1915
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1916
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1917
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1918
#ifdef ENETRESET
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1919
	    case ENETRESET:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1920
		sym = @symbol(ENETRESET);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1921
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1922
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1923
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1924
#ifdef ECONNABORTED
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1925
	    case ECONNABORTED:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1926
		sym = @symbol(ECONNABORTED);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1927
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1928
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1929
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1930
#ifdef ECONNRESET
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1931
	    case ECONNRESET:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1932
		sym = @symbol(ECONNRESET);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1933
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1934
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1935
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1936
#ifdef EISCONN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1937
	    case EISCONN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1938
		sym = @symbol(EISCONN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1939
		typ = @symbol(unpreparedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1940
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1941
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1942
#ifdef ENOTCONN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1943
	    case ENOTCONN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1944
		sym = @symbol(ENOTCONN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1945
		typ = @symbol(unpreparedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1946
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1947
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1948
#ifdef ESHUTDOWN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1949
	    case ESHUTDOWN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1950
		sym = @symbol(ESHUTDOWN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1951
		typ = @symbol(unpreparedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1952
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1953
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1954
#ifdef EHOSTDOWN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1955
	    case EHOSTDOWN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1956
		sym = @symbol(EHOSTDOWN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1957
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1958
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1959
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1960
#ifdef EHOSTUNREACH
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1961
	    case EHOSTUNREACH:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1962
		sym = @symbol(EHOSTUNREACH);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1963
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1964
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1965
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1966
#ifdef EDQUOT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1967
	    case EDQUOT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1968
		sym = @symbol(EDQUOT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1969
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1970
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1971
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1972
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1973
#ifdef ENOMEDIUM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1974
	    case ENOMEDIUM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1975
		sym = @symbol(ENOMEDIUM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1976
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1977
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1978
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1979
#ifdef EMEDIUMTYPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1980
	    case EMEDIUMTYPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1981
		sym = @symbol(EMEDIUMTYPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1982
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1983
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1984
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1985
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1986
	    default:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1987
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1988
	}
6287
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
%}.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1991
    holder := OSErrorHolder new.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1992
    holder errorSymbol:sym errorCategory:typ.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1993
    ^ holder
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1994
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1995
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1996
     OperatingSystem errorHolderForNumber:4
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1997
     self errorHolderForNumber:(self errorNumberFor:#EPERM)
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1998
     self errorHolderForNumber:(self errorNumberFor:#EIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1999
     self errorHolderForNumber:(self errorNumberFor:#ENXIO)
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2000
     self errorHolderForNumber:(self errorNumberFor:#EOVERFLOW)
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2001
    "
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
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2004
errorNumberFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2005
    "given a symbolic error, return the numeric;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2006
     (i.e. errorNumberFor:#EBADF returns EBADF's value).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2007
     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
  2008
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2009
%{   /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2010
    OBJ sym = aSymbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2011
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2012
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2013
     * POSIX errnos - these should be defined
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2014
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2015
#ifdef EPERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2016
    if (sym == @symbol(EPERM)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2017
	RETURN ( __mkSmallInteger(EPERM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2018
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2019
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2021
#ifdef ENOENT
14435
fc486e748569 changed: #errorNumberFor:
Stefan Vogel <sv@exept.de>
parents: 14377
diff changeset
  2022
    /* ERROR_FILE_NOT_FOUND is originally windows, but referd to in ExternalStream>>#openError: */
fc486e748569 changed: #errorNumberFor:
Stefan Vogel <sv@exept.de>
parents: 14377
diff changeset
  2023
    if (sym == @symbol(ENOENT) || sym == @symbol(ERROR_FILE_NOT_FOUND)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2024
	RETURN ( __mkSmallInteger(ENOENT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2025
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2026
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2027
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2028
#ifdef ESRCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2029
    if (sym == @symbol(ESRCH)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2030
	RETURN ( __mkSmallInteger(ESRCH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2031
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2032
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2033
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2034
#ifdef EINTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2035
    if (sym == @symbol(EINTR)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2036
	RETURN ( __mkSmallInteger(EINTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2037
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2038
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2039
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2040
#ifdef EIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2041
    if (sym == @symbol(EIO)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2042
	RETURN ( __mkSmallInteger(EIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2043
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2044
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2045
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2046
#ifdef ENXIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2047
    if (sym == @symbol(ENXIO)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2048
	RETURN ( __mkSmallInteger(ENXIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2049
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2050
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2051
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2052
#ifdef E2BIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2053
    if (sym == @symbol(E2BIG)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2054
	RETURN ( __mkSmallInteger(E2BIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2055
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2056
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2057
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2058
#ifdef ENOEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2059
    if (sym == @symbol(ENOEXEC)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2060
	RETURN ( __mkSmallInteger(ENOEXEC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2061
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2062
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2063
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2064
#ifdef EBADF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2065
    if (sym == @symbol(EBADF)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2066
	RETURN ( __mkSmallInteger(EBADF) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2067
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2068
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2069
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2070
#ifdef ECHILD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2071
    if (sym == @symbol(ECHILD)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2072
	RETURN ( __mkSmallInteger(ECHILD) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2073
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2074
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2075
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2076
#if defined(EAGAIN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2077
    if (sym == @symbol(EAGAIN)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2078
	RETURN ( __mkSmallInteger(EAGAIN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2079
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2080
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2081
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2082
#ifdef ENOMEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2083
    if (sym == @symbol(ENOMEM)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2084
	RETURN ( __mkSmallInteger(ENOMEM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2085
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2086
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2087
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2088
#ifdef EACCES
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2089
    if (sym == @symbol(EACCES)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2090
	RETURN ( __mkSmallInteger(EACCES) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2091
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2092
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2093
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2094
#ifdef EFAULT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2095
    if (sym == @symbol(EFAULT)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2096
	RETURN ( __mkSmallInteger(EFAULT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2097
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2098
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2099
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2100
#ifdef EBUSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2101
    if (sym == @symbol(EBUSY)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2102
	RETURN ( __mkSmallInteger(EBUSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2103
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2104
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2105
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2106
#ifdef EXDEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2107
    if (sym == @symbol(EXDEV)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2108
	RETURN ( __mkSmallInteger(EXDEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2109
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2110
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2111
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2112
#ifdef ENODEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2113
    if (sym == @symbol(ENODEV)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2114
	RETURN ( __mkSmallInteger(ENODEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2115
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2116
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2117
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2118
#ifdef ENOTDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2119
    if (sym == @symbol(ENOTDIR)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2120
	RETURN ( __mkSmallInteger(ENOTDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2121
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2122
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2123
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2124
#ifdef EISDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2125
    if (sym == @symbol(EISDIR)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2126
	RETURN ( __mkSmallInteger(EISDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2127
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2128
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2129
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2130
#ifdef EINVAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2131
    if (sym == @symbol(EINVAL)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2132
	RETURN ( __mkSmallInteger(EINVAL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2133
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2134
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2135
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2136
#ifdef ENFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2137
    if (sym == @symbol(ENFILE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2138
	RETURN ( __mkSmallInteger(ENFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2139
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2140
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2141
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2142
#ifdef EMFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2143
    if (sym == @symbol(EMFILE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2144
	RETURN ( __mkSmallInteger(EMFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2145
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2146
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2147
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2148
#ifdef ENOTTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2149
    if (sym == @symbol(ENOTTY)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2150
	RETURN ( __mkSmallInteger(ENOTTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2151
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2152
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2153
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2154
#ifdef EFBIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2155
    if (sym == @symbol(EFBIG)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2156
	RETURN ( __mkSmallInteger(EFBIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2157
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2158
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2159
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2160
#ifdef ENOSPC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2161
    if (sym == @symbol(ENOSPC)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2162
	RETURN ( __mkSmallInteger(ENOSPC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2163
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2164
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2165
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2166
#ifdef ESPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2167
    if (sym == @symbol(ESPIPE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2168
	RETURN ( __mkSmallInteger(ESPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2169
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2170
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2171
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2172
#ifdef EROFS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2173
    if (sym == @symbol(EROFS)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2174
	RETURN ( __mkSmallInteger(EROFS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2175
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2176
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2177
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2178
#ifdef EMLINK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2179
    if (sym == @symbol(EMLINK)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2180
	RETURN ( __mkSmallInteger(EMLINK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2181
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2182
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2183
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2184
#ifdef EPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2185
    if (sym == @symbol(EPIPE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2186
	RETURN ( __mkSmallInteger(EPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2187
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2188
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2190
#ifdef EDOM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2191
    if (sym == @symbol(EDOM)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2192
	RETURN ( __mkSmallInteger(EDOM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2193
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2194
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2195
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2196
#ifdef ERANGE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2197
    if (sym == @symbol(ERANGE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2198
	RETURN ( __mkSmallInteger(ERANGE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2199
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2200
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2201
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2202
#ifdef EDEADLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2203
    if (sym == @symbol(EDEADLK)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2204
	RETURN ( __mkSmallInteger(EDEADLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2205
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2206
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2207
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2208
#ifdef ENAMETOOLONG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2209
    if (sym == @symbol(ENAMETOOLONG)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2210
	RETURN ( __mkSmallInteger(ENAMETOOLONG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2211
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2212
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2213
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2214
#ifdef ENOLCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2215
    if (sym == @symbol(ENOLCK)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2216
	RETURN ( __mkSmallInteger(ENOLCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2217
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2218
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2219
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2220
#ifdef ENOSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2221
    if (sym == @symbol(ENOSYS)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2222
	RETURN ( __mkSmallInteger(ENOSYS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2223
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2224
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2225
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2226
#ifdef ENOTEMPTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2227
    if (sym == @symbol(ENOTEMPTY)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2228
	RETURN ( __mkSmallInteger(ENOTEMPTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2229
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2230
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2231
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2232
#ifdef EEXIST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2233
    if (sym == @symbol(EEXIST)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2234
	RETURN ( __mkSmallInteger(EEXIST) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2235
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2236
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2237
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2238
#ifdef EILSEQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2239
    if (sym == @symbol(EILSEQ)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2240
	RETURN ( __mkSmallInteger(EILSEQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2241
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2242
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2243
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2244
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2245
     * XPG3 errnos - defined on most systems
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2246
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2247
#ifdef ENOTBLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2248
    if (sym == @symbol(ENOTBLK)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2249
	RETURN ( __mkSmallInteger(ENOTBLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2250
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2251
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2252
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2253
#ifdef ETXTBSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2254
    if (sym == @symbol(ETXTBSY)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2255
	RETURN ( __mkSmallInteger(ETXTBSY) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2258
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
     * some others
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2261
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2262
#ifdef EWOULDBLOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2263
    if (sym == @symbol(EWOULDBLOCK)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2264
	RETURN ( __mkSmallInteger(EWOULDBLOCK) );
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2265
    }
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2266
#endif
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2267
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2268
#ifdef EOVERFLOW
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2269
    if (sym == @symbol(EOVERFLOW)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2270
	RETURN ( __mkSmallInteger(EOVERFLOW) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2273
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2274
#ifdef ENOMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2275
    if (sym == @symbol(ENOMSG)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2276
	RETURN ( __mkSmallInteger(ENOMSG) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2279
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2280
#ifdef ELOOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2281
    if (sym == @symbol(ELOOP)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2282
	RETURN ( __mkSmallInteger(ELOOP) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2285
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2286
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2287
     * some stream errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2288
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2289
#ifdef ETIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2290
    if (sym == @symbol(ETIME)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2291
	RETURN ( __mkSmallInteger(ETIME) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2292
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2293
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2294
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2295
#ifdef ENOSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2296
    if (sym == @symbol(ENOSR)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2297
	RETURN ( __mkSmallInteger(ENOSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2298
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2299
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2300
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2301
#ifdef ENOSTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2302
    if (sym == @symbol(ENOSTR)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2303
	RETURN ( __mkSmallInteger(ENOSTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2304
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2305
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2306
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2307
#ifdef ECOMM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2308
    if (sym == @symbol(ECOMM)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2309
	RETURN ( __mkSmallInteger(ECOMM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2310
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2311
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2312
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2313
#ifdef EPROTO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2314
    if (sym == @symbol(EPROTO)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2315
	RETURN ( __mkSmallInteger(EPROTO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2316
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2317
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2318
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
     * nfs errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2321
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2322
#ifdef ESTALE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2323
    if (sym == @symbol(ESTALE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2324
	RETURN ( __mkSmallInteger(ESTALE) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2327
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2328
#ifdef EREMOTE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2329
    if (sym == @symbol(EREMOTE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2330
	RETURN ( __mkSmallInteger(EREMOTE) );
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2333
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2334
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2335
     * some networking errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2336
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2337
#ifdef EINPROGRESS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2338
    if (sym == @symbol(EINPROGRESS)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2339
	RETURN ( __mkSmallInteger(EINPROGRESS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2340
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2341
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2342
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2343
#ifdef EALREADY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2344
    if (sym == @symbol(EALREADY)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2345
	RETURN ( __mkSmallInteger(EALREADY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2346
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2347
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2348
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2349
#ifdef ENOTSOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2350
    if (sym == @symbol(ENOTSOCK)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2351
	RETURN ( __mkSmallInteger(ENOTSOCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2352
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2353
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2354
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2355
#ifdef EDESTADDRREQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2356
    if (sym == @symbol(EDESTADDRREQ)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2357
	RETURN ( __mkSmallInteger(EDESTADDRREQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2358
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2359
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2360
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2361
#ifdef EMSGSIZE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2362
    if (sym == @symbol(EMSGSIZE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2363
	RETURN ( __mkSmallInteger(EMSGSIZE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2364
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2365
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2366
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2367
#ifdef EPROTOTYPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2368
    if (sym == @symbol(EPROTOTYPE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2369
	RETURN ( __mkSmallInteger(EPROTOTYPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2370
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2371
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2372
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2373
#ifdef ENOPROTOOPT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2374
    if (sym == @symbol(ENOPROTOOPT)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2375
	RETURN ( __mkSmallInteger(ENOPROTOOPT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2376
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2377
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2378
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2379
#ifdef EPROTONOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2380
    if (sym == @symbol(EPROTONOSUPPORT)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2381
	RETURN ( __mkSmallInteger(EPROTONOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2382
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2383
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2384
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2385
#ifdef ESOCKTNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2386
    if (sym == @symbol(ESOCKTNOSUPPORT)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2387
	RETURN ( __mkSmallInteger(ESOCKTNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2388
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2389
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2390
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2391
#ifdef EOPNOTSUPP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2392
    if (sym == @symbol(EOPNOTSUPP)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2393
	RETURN ( __mkSmallInteger(EOPNOTSUPP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2394
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2395
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2396
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2397
#ifdef EPFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2398
    if (sym == @symbol(EPFNOSUPPORT)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2399
	RETURN ( __mkSmallInteger(EPFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2400
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2401
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2402
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2403
#ifdef EAFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2404
    if (sym == @symbol(EAFNOSUPPORT)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2405
	RETURN ( __mkSmallInteger(EAFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2406
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2407
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2408
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2409
#ifdef EADDRINUSE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2410
    if (sym == @symbol(EADDRINUSE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2411
	RETURN ( __mkSmallInteger(EADDRINUSE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2412
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2413
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2414
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2415
#ifdef EADDRNOTAVAIL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2416
    if (sym == @symbol(EADDRNOTAVAIL)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2417
	RETURN ( __mkSmallInteger(EADDRNOTAVAIL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2418
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2419
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2420
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2421
#ifdef ETIMEDOUT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2422
    if (sym == @symbol(ETIMEDOUT)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2423
	RETURN ( __mkSmallInteger(ETIMEDOUT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2424
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2425
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2426
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2427
#ifdef ECONNREFUSED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2428
    if (sym == @symbol(ECONNREFUSED)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2429
	RETURN ( __mkSmallInteger(ECONNREFUSED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2430
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2431
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2432
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2433
#ifdef ENETDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2434
    if (sym == @symbol(ENETDOWN)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2435
	RETURN ( __mkSmallInteger(ENETDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2436
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2437
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2438
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2439
#ifdef ENETUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2440
    if (sym == @symbol(ENETUNREACH)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2441
	RETURN ( __mkSmallInteger(ENETUNREACH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2442
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2443
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2444
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2445
#ifdef ENETRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2446
    if (sym == @symbol(ENETRESET)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2447
	RETURN ( __mkSmallInteger(ENETRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2448
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2449
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2450
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2451
#ifdef ECONNABORTED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2452
    if (sym == @symbol(ECONNABORTED)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2453
	RETURN ( __mkSmallInteger(ECONNABORTED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2454
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2455
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2456
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2457
#ifdef ECONNRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2458
    if (sym == @symbol(ECONNRESET)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2459
	RETURN ( __mkSmallInteger(ECONNRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2460
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2461
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2462
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2463
#ifdef EISCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2464
    if (sym == @symbol(EISCONN)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2465
	RETURN ( __mkSmallInteger(EISCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2466
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2467
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2468
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2469
#ifdef ENOTCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2470
    if (sym == @symbol(ENOTCONN)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2471
	RETURN ( __mkSmallInteger(ENOTCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2472
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2473
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2474
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2475
#ifdef ESHUTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2476
    if (sym == @symbol(ESHUTDOWN)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2477
	RETURN ( __mkSmallInteger(ESHUTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2478
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2479
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2480
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2481
#ifdef EHOSTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2482
    if (sym == @symbol(EHOSTDOWN)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2483
	RETURN ( __mkSmallInteger(EHOSTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2484
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2485
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2486
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2487
#ifdef EHOSTUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2488
    if (sym == @symbol(EHOSTUNREACH)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2489
	RETURN ( __mkSmallInteger(EHOSTUNREACH) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2490
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2491
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2492
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2493
#ifdef EREMOTEIO
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2494
    if (sym == @symbol(EREMOTEIO)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2495
	RETURN ( __mkSmallInteger(EREMOTEIO) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2496
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2497
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2498
#ifdef EDQUOT
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2499
    if (sym == @symbol(EDQUOT)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2500
	RETURN ( __mkSmallInteger(EDQUOT) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2501
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2502
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2503
#ifdef ENOMEDIUM
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2504
    if (sym == @symbol(ENOMEDIUM)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2505
	RETURN ( __mkSmallInteger(ENOMEDIUM) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2506
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2507
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2508
#ifdef EMEDIUMTYPE
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2509
    if (sym == @symbol(EMEDIUMTYPE)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2510
	RETURN ( __mkSmallInteger(EMEDIUMTYPE) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2511
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2512
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2513
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2514
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2515
    ^ -1
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2516
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2517
    "
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2518
     self errorNumberFor:#EOVERFLOW
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2519
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2520
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2521
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2522
!UnixOperatingSystem class methodsFor:'executing OS commands-implementation'!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2523
14576
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  2524
exec:aCommandPathArg withArguments:argColl environment:environmentDictionary
7170
19558aa463e0 Environment in #executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 7152
diff changeset
  2525
    fileDescriptors:fdColl fork:doFork newPgrp:newPgrp inDirectory:aDirectory
19558aa463e0 Environment in #executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 7152
diff changeset
  2526
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2527
    "Internal lowLevel entry for combined fork & exec;
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2528
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2529
     If fork is false (chain a command):
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2530
	 execute the OS command specified by the argument, aCommandPath, with
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2531
	 arguments in argArray (no arguments, if nil).
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2532
	 If successful, this method does not return and smalltalk is gone.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2533
	 If not successful, it does return.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2534
	 Normal use is with forkForCommand.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2535
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2536
     If fork is true (subprocess command execution):
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2537
	fork a child to do the above.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2538
	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
  2539
7079
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7072
diff changeset
  2540
     fdColl contains the filedescriptors, to be used for the child (if fork is true).
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2541
	fdArray[1] = 15 -> use fd 15 as stdin.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2542
	If an element of the array is set to nil, the corresponding filedescriptor
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2543
	will be closed for the child.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2544
	fdArray[1] == StdIn for child
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2545
	fdArray[2] == StdOut for child
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2546
	fdArray[3] == StdErr for child
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2547
	on VMS, these must be channels as returned by createMailBox.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2548
	All filedescriptors not present in fdColl will be closed for the child.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2549
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2550
     If newPgrp is true, the subprocess will be established in a new process group.
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2551
	The processgroup will be equal to id.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2552
	newPgrp is not used on WIN32 and VMS systems.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2553
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2554
     environmentDictionary specifies environment variables which are passed differently from
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2555
     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
  2556
     key-value pairs for changed/added environment variables.
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2557
     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
  2558
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2559
     Notice: this used to be two separate ST-methods; however, in order to use
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2560
	    vfork on some machines, it had to be merged into one, to avoid write
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2561
	    accesses to ST/X memory from the vforked-child.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2562
	    The code below only does read accesses."
14576
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  2563
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  2564
    |envArray argArray fdArray dirName cnt aCommandPath|
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2565
14590
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
  2566
    environmentDictionary notEmptyOrNil ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2567
	envArray := Array new:environmentDictionary size.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2568
	cnt := 1.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2569
	environmentDictionary keysAndValuesDo:[:key :val |
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2570
	    val isNil ifTrue:[
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2571
		envArray at:cnt put:((self encodePath:key), '=')
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2572
	    ] ifFalse:[
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2573
		envArray at:cnt put:((self encodePath:key), '=', (self encodePath:val))
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2574
	    ].
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2575
	    cnt := cnt + 1.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2576
	].
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2577
    ].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2578
    argColl notNil ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2579
	argArray := argColl asArray collect:[:eachArg| self encodePath:eachArg].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2580
    ].
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2581
    fdColl notNil ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2582
	fdArray := fdColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2583
    ].
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2584
    aDirectory notNil ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2585
	dirName := aDirectory asFilename name.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2586
	dirName := self encodePath:dirName.
14576
2baac9ebde6d class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14575
diff changeset
  2587
    ].
14582
24adef09db30 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14576
diff changeset
  2588
    aCommandPath := self encodePath:aCommandPathArg.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2589
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2590
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2591
    char **argv;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2592
    int nargs, i, id;
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  2593
    OBJ arg;
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  2594
#ifdef __osx__
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  2595
    char **environ = _NSGetEnviron();
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  2596
#else
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  2597
    extern char **environ;
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  2598
#endif
3571
9090dc66a427 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
  2599
    char **_env, **_nEnv;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2600
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2601
    if (__isStringLike(aCommandPath) &&
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2602
	((argArray == nil) || __isArrayLike(argArray)) &&
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2603
	((fdArray == nil) || __isArrayLike(fdArray))
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2604
    ) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2605
	nargs = argArray == nil ? 0 : __arraySize(argArray);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2606
	argv = (char **) malloc(sizeof(char *) * (nargs + 1));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2607
	if (argv) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2608
	    int nOldEnv, nNewEnv;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2609
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2610
	    for (i=0; i < nargs; i++) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2611
		arg = __ArrayInstPtr(argArray)->a_element[i];
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2612
		if (__isStringLike(arg)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2613
		    argv[i] = (char *) __stringVal(arg);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2614
		} else {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2615
		    argv[i] = "";
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2616
		}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2617
	    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2618
	    argv[i] = NULL;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2619
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2620
	    /*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2621
	     * number of new items in environment ..
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2622
	     */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2623
	    nNewEnv = 0;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2624
	    if ((envArray != nil) && __isArrayLike(envArray)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2625
		nNewEnv = __arraySize(envArray);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2626
	    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2627
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2628
	    if (nNewEnv == 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2629
		_nEnv = environ;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2630
	    } else {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2631
		_env = environ;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2632
		/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2633
		 * get size of environment
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2634
		 */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2635
		nOldEnv = 0;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2636
		if (_env) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2637
		    while (*_env) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2638
			nOldEnv++;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2639
			_env++;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2640
		    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2641
		}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2642
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2643
		/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2644
		 * generate a new environment
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2645
		 * I have not found a spec which defines if
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2646
		 * items at the end overwrite previous definitions,
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2647
		 * or if the first encountered definition is valid.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2648
		 * To be prepared for any case, simply add the new definitions
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2649
		 * at both ends - that should do it in any case.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2650
		 * Someone with more know-how may want to fix this.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2651
		 * getenv() searches for the first entry.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2652
		 * But maybe someone creates a Dictionary from the environment.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2653
		 * In this case the last entry would overwrite previous entries.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2654
		 */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2655
		_nEnv = (char **)malloc(sizeof(char *) * (nNewEnv + nOldEnv + nNewEnv + 1));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2656
		if (_nEnv) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2657
		    char **eO, **eN;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2658
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2659
		    eN = _nEnv;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2660
		    if (nNewEnv) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2661
			/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2662
			 * add new items at the front ...
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2663
			 */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2664
			int i;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2665
			OBJ *t;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2666
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2667
			for (i=0, t = __arrayVal(envArray);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2668
			     i < __arraySize(envArray);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2669
			     i++, t++) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2670
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2671
			    if (__isStringLike(*t)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2672
				*eN++ = (char *)__stringVal(*t);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2673
			    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2674
			}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2675
		    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2676
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2677
		    if (nOldEnv) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2678
			/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2679
			 * append old environment
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2680
			 */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2681
			for (eO = environ; *eO; *eN++ = *eO++)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2682
			    continue;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2683
		    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2684
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2685
		    if (nNewEnv) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2686
			/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2687
			 * append new items again at the end
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2688
			 */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2689
			for (eO = _nEnv, i=0; i<nNewEnv; i++) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2690
			    *eN++ = *eO++;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2691
			}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2692
		    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2693
		    *eN = NULL;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2694
		}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2695
	    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2696
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2697
	    if (doFork == true) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2698
		/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2699
		 * fork a subprocess.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2700
		 */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2701
		int nfd;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2702
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2703
		nfd = fdArray == nil ? 0 : __arraySize(fdArray);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2704
		id = FORK ();
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2705
		if (id == 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2706
		    /*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2707
		    ** In child.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2708
		    ** first: dup filedescriptors.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2709
		    */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2710
		    for (i = 0; i < nfd; i++) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2711
			OBJ fd;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2712
			int rslt;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2713
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2714
			fd = __arrayVal(fdArray)[i];
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2715
			if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2716
			    do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2717
				rslt = dup2(__intVal(fd), i);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2718
			    } while ((rslt < 0) && (errno == EINTR));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2719
			}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2720
		    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2721
		    /*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2722
		    ** Second: close descriptors
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2723
		    **         marked as unwanted
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2724
		    ** (extra loop to allow duping of low filedescriptor numbers to
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2725
		    **  higher fd numbers)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2726
		    */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2727
		    for (i = 0; i < nfd; i++) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2728
			if (__arrayVal(fdArray)[i] == nil) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2729
			    close(i);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2730
			}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2731
		    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2732
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2733
		    /*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2734
		    ** third: close all filedescriptors larger
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2735
		    ** then the explicitely closed or duped
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2736
		    ** filedescriptors
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2737
		    */
7072
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  2738
#ifndef OPEN_MAX
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  2739
# define OPEN_MAX       256
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  2740
#endif
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2741
		    for ( ;i < OPEN_MAX; i++) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2742
			close(i);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2743
		    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2744
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2745
		    if (newPgrp == true) {
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  2746
#ifndef NEXT
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2747
			setsid();
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  2748
#endif
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  2749
#if defined(TIOCSCTTY)
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2750
			ioctl(0, TIOCSCTTY, 0) ;
3561
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  2751
#endif
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  2752
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  2753
#if defined(TIOCSPGRP)
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2754
			{
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2755
			    int pgrp = getpid();
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2756
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2757
			    ioctl(0, TIOCSPGRP, (char *)&pgrp);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2758
			}
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  2759
#endif
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2760
#if defined(_POSIX_JOB_CONTROL)
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2761
			(void) setpgid(0, 0);
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2762
#else
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2763
# if defined(BSD) || defined(LINUX)
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2764
			(void) setpgrp(0);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2765
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2766
#endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2767
		    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2768
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2769
		    if (dirName == nil || chdir((char *)__stringVal(dirName)) == 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2770
			execve((char *)__stringVal(aCommandPath), argv, _nEnv);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2771
		    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2772
		    /* reached if chdir failed or aCommandPathh cannot be executed */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2773
		    _exit(127);                 /* POSIX 2 compatible exit value */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2774
		}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2775
	    } else {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2776
		/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2777
		 * no subprocess (i.e. transfer to another program)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2778
		 */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2779
		if (dirName == nil || chdir((char *)__stringVal(dirName)) == 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2780
		    execve((char *)__stringVal(aCommandPath), argv, _nEnv);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2781
		}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2782
		/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2783
		 * reached if chdir failed or command-path cannot be executed
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2784
		 */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2785
		id = -1;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2786
	    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2787
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2788
	    if (nNewEnv && (_nEnv != NULL)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2789
		/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2790
		 * free new environment stuff
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2791
		 */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2792
		free(_nEnv);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2793
	    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2794
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2795
	    free(argv);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2796
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2797
	    /*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2798
	     * In parent: succes or failure
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2799
	     */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2800
	    if (id == -1) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2801
		RETURN (nil);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2802
	    } else {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2803
		RETURN (__mkSmallInteger(id));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2804
	    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2805
	}
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2806
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2807
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2808
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2809
     path-argument not string
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2810
     or argArray not an array/nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2811
     or malloc failed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2812
     or not supported by OS
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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2815
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2816
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2817
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2818
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  2819
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2820
     id == 0 ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2821
	'I am the child'.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2822
	OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2823
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2824
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2825
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2826
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2827
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2828
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  2829
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2830
     id == 0 ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2831
	'I am the child'.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2832
	OperatingSystem
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2833
	   exec:'/bin/sh'
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2834
	   withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  2835
	'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2836
     ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2837
     id printNL.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2838
     (Delay forSeconds:3.5) wait.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2839
     'killing ...' printNL.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  2840
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  2841
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2842
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2843
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2844
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2845
fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2846
    "fork a new (HEAVY-weight) unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2847
     Not supported with MSDOS & VMS systems.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2848
     Dont confuse this with Block>>fork, which creates
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2849
     lightweight smalltalk processes. This method will return
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2850
     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
  2851
     unix-process-id) to the parent (original) process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2852
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2853
     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
  2854
     #startProcess: and #executCommand: for higher level interfaces."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2855
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2856
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2857
    int pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2858
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2859
    pid = fork();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2860
    RETURN ( __MKUINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2861
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2862
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2863
    "/ not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2864
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2865
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2866
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2867
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2868
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2869
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2870
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  2871
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2872
     id == 0 ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2873
	'I am the child process' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2874
	OperatingSystem exit
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2875
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2876
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2877
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2878
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2879
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2880
    errorTo:anExternalErrStream auxFrom:anAuxiliaryStream
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2881
    environment:anEvironmentDictionary inDirectory:dir
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2882
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2883
    "start executing the OS command as specified by the argument, aCommandString
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2884
     as a separate process; do not wait for the command to finish.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2885
     The commandString is passed to a shell for execution - see the description of
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2886
     'sh -c' in your UNIX manual ('cmd.com' in your MSDOS manual).
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2887
     The command gets stdIn, stdOut and stdErr assigned from the arguments;
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2888
     each may be nil.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2889
     Return the processId if successful, nil otherwise.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2890
     Use #monitorPid:action: for synchronization and exec status return,
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2891
     or #killProcess: to stop it."
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2892
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2893
    |nullStream in out err shellAndArgs rslt auxFd|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2894
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2895
    aCommandString isNil ifTrue:[^ nil].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2896
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2897
    (in := anExternalInStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2898
	nullStream := Filename nullDevice readWriteStream.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2899
	in := nullStream.
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2900
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2901
    (out := anExternalOutStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2902
	nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2903
	out := nullStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2904
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2905
    (err := anExternalErrStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2906
	err := out
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2907
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2908
    anAuxiliaryStream notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2909
	auxFd := anAuxiliaryStream fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2910
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2911
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2912
    shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2913
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2914
    rslt := self
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2915
	exec:(shellAndArgs at:1)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2916
	withArguments:(shellAndArgs at:2)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2917
	environment:anEvironmentDictionary
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2918
	fileDescriptors:(Array with:in fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2919
			       with:out fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2920
			       with:err fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2921
			       with:auxFd)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2922
	fork:true
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2923
	newPgrp:true "/ false
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2924
	inDirectory:dir.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2925
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2926
    nullStream notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2927
	nullStream close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2928
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2929
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2930
    ^ rslt
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2931
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2932
    "blocking at current prio (i.e. only higher prio threads execute):
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2933
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2934
     OperatingSystem executeCommand:'ls -l > out'.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2935
    "
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2936
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2937
    "non-blocking (lower prio threads continue):
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2938
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2939
     |in out err pid sema|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2940
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2941
     in := 'out' asFilename readStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2942
     out := 'out2' asFilename writeStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2943
     err := 'err' asFilename writeStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2944
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2945
     sema := Semaphore new.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2946
     pid := OperatingSystem startProcess:'sleep 10; grep drw' inputFrom:in outputTo:out errorTo:err.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2947
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2948
     The following will no longer work. monitorPid has disappeared
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2949
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2950
     pid notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2951
	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2952
     ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2953
     in close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2954
     out close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2955
     err close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2956
     sema wait.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2957
     Transcript showCR:'finished'
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2958
    "
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2959
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2960
    "Modified: / 21.3.1997 / 10:04:35 / dq"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2961
    "Modified: / 15.7.1997 / 16:03:51 / stefan"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2962
    "Modified: / 5.6.1998 / 19:03:51 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2963
    "Created: / 12.11.1998 / 14:39:20 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2964
! !
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2965
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2966
!UnixOperatingSystem class methodsFor:'executing OS commands-queries'!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2967
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2968
commandAndArgsForOSCommand:aCommandString
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2969
    "get a shell and shell arguments for command execution"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2970
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2971
    |shell args|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2972
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2973
    "/
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2974
    "/ '/bin/sh -c <command>'
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2975
    "/
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2976
    shell := '/bin/sh'.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2977
    args := Array with:'sh' with:'-c' with:aCommandString.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2978
    ^ Array with:shell with:args
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2979
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2980
    "Modified: / 20.1.1998 / 16:57:19 / md"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2981
    "Modified: / 5.6.1998 / 17:40:48 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2982
!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2983
11046
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  2984
nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  2985
    "return the name of the running ST/X executable program.
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  2986
     Usually, 'stx' is returned -
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  2987
     but may be different for standAlone apps (or winstx.exe)."
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  2988
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  2989
    |info path|
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  2990
15206
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  2991
    "shortcut - use the /proc filesystem (if present).
14376
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  2992
     Here we get an absolute path to the running executable."
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  2993
    info := '/proc/self/exe' asFilename linkInfo.
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  2994
    info notNil ifTrue:[
15206
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  2995
        path := info path.
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  2996
        path notEmptyOrNil ifTrue:[
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  2997
            ^ path
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  2998
        ].
14376
608194431b5e changed: #nameOfSTXExecutable
Stefan Vogel <sv@exept.de>
parents: 14370
diff changeset
  2999
     ].
11046
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3000
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3001
    "Fall back - do it the hard way"
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3002
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3003
    ^ super nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3004
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3005
    "
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3006
     OperatingSystem nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3007
    "
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3008
!
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3009
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3010
pathOfCommand:aCommand
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3011
    "find where aCommand's executable file is;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3012
     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
  3013
     return nil."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3014
9078
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3015
    |path f fExt commandFilename|
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3016
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3017
    commandFilename := aCommand asFilename.
9078
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3018
    commandFilename isAbsolute ifTrue:[
15206
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3019
        ^ commandFilename pathName
9078
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3020
    ].
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3021
    commandFilename isExplicitRelative ifTrue:[
15210
e70fc011e203 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15209
diff changeset
  3022
         ^ commandFilename pathName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3023
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3025
    path := self getEnvironment:'PATH'.
14370
66a4b9c492b9 Fixed: bad definition of MAXPATHLEN from PATH_MAX
Stefan Vogel <sv@exept.de>
parents: 13801
diff changeset
  3026
    path notEmptyOrNil ifTrue:[
15206
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3027
        (path asCollectionOfSubstringsSeparatedBy:self pathSeparator) do:[:eachPathComponent |
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3028
            eachPathComponent isEmpty ifTrue:[
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3029
                f := commandFilename
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3030
            ] ifFalse:[
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3031
                f := eachPathComponent asFilename construct:aCommand.
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3032
            ].
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3033
            self executableFileExtensions do:[:eachExtension |
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3034
                eachExtension notEmpty ifTrue:[
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3035
                    fExt := f addSuffix:eachExtension.
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3036
                ] ifFalse:[
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3037
                    fExt := f.
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3038
                ].
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3039
                fExt isExecutable ifTrue:[
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3040
                    ^ fExt pathName
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3041
                ].
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3042
            ].
7c9981d16755 class: UnixOperatingSystem
Claus Gittinger <cg@exept.de>
parents: 15178
diff changeset
  3043
        ].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3044
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3045
    ^ nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3046
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3047
    "unix:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3048
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3049
     OperatingSystem pathOfCommand:'fooBar'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3050
     OperatingSystem pathOfCommand:'ls'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3051
     OperatingSystem pathOfCommand:'cvs'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3052
     OperatingSystem pathOfCommand:'stx'
9078
b142a0c5f5ed Fix #pathOfCommand: for './stx' when '.' is not in /home/stefan/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:.:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin:.
Stefan Vogel <sv@exept.de>
parents: 8998
diff changeset
  3053
     OperatingSystem pathOfCommand:'./stx'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3054
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3055
    "windows:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3056
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3057
     OperatingSystem pathOfCommand:'windbg'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3058
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3059
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3060
    "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
  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
!UnixOperatingSystem class methodsFor:'file access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3064
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3065
closeFd:anInteger
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3066
    "low level close of a filedescriptor"
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
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3069
     if (__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3070
	if (@global(ExternalStream:FileOpenTrace) == true) {
15176
aae943ef2519 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 15175
diff changeset
  3071
	    fprintf(stderr, "close [UnixOp] fd=%d\n", (int)__intVal(anInteger));
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3072
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3073
	close(__intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3074
	RETURN(self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3075
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3076
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3077
     ^ self primitiveFailed.
7133
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3078
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3079
    "
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3080
     10 to:400 do:[:fd | OperatingSystem closeFd:fd]
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3081
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3082
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3083
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3084
copyFromFd:inFd toFd:outFd startIndex:startIdx count:count
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3085
    "directly copy from one Fd to another (if supported by the OS)"
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3086
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3087
%{
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3088
#if defined(HAS_SENDFILE)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3089
     if (__isSmallInteger(inFd)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3090
      && __isSmallInteger(outFd)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3091
      && __isSmallInteger(startIdx)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3092
      && __isSmallInteger(count)) {
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  3093
	int nWritten;
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  3094
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  3095
	nWritten = sendfile(__intVal(outFd), __intVal(inFd), __intVal(startIdx), __intVal(count));
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  3096
	if (nWritten < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  3097
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  3098
	}
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  3099
	RETURN (__mkSmallInteger(nWritten));
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3100
     }
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3101
#endif
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3102
%}.
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3103
    ^ 0 "/ not supported
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3104
!
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3105
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3106
createDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3107
    "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
  3108
     path, or relative to the current directory.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3109
     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
  3110
     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
  3111
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3112
    ^ self createDirectory:aPathName withAccess:((self getEnvironment:'UMASK') ? 8r0755)
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3113
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3114
    "
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3115
     OperatingSystem createDirectory:'foo'
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3116
    "
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3117
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3118
    "Modified: 20.12.1995 / 11:24:13 / stefan"
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3119
    "Modified: 29.6.1996 / 14:06:54 / cg"
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3120
!
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3121
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3122
createDirectory:aPathName withAccess:umask
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3123
    "create a new directory with name 'aPathName', which may be an absolute
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3124
     path, or relative to the current directory.
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3125
     Return true if successful (or the directory existed already), false if failed.
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3126
     This is a low-level entry - use Filename protocol for compatibility."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3127
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3128
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3129
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3130
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3131
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3132
%{
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3133
    if (__isStringLike(encodedPathName) && __isSmallInteger(umask)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3134
	if (mkdir(__stringVal(encodedPathName), __smallIntegerVal(umask)) >= 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3135
	    RETURN(true);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3136
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3137
	@global(LastErrorNumber) = __mkSmallInteger(errno);
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3138
    }
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3139
%}.
11547
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3140
    "/ could not create - if it already existed this is ok
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3141
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3142
    (self isDirectory:aPathName) ifTrue:[^ true].
11547
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3143
    ^ false.
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3144
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3145
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3146
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3147
     OperatingSystem createDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3148
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3150
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3151
createFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3152
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3153
    ^ self open:pathName attributes:#(O_RDWR O_CREAT O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3154
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3155
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3156
createFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3157
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3158
    ^ 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
  3159
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3160
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3161
createFileForWrite:pathName
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3162
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3163
    ^ self open:pathName attributes:#(O_WRONLY O_CREAT O_TRUNC) mode:nil
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3164
!
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3165
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3166
createHardLinkFrom:oldPath to:newPath
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3167
    "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
  3168
     Return true if successful, false if not."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3169
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3170
    |encodedOldPathName encodedNewPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3171
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3172
    encodedOldPathName := self encodePath:oldPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3173
    encodedNewPathName := self encodePath:newPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3174
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3175
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3176
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3177
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3178
    if (__isStringLike(encodedOldPathName) && __isStringLike(encodedNewPathName)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3179
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3180
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3181
	    ret = link((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3182
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3183
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3184
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3185
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3186
	    RETURN ( false );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3187
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3188
	RETURN (true);
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3189
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3190
%}.
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3191
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3192
    "/ bad argument(s) given
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3193
    "/
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3194
    ^ self primitiveFailed
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3195
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3196
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3197
     OperatingSystem linkFile:'foo' to:'bar'
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3198
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3199
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3200
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3201
createSymbolicLinkFrom:oldPath to:newPath
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3202
    "make a symbolic link for 'newPath' to the file 'oldPath'.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3203
     The link will be a soft (symbolic) link.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3204
     Return true if successful, false if not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3205
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3206
    |encodedOldPathName encodedNewPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3207
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3208
    encodedOldPathName := self encodePath:oldPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3209
    encodedNewPathName := self encodePath:newPath.
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3210
%{
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3211
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3212
    int ret;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3213
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3214
    if (__isStringLike(encodedOldPathName) && __isStringLike(encodedNewPathName)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3215
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3216
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3217
	    ret = symlink((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3218
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3219
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3220
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3221
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3222
	    RETURN ( false );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3223
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3224
	RETURN (true);
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3225
    }
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3226
#endif
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3227
%}.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3228
    (encodedOldPathName isString not or:[encodedNewPathName isString not]) ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3229
	"/
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3230
	"/ bad argument(s) given
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3231
	"/
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3232
	^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3233
    ].
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
    "/
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3236
    "/ 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
  3237
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3238
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3239
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3240
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3241
     OperatingSystem symbolicLinkFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3242
    "
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
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3245
open:path attributes:attributes mode:modeInteger
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3246
    "open a file, return an os specific fileHandle.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3247
     openmode is a symbol defining the way to open
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3248
     valid modes are:
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3249
	#O_RDONLY
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3250
	#O_RDWR
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3251
	#O_WRONLY
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3252
	#O_CREAT
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3253
	#O_APPEND
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3254
	#O_SYNC
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3255
	#O_LARGEFILE
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3256
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3257
     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
  3258
     which is proprietrary to the operatingSystem."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3259
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3260
    |error fileDescriptor encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3261
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3262
    encodedPathName := self encodePath:path.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3263
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3264
%{
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3265
    OBJ *ap;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3266
    int nAttributes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3267
    int fd;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3268
    int mode, openFlags = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3269
    int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3270
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3271
    if (!__isStringLike(encodedPathName)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3272
	error = @symbol(badArgument1);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3273
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3274
    }
8934
32a063645991 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3275
    if (!__isArrayLike(attributes)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3276
	error = @symbol(badArgument2);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3277
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3278
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3279
    if (modeInteger == nil) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3280
	mode = 0644;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3281
    } else if (__isSmallInteger(modeInteger)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3282
	mode = __intVal(modeInteger);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3283
    } else {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3284
	error = @symbol(badArgument3);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3285
	goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3286
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3287
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3288
    nAttributes = __arraySize(attributes);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3289
    for (n = 0, ap = __arrayVal(attributes); n < nAttributes; n++) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3290
	OBJ attribute = ap[n];
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3291
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3292
	if (attribute == @symbol(O_RDONLY)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3293
	    openFlags |= O_RDONLY;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3294
	} else if (attribute == @symbol(O_RDWR)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3295
	    openFlags |= O_RDWR;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3296
	} else if (attribute == @symbol(O_WRONLY)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3297
	    openFlags |= O_WRONLY;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3298
	} else if (attribute == @symbol(O_CREAT)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3299
	    openFlags |= O_CREAT;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3300
	} else if (attribute == @symbol(O_APPEND)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3301
	    openFlags |= O_APPEND;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3302
	} else if (attribute == @symbol(O_EXCL)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3303
	    openFlags |= O_EXCL;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3304
	} else if (attribute == @symbol(O_TRUNC)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3305
	    openFlags |= O_TRUNC;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3306
	} else if (attribute == @symbol(O_LARGEFILE)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3307
#ifdef O_LARGEFILE
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3308
	    openFlags |= O_LARGEFILE;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3309
#else
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3310
	    error = @symbol(badArgument2);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3311
	    goto err;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3312
#endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3313
	} else if (attribute == @symbol(O_SYNC)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3314
#ifdef O_SYNC
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3315
	    openFlags |= O_SYNC;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3316
#else
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3317
	    error = @symbol(badArgument2);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3318
	    goto err;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3319
#endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3320
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3321
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3322
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3323
#if defined(O_NONBLOCK)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3324
    openFlags |= O_NONBLOCK;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  3325
#elif defined(O_NDELAY)
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3326
    openFlags |= O_NDELAY;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3327
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3328
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3329
again:
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3330
    fd = open((char *) __stringVal(encodedPathName), openFlags, mode);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3331
    if (fd < 0) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3332
	if (errno == EINTR) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3333
	    __HANDLE_INTERRUPTS__;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3334
	    goto again;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3335
	} else {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3336
	    error = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3337
	    goto err;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3338
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3339
    }
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  3340
    fileDescriptor = __mkSmallInteger(fd);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3341
err:;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3342
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3343
    ^ fileDescriptor notNil ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3344
	FileDescriptorHandle for:fileDescriptor.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3345
    ] ifFalse:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3346
	(self errorHolderForNumber:error) reportError
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3347
    ].
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3348
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3349
    "
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3350
	self open:'/etc/hosts' attributes:#(O_RDONLY) mode:nil
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3351
	self open:'/tmp/xxzz' attributes:#(O_RDWR O_CREAT) mode:8r611
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3352
	self open:'/etc/passwd' attributes:#(O_RDWR) mode:nil
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3353
	self open:'/no one knows this file' attributes:#(O_RDONLY) mode:nil
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3354
	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
  3355
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3356
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3357
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3358
openFileForAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3359
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3360
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3361
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3362
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3363
openFileForRead:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3364
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3365
    ^ self open:pathName attributes:#(O_RDONLY) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3366
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3367
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3368
openFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3369
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3370
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3371
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3372
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3373
openFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3374
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3375
    ^ self open:pathName attributes:#(O_RDWR)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3376
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3377
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3378
openFileForWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3379
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3380
    ^ self open:pathName attributes:#(O_WRONLY)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3381
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3382
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3383
recursiveCopyDirectory:sourcePathName to:destination
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3384
    "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
  3385
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3386
12530
96a8b0ef61f5 changed: #recursiveCopyDirectory:to:
Stefan Vogel <sv@exept.de>
parents: 12458
diff changeset
  3387
    ^ self executeCommand:('/bin/cp -af ''' , sourcePathName, ''' ''', destination , '''')
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3388
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3389
    "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
  3390
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3391
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3392
recursiveRemoveDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3393
    "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
  3394
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3395
10930
95015f0d599e Use full pathname and quoting when executing commands
Stefan Vogel <sv@exept.de>
parents: 10800
diff changeset
  3396
    ^ self executeCommand:('/bin/rm -rf ''' , fullPathName , '''')
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3397
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3398
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3399
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3400
     OperatingSystem recursiveRemoveDirectory:'foo'
3496
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
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3403
    "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
  3404
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3405
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3406
removeDirectory:fullPathName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3407
    "remove the directory named 'fullPathName'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3408
     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
  3409
     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
  3410
     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
  3411
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3412
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3413
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3414
    encodedPathName := self encodePath:fullPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3415
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3416
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3417
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3418
    if (__isStringLike(encodedPathName)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3419
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3420
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3421
	    ret = rmdir((char *) __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3422
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3423
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3424
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3425
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3426
	    RETURN ( false );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3427
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3428
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3429
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3430
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3431
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3432
    "/ either not a string argument,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3433
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3434
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3435
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3436
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3437
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3438
     OperatingSystem createDirectory:'foo'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3439
     OperatingSystem removeDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3440
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3441
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3442
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3443
removeFile:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3444
    "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
  3445
     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
  3446
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3447
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3448
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3449
    encodedPathName := self encodePath:fullPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3450
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3451
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3452
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3453
    if (__isStringLike(encodedPathName)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3454
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3455
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3456
	    ret = unlink((char *) __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3457
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3458
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3459
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3460
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3461
	    RETURN ( false );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3462
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3463
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3464
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3465
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3466
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3467
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3468
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3469
renameFile:oldPath to:newPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3470
    "rename the file 'oldPath' to 'newPath'.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3471
     Someone else has to care for the names to be correct and
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3472
     correct for the OS used - therefore, this should not be called
11798
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3473
     directly. Instead, use Filename protocol to rename; this cares for
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3474
     any invalid names.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3475
     Returns true if successful, false if not"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3476
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3477
    |encodedOldPathName encodedNewPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3478
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3479
    encodedOldPathName := self encodePath:oldPath.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3480
    encodedNewPathName := self encodePath:newPath.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3481
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3482
    int ret, eno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3483
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3484
    if (__isStringLike(encodedOldPathName) && __isStringLike(encodedNewPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3485
#if defined(HAS_RENAME)
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3486
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3487
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3488
	    ret = rename((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3489
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3490
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3491
#else
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3492
	ret = link((char *) __stringVal(encodedOldPathName), (char *) __stringVal(encodedNewPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3493
	if (ret >= 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3494
	    ret = unlink((char *) __stringVal(encodedOldPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3495
	    if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3496
		eno = errno;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3497
		unlink((char *) __stringVal(encodedNewPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3498
		errno = eno;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3499
	    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3500
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3501
#endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3502
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3503
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3504
	    RETURN ( false );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3505
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3506
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3507
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3508
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3509
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3510
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3511
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3512
     OperatingSystem renameFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3513
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3514
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3515
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3516
truncateFile:aPathName to:newSize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3517
    "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
  3518
     This may not be supported on all architectures.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3519
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3520
     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
  3521
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3522
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3523
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3524
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3525
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3526
%{
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3527
#if defined(HAS_TRUNCATE) || defined(HAS_FTRUNCATE)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3528
    int ret;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3529
    off_t truncateSize;
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3530
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3531
    if (!__isStringLike(encodedPathName))
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3532
	goto getOutOfHere;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3533
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3534
    if (__isSmallInteger(newSize)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3535
	truncateSize = __intVal(newSize);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3536
	if (truncateSize < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3537
	    goto getOutOfHere;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3538
	}
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3539
    } else {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3540
	truncateSize = __signedLongIntVal(newSize);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3541
	if (truncateSize < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3542
	    goto getOutOfHere;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3543
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3544
	if (truncateSize == 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3545
	    if (sizeof(truncateSize) == 8) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3546
		if (__signedLong64IntVal(newSize, &truncateSize) == 0 || truncateSize < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3547
		    goto getOutOfHere;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3548
		}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3549
	    } else {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3550
		goto getOutOfHere;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3551
	    }
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3552
	}
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3553
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3554
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3555
#if defined(HAS_TRUNCATE)
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3556
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3557
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3558
	    ret = truncate((char *) __stringVal(encodedPathName), truncateSize);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3559
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3560
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3561
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3562
# ifdef HAS_FTRUNCATE
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3563
    {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3564
	int fd;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3565
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3566
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3567
	    fd = open((char *) __stringVal(encodedPathName), 2);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3568
	} while (fd < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3569
	if (fd < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3570
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3571
	    RETURN ( false );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3572
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3573
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3574
	ret = ftruncate(fd, truncateSize);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3575
	close(fd);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3576
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3577
# endif /* HAS_FTRUNCATE */
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3578
#endif
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3579
    if (ret < 0) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3580
	@global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3581
	RETURN ( false );
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3582
    }
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3583
    RETURN (true);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3584
getOutOfHere:;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3585
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3586
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3587
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3588
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3589
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3590
!UnixOperatingSystem class methodsFor:'file access rights'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3591
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3592
accessMaskFor:aSymbol
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3593
    "return the access bits mask for numbers as returned by
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3594
     OperatingSystem>>accessModeOf:
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3595
     and expected by OperatingSystem>>changeAccessModeOf:to:.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3596
     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
  3597
     (never hardcode 8rxxx into your code)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3599
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3600
#   ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3601
    /* posix systems should define these ... */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3602
#    define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3603
#    define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3604
#    define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3605
#    define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3606
#    define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3607
#    define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3608
#    define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3609
#    define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3610
#    define S_IXOTH 0001
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3611
#    define S_ISUID 04000
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3612
#    define S_ISGID 02000
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3613
#    define S_ISVTX 01000
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3614
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3615
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3616
    if (aSymbol == @symbol(readUser)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3617
	RETURN ( __mkSmallInteger(S_IRUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3618
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3619
    if (aSymbol == @symbol(writeUser)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3620
	RETURN ( __mkSmallInteger(S_IWUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3621
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3622
    if (aSymbol == @symbol(executeUser)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3623
	RETURN ( __mkSmallInteger(S_IXUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3624
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3625
    if (aSymbol == @symbol(readGroup)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3626
	RETURN ( __mkSmallInteger(S_IRGRP) );
3496
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
    if (aSymbol == @symbol(writeGroup)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3629
	RETURN ( __mkSmallInteger(S_IWGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3630
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3631
    if (aSymbol == @symbol(executeGroup)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3632
	RETURN ( __mkSmallInteger(S_IXGRP) );
3496
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
    if (aSymbol == @symbol(readOthers)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3635
	RETURN ( __mkSmallInteger(S_IROTH) );
3496
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 (aSymbol == @symbol(writeOthers)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3638
	RETURN ( __mkSmallInteger(S_IWOTH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3639
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3640
    if (aSymbol == @symbol(executeOthers)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3641
	RETURN ( __mkSmallInteger(S_IXOTH) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3642
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3643
    if (aSymbol == @symbol(setUid)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3644
	RETURN ( __mkSmallInteger(S_ISUID) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3645
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3646
    if (aSymbol == @symbol(setGid)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3647
	RETURN ( __mkSmallInteger(S_ISGID) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3648
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3649
    if (aSymbol == @symbol(removeOnlyByOwner)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3650
	RETURN ( __mkSmallInteger(S_ISVTX) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3651
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3652
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3653
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3654
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3655
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3656
     OperatingSystem accessMaskFor:#readUser
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3657
     OperatingSystem accessMaskFor:#removeOnlyByOwner
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3658
    "
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
accessModeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3662
    "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
  3663
     group and others. Return nil if such a file does not exist.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3664
     Notice that the returned number is OS dependent - use the
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3665
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
3496
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
     this could have been implemented as:
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3669
	(self infoOf:aPathName) at:#mode
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3670
     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
  3671
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3672
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3673
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3674
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3675
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3676
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3677
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3678
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3679
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3680
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3681
# ifdef TRACE_STAT_CALLS
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3682
	printf("stat on '%s' for accessMode\n", __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3683
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3684
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3685
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3686
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3687
	} while ((ret < 0) && (errno == EINTR));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3688
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3689
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3690
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3691
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3692
	    RETURN ( nil );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3693
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3694
	RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3695
    }
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
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3698
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3699
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3700
    (OperatingSystem accessModeOf:'/') printStringRadix:8
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3701
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3702
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3703
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3704
accessModeOfFd:aFileDescriptor
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3705
    "return a number representing access rights rwxrwxrwx for owner,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3706
     group and others. Return nil if such a file does not exist.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3707
     Notice that the returned number is OS dependent - use the
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3708
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3709
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3710
%{
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3711
    struct stat buf;
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3712
    int ret;
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3713
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3714
    if (__isSmallInteger(aFileDescriptor)) {
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3715
# ifdef TRACE_STAT_CALLS
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3716
        printf("fstat on '%d' for accessMode\n", __smallIntegerVal(aFileDescriptor));
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3717
# endif
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3718
        __BEGIN_INTERRUPTABLE__
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3719
        do {
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3720
            ret = fstat(__smallIntegerVal(aFileDescriptor), &buf);
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3721
        } while ((ret < 0) && (errno == EINTR));
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3722
        __END_INTERRUPTABLE__
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3723
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3724
        if (ret < 0) {
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3725
            @global(LastErrorNumber) = __mkSmallInteger(errno);
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3726
            RETURN ( nil );
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3727
        }
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3728
        RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3729
    }
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3730
%}.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3731
   ^ self primitiveFailed
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3732
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3733
   "
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3734
    '/' asFilename readingFileDo:[:s|
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3735
        (OperatingSystem accessModeOfFd:s fileDescriptor) printStringRadix:8
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3736
    ].
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3737
   "
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3738
!
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3739
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3740
changeAccessModeOf:aPathName to:modeBits
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3741
    "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
  3742
     You should construct this mask using accessMaskFor, to be OS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3743
     independent. Return true if changed,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3744
     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
  3745
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3746
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3747
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3748
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3749
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3750
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3751
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  3752
    if (__isStringLike(encodedPathName) && __isSmallInteger(modeBits)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3753
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3754
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3755
	    ret = chmod((char *)__stringVal(encodedPathName), __intVal(modeBits));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3756
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3757
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3758
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3759
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3760
	    RETURN ( false );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3761
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  3762
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3763
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3764
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3765
    ^ self primitiveFailed
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3766
!
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3767
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3768
changeAccessModeOfFd:aFileDescriptor to:modeBits
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3769
    "change the access rights of the file referenced by aFileDescriptor
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3770
     to the OS dependent modeBits.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3771
     You should construct this mask using accessMaskFor, to be OS
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3772
     independent. Return true if changed,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3773
     false if such a file does not exist or change was not allowd."
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3774
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3775
%{
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3776
    int ret;
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3777
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3778
    if (__isSmallInteger(aFileDescriptor) && __isSmallInteger(modeBits)) {
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3779
        __BEGIN_INTERRUPTABLE__
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3780
        do {
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3781
            ret = fchmod(__smallIntegerVal(aFileDescriptor), __intVal(modeBits));
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3782
        } while (ret < 0 && errno == EINTR);
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3783
        __END_INTERRUPTABLE__
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3784
        if (ret < 0) {
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3785
            @global(LastErrorNumber) = __mkSmallInteger(errno);
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3786
            RETURN ( false );
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3787
        }
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3788
        RETURN ( true );
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3789
    }
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3790
%}.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  3791
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3792
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3793
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3794
!UnixOperatingSystem class methodsFor:'file locking'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3795
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3796
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3797
   "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
  3798
    (such as returned by ExternalStream>>fileDescriptor).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3799
    On some systems, only advisory locks are available -
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3800
    these depends on other accessors to also perform the locking operation.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3801
    If they do not, they may still access the file
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3802
    (on some systems, locks are mandatory, on others, they are advisory).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3803
    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
  3804
    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
  3805
    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
  3806
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3807
    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
  3808
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3809
    Notice, that not all OS's support these locks;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3810
    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
  3811
    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
  3812
    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
  3813
    argument."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3814
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3815
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3816
    if (__isSmallInteger(aFileDescriptor)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3817
	int fd = __intVal(aFileDescriptor);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3818
	int lockArg;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3819
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3820
	/*
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3821
	 * claus: sigh - each one has a different interface ...
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3822
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3823
#if defined(F_SETLK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3824
	{
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3825
	    /*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3826
	     * new fcntl(SETLK) interface;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3827
	     * available on SYSV4 and Linux
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3828
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3829
	    struct flock flock;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3830
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3831
	    if (isSharedReadLock == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3832
		flock.l_type = F_RDLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3833
	    } else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3834
		flock.l_type = F_WRLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3835
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3836
	    flock.l_whence = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3837
	    flock.l_start = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3838
	    flock.l_len = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3839
	    lockArg = F_SETLK;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3840
# if defined(F_SETLKW)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3841
	    if (blockIfLocked == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3842
		lockArg = F_SETLKW;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3843
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3844
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3845
	    if (fcntl(fd, lockArg, &flock) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3846
		RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3847
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3848
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3849
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3850
#else /* no F_SETLK available */
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
# if defined(LOCK_EX) && defined(LOCK_UN)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3853
	/*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3854
	 * BSD 4.3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3855
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3856
	lockArg = LOCK_EX;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3857
#  if defined(LOCK_SH)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3858
	if (isSharedReadLock == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3859
	    lockArg = LOCK_SH
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3860
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3861
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3862
#  if defined(LOCK_NB)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3863
	if (blockIfLocked == false) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3864
	    lockArg |= LOCK_NB;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3865
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3866
#  endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3867
	if (flock(fd, lockArg) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3868
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3869
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3870
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3871
# else /* no flock available */
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
#  if defined(F_LOCK) && defined(F_UNLOCK)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3874
	/*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3875
	 * SYSV3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3876
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3877
	if (lockf(fd, F_LOCK, 0) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3878
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3879
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3880
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3881
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3882
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3883
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3884
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3885
    ^ false
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3888
supportsFileLinks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3889
    "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
  3890
     Typically, only unix returns true here."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3891
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3892
    ^ true
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3893
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3894
    "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
  3895
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3896
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3897
supportsFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3898
    "return true, if the OS supports file locking"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3899
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3900
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3901
#if defined(F_SETLK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3902
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3903
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3904
# if defined(LOCK_EX) && defined(LOCK_UN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3905
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3906
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3907
#  if defined(F_LOCK) && defined(F_UNLOCK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3908
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3909
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3910
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3911
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3912
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3913
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3914
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3915
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3916
     OperatingSystem supportsFileLocks
3496
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
!
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
supportsNonBlockingFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3921
    "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
  3922
     (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
  3923
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3924
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3925
#if defined(F_SETLK) && defined(F_SETLKW)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3926
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3927
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3928
# 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
  3929
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3930
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3931
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3932
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3933
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3934
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3935
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3936
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3937
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3938
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3939
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3940
supportsSharedLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3941
    "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
  3942
     file locking."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3943
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3944
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3945
#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
  3946
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3947
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3948
# 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
  3949
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3950
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3951
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3952
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3953
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3954
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3955
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3956
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3957
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3958
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3959
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3960
unlockFD:aFileDescriptor
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3961
    "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
  3962
     which was previously aquired by #lockFD:.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3963
     Return false, if the unlock failed
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3964
     (which may happens when a wrong fd is passed,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3965
      no lock was set previously, or the systsem does not support locks).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3966
     Notice, that not all OS's support file locks;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3967
     on some, this may simply be a no-op."
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3968
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3969
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3970
    if (__isSmallInteger(aFileDescriptor)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3971
	int fd = __intVal(aFileDescriptor);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3972
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3973
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3974
	 * claus: sigh - each one has a different interface ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3975
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3976
#if defined(F_SETLK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3977
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3978
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3979
	     * new fcntl(SETLK) interface;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3980
	     * available on SYSV4 and Linux
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3981
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3982
	    struct flock flock;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3983
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3984
	    flock.l_type = F_UNLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3985
	    flock.l_whence = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3986
	    flock.l_start = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3987
	    flock.l_len = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3988
	    if (fcntl(fd, F_SETLK, &flock) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3989
		RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3990
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3991
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3992
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3993
#else /* no F_SETLK available */
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
# if defined(LOCK_EX) && defined(LOCK_UN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3996
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3997
	 * BSD 4.3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3998
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3999
	if (flock(fd, LOCK_UN) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4000
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4001
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4003
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4005
#  if defined(F_LOCK) && defined(F_UNLOCK)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4006
	/*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4007
	 * SYSV3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4008
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4009
	if (lockf(fd, F_UNLOCK, 0) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4010
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4011
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4012
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4013
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4014
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4015
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4016
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4017
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4018
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4019
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4020
!UnixOperatingSystem class methodsFor:'file queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4021
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4022
caseSensitiveFilenames
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4023
    "return true, if the OS has caseSensitive file naming.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4024
     On MSDOS, this will return false;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4025
     on a real OS, we return true."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4026
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4027
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4028
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4029
    "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
  4030
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4031
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4032
compressPath:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4033
    "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
  4034
     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
  4035
     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
  4036
     if realPath and popen failed."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4037
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4038
    |names n "{ Class: SmallInteger }" |
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4039
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4040
    names := pathName
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4041
		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4042
    names := names asOrderedCollection.
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
     cut off initial double-slashes
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
    [names startsWith:#('' '')] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4047
	names removeFirst.
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
     cut off double-slashes at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4051
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4052
    [names endsWith:#('')] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4053
	names removeLast.
3496
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
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4056
     cut off current-dir at beginning
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4057
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4058
    n := names size.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4059
    [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4060
	names removeFirst.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4061
	n := n - 1.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4062
    ].
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
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4065
     cut off parent-dirs at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4066
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4067
    [(n > 2)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4068
     and:[(names endsWith:#('..'))
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4069
     and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4070
	names removeLast; removeLast.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4071
	n := n - 2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4072
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4073
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4074
    ^ names asStringWith:self fileSeparator
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4075
		    from:1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4076
		    to:n
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4077
		    compressTabs:false final:nil
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4078
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4079
    "
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4080
     OperatingSystem compressPath:'./..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4081
     OperatingSystem compressPath:'/foo/bar/baz/..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4082
     OperatingSystem compressPath:'foo/bar/baz/..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4083
     OperatingSystem compressPath:'foo/bar/baz/../'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4084
     OperatingSystem compressPath:'foo/bar/baz/..///'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4085
     OperatingSystem compressPath:'///foo/bar/baz/..///'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4086
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4087
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4088
    "Modified: 1.11.1996 / 20:13:48 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4089
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4090
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4091
fileSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4092
    "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
  4093
     This character differs for MSDOS and other systems,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4094
     (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
  4095
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4096
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4097
    ^ $/
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4098
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4099
    "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
  4100
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4101
13110
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4102
getCurrentDirectory
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4103
    "return the name of the current directory"
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4104
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4105
    |path|
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4106
14590
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
  4107
    path := self decodePath:self primGetCurrentDirectory.
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4108
    CurrentDirectory := path.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4109
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4110
    ^ path.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4111
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4112
    "
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4113
	self getCurrentDirectory
13110
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4114
    "
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4115
!
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4116
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4117
getDiskInfoOf:aDirectoryPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4118
    "return some disk info.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4119
     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
  4120
     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
  4121
     On unix, the information returned is (at least):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4122
	freeBytes
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4123
	totalBytes
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4124
    "
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4125
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4126
    |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
  4127
     fileSystemIdx sizeIdx usedIdx availIdx capacityIdx mountIdx|
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4128
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4129
    p := PipeStream readingFrom:('df -k ' , aDirectoryPath).
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4130
    p isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4131
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4132
    [
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4133
	outputText := p contentsOfEntireFile.
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6375
diff changeset
  4134
    ] ensure:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4135
	p close.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4136
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4137
"/ Transcript showCR:outputText asString.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4138
    outputText isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4139
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4140
    outputText := outputText asCollectionOfLines.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4141
    outputText size < 2 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4142
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4143
    keys := (outputText at:1) asLowercase asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4144
    values := (outputText at:2) asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4145
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4146
    "/ 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
  4147
    "/ on some rude Unix versions ...
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4148
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4149
    fileSystemIdx := 1.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4150
    sizeIdx := 2.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4151
    usedIdx := 3.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4152
    availIdx := 4.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4153
    capacityIdx := 5.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4154
    mountIdx := 6.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4155
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4156
    values size < 6 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4157
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4158
    info := IdentityDictionary new.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4159
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4160
    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
  4161
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4162
	info at:#percentUsed put:n
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4163
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4164
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4165
    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
  4166
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4167
	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
  4168
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4169
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4170
    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
  4171
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4172
	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
  4173
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4174
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4175
    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
  4176
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4177
	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
  4178
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4179
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4180
    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
  4181
    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
  4182
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4183
    ^ info
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4184
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4185
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4186
     OperatingSystem getDiskInfoOf:'/'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4187
     OperatingSystem getDiskInfoOf:'.'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4188
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4189
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4190
    "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
  4191
!
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4192
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4193
getDriveList
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4194
    "return a list of volumes in the system.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4195
     On unix, no such thing like a volume exists
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4196
     - there, a synthetic list with root, home & current is returned.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4197
     On MSDOS, a list of drive letters is returned.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4198
     On VMS, a list of volumes is returned."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4199
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4200
    "/
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4201
    "/ default: return array filled with
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4202
    "/ root, home and current directories.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4203
    "/
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4204
    ^ Array
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4205
	with:'/'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4206
	with:(self getHomeDirectory)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4207
	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
  4208
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4209
    "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
  4210
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4211
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4212
getMountedVolumes
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4213
    "return info about mounted volumes.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4214
     The amount of information returned depends upon the OS, and is
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4215
     not guaranteed to be consistent across architectures.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4216
     On unix, the information returned is (at least):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4217
	mountPoint - mount point
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4218
	fileSystem - device or NFS-remotePath
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4219
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4220
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4221
    |p outputText keys values info infoEntry|
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4222
4933
bfa38904104e use df -k
Claus Gittinger <cg@exept.de>
parents: 4923
diff changeset
  4223
    p := PipeStream readingFrom:('df -k').
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4224
    p isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4225
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4226
    [
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4227
	outputText := p contentsOfEntireFile.
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6375
diff changeset
  4228
    ] ensure:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4229
	p close.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4230
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4231
"/ Transcript showCR:outputText asString.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4232
    outputText isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4233
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4234
    outputText := outputText asCollectionOfLines.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4235
    outputText size < 2 ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4236
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4237
    keys := (outputText at:1) asLowercase asCollectionOfWords.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4238
    "/ we may have to validate the following column indices
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4239
    "/ on some rude Unix versions ...
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4240
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4241
    info := OrderedCollection new.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4242
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4243
    outputText from:2 do:[:line |
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4244
	values := line asCollectionOfWords.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4245
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4246
	values size >= 2 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4247
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4248
	    infoEntry := IdentityDictionary new.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4249
	    infoEntry at:#mountPoint put:(values last).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4250
	    infoEntry at:#fileSystem put:(values first).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4251
	    info add:infoEntry.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4252
	]
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4253
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4254
    ^ info
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4255
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4256
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4257
     OperatingSystem getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4258
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4259
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4260
    "Modified: / 22.5.1999 / 00:32:13 / cg"
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4261
!
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4262
4201
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4263
getNullDevice
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4264
    "return the name of the OS's null device"
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4265
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4266
    ^ '/dev/null'
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4267
!
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4268
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4269
infoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4270
    "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
  4271
     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
  4272
     the returned object) is:
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4273
	 type            - a symbol giving the files type
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4274
	 mode            - numeric access mode
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4275
	 uid             - owners user id
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4276
	 gid             - owners group id
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4277
	 size            - files size
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4278
	 id              - files number (i.e. inode number)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4279
	 accessed        - last access time (as Timestamp)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4280
	 modified        - last modification time (as Timestamp)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4281
	 statusChanged   - last status change time (as Timestamp)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4282
	 alternativeName     - (windows only:) the MSDOS name of the file
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4283
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4284
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4285
	 recordAttributes    - (VMS only:) recordAttributes
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4286
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4287
	 recordSize          - (VMS only:) record size.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4288
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4289
     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
  4290
     all of the information.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4291
     Return nil if such a file does not exist.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4292
     For symbolic links (if supported by the OS),
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4293
     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
  4294
     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
  4295
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4296
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4297
    |type mode uid gid size id nLink aOStime mOStime cOStime error encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4298
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4299
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4300
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4301
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4302
    int ret;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4303
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4304
    if (!__isStringLike(encodedPathName)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4305
	error = @symbol(badArgument);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4306
	goto out;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4307
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4308
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4309
# ifdef TRACE_STAT_CALLS
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4310
    printf("stat on '%s' for info\n", __stringVal(aPathName));
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4311
# endif
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4312
    __BEGIN_INTERRUPTABLE__
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4313
    do {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4314
	ret = stat((char *) __stringVal(encodedPathName), &buf);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4315
    } while ((ret < 0) && (errno == EINTR));
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4316
    __END_INTERRUPTABLE__
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4317
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4318
    if (ret < 0) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4319
	error = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4320
	@global(LastErrorNumber) = error;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4321
	goto out;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4322
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4323
    switch (buf.st_mode & S_IFMT) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4324
	case S_IFDIR:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4325
	    type = @symbol(directory);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4326
	    break;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4327
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4328
	case S_IFREG:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4329
	    type = @symbol(regular);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4330
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4331
# ifdef S_IFCHR
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4332
	case S_IFCHR:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4333
	    type = @symbol(characterSpecial);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4334
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4335
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4336
# ifdef S_IFBLK
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4337
	case S_IFBLK:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4338
	    type = @symbol(blockSpecial);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4339
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4340
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4341
# ifdef S_IFMPC
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4342
	case S_IFMPC:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4343
	    type = @symbol(multiplexedCharacterSpecial);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4344
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4345
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4346
# ifdef S_IFMPB
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4347
	case S_IFMPB:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4348
	    type = @symbol(multiplexedBlockSpecial);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4349
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4350
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4351
# ifdef S_IFLNK
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4352
	case S_IFLNK:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4353
	    type = @symbol(symbolicLink);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4354
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4355
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4356
# ifdef S_IFSOCK
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4357
	case S_IFSOCK:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4358
	    type = @symbol(socket);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4359
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4360
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4361
# ifdef S_IFIFO
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4362
	case S_IFIFO:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4363
	    type = @symbol(fifo);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4364
	    break;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4365
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4366
	default:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4367
	    type = @symbol(unknown);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4368
	    break;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4369
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4370
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4371
    if (sizeof(buf.st_ino) == 8) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4372
	id = __MKUINT64(&buf.st_ino);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4373
    } else {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4374
	id = __MKUINT(buf.st_ino);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4375
    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4376
    mode = __mkSmallInteger(buf.st_mode & 0777);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4377
    uid = __mkSmallInteger(buf.st_uid);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4378
    gid = __mkSmallInteger(buf.st_gid);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4379
    nLink = __mkSmallInteger(buf.st_nlink);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4380
    if (sizeof(buf.st_size) == 8) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4381
	size = __MKINT64(&buf.st_size);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4382
    } else {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4383
	size = __MKINT(buf.st_size);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4384
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4385
    aOStime = __MKUINT(buf.st_atime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4386
    mOStime = __MKUINT(buf.st_mtime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4387
    cOStime = __MKUINT(buf.st_ctime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4388
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4389
    out:;
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4390
%}.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4391
     mode notNil ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4392
	"/ now done lazy in FileStatusInfo
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4393
	"/ atime := Timestamp fromOSTime:(aOStime * 1000).
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4394
	"/ mtime := Timestamp fromOSTime:(mOStime * 1000).
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4395
	"/ ctime := Timestamp fromOSTime:(cOStime * 1000).
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4396
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4397
	^ FileStatusInfo
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4398
		    type:type
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4399
		    mode:mode
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4400
		    uid:uid
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4401
		    gid:gid
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4402
		    size:size
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4403
		    id:id
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4404
		    accessed:aOStime
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4405
		    modified:mOStime
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4406
		    statusChanged:cOStime
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4407
		    path:nil
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4408
		    numLinks:nLink.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4409
    ].
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4410
    error notNil ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4411
	^ nil.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4412
    ].
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4413
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4414
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4415
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4416
   "
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4417
    OperatingSystem infoOf:'/ccccccc'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4418
    (OperatingSystem infoOf:'/') uid
7889
5e96f8cdf9aa Fix comment
Stefan Vogel <sv@exept.de>
parents: 7886
diff changeset
  4419
    (OperatingSystem infoOf:'/') accessTime
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4420
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4421
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4422
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4423
isDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4424
    "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
  4425
     (i.e. exists and is a directory).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4426
     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
  4427
     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
  4428
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4429
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4430
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4431
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4432
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4433
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4434
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4435
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4436
    if (__isStringLike(encodedPathName)) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4437
	struct stat buf;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4438
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4439
# ifdef TRACE_STAT_CALLS
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4440
	printf("stat on '%s' for isDirectory\n", __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4441
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4442
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4443
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4444
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4445
	} while ((ret < 0) && (errno == EINTR));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4446
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4447
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4448
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4449
	    RETURN ( false );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4450
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4451
	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
  4452
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4453
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4454
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4455
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4456
    "an alternative implementation would be:
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4457
	^ (self infoOf:aPathName) type == #directory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4458
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4459
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4460
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4461
isExecutable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4462
    "return true, if the given file is executable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4463
     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
  4464
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4465
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4466
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4467
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4468
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4469
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4470
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4471
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4472
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4473
# ifdef TRACE_ACCESS_CALLS
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4474
	printf("access on '%s' for executable\n", __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4475
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4476
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4477
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4478
	    ret = access(__stringVal(encodedPathName), X_OK);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4479
	} while ((ret < 0) && (errno == EINTR));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4480
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4481
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4482
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4483
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4484
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4485
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4486
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4487
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4488
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4489
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4490
isReadable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4491
    "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
  4492
     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
  4493
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4494
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4495
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4496
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4497
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4498
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4499
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4500
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4501
# ifdef TRACE_ACCESS_CALLS
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4502
	printf("access on '%s' for readable\n", __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4503
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4504
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4505
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4506
	    ret = access(__stringVal(encodedPathName), R_OK);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4507
	} while ((ret < 0) && (errno == EINTR));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4508
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4509
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4510
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4511
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4512
	RETURN ( ((ret == 0) ? true : false) );
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
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4515
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4516
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4517
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4518
isValidPath:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4519
    "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
  4520
     (i.e. the file or directory exists)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4521
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4522
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4523
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4524
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4525
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4526
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4527
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4528
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4529
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4530
# ifdef TRACE_STAT_CALLS
15072
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4531
        printf("stat on '%s' for isValidPath\n", __stringVal(encodedPathName));
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4532
# endif
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4533
        __BEGIN_INTERRUPTABLE__
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4534
        do {
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4535
            ret = stat((char *) __stringVal(encodedPathName), &buf);
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4536
        } while ((ret < 0) && (errno == EINTR));
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4537
        __END_INTERRUPTABLE__
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4538
        if (ret < 0) {
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4539
            @global(LastErrorNumber) = __mkSmallInteger(errno);
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4540
            RETURN (false);
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4541
        }
da8a6e7c9d5c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14899
diff changeset
  4542
        RETURN ( ret ? false : true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4543
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4544
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4545
    ^ self primitiveFailed
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4546
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4547
"/ alternative:
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4548
"/        ^ (self infoOf:aPathName) notNil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4549
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4550
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4551
isWritable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4552
    "return true, if the given file is writable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4553
     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
  4554
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4555
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4556
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4557
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4558
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4559
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4560
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4561
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4562
# ifdef TRACE_ACCESS_CALLS
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4563
	printf("access on '%s' for writable\n", __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4564
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4565
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4566
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4567
	    ret = access(__stringVal(encodedPathName), W_OK);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4568
	} while ((ret < 0) && (errno == EINTR));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4569
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4570
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4571
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4572
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4573
	RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4574
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4575
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4576
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4577
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4578
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4579
linkInfoOf:aPathName
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4580
    "return some object filled with info for the file 'aPathName'.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4581
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4582
     The info (for which corresponding access methods are understood by
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4583
     the returned object) is:
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4584
	 type            - a symbol giving the files type
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4585
	 mode            - numeric access mode
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4586
	 uid             - owners user id
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4587
	 gid             - owners group id
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4588
	 size            - files size
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4589
	 id              - files number (i.e. inode number)
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4590
	 accessed        - last access time (as Timestamp)
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4591
	 modified        - last modification time (as Timestamp)
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4592
	 statusChanged   - last status change time (as Timestamp)
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4593
	 alternativeName     - (windows only:) the MSDOS name of the file
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4594
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4595
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4596
	 recordAttributes    - (VMS only:) recordAttributes
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4597
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4598
	 recordSize          - (VMS only:) record size.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4599
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4600
     Some of the fields may be returned as nil on systems which do not provide
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4601
     all of the information.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4602
15250
c73ad268f7f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15234
diff changeset
  4603
     If aPathName is invalid, nil is returned.
c73ad268f7f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15234
diff changeset
  4604
     If aPathName is NOT a symbolic link, the #infoOf: aPathname itself is returned.
c73ad268f7f0 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15234
diff changeset
  4605
     (which means, that systems like VMS or MSDOS always return the info here.)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4606
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4607
     Return the info about the link itself,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4608
     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
  4609
     in case of a symbolic link."
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4610
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4611
    |type mode uid gid size id nLink aOStime mOStime cOStime path encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4612
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4613
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4614
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4615
%{  /* STACK: 1200 */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  4616
#if defined(S_IFLNK)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4617
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4618
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4619
    char pathBuffer[1024];
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4620
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4621
    if (__isStringLike(encodedPathName)) {
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4622
	__BEGIN_INTERRUPTABLE__
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4623
	do {
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4624
	    ret = lstat((char *) __stringVal(encodedPathName), &buf);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4625
	} while ((ret < 0) && (errno == EINTR));
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4626
	__END_INTERRUPTABLE__
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4627
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4628
	if (ret < 0) {
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4629
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4630
	    RETURN ( nil );
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4631
	}
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4632
	switch (buf.st_mode & S_IFMT) {
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4633
    # ifdef S_IFLNK
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4634
	    case S_IFLNK:
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4635
		type = @symbol(symbolicLink);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4636
		if ((ret = readlink((char *) __stringVal(encodedPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4637
		    @global(LastErrorNumber) = __mkSmallInteger(errno);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4638
		    RETURN ( nil );
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4639
		}
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4640
		pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4641
		path = __MKSTRING(pathBuffer);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4642
		break;
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4643
    # endif
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4644
	    case S_IFDIR:
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4645
		type = @symbol(directory);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4646
		break;
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4647
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4648
	    case S_IFREG:
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4649
		type = @symbol(regular);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4650
		break;
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4651
    # ifdef S_IFCHR
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4652
	    case S_IFCHR:
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4653
		type = @symbol(characterSpecial);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4654
		break;
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4655
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4656
    # ifdef S_IFBLK
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4657
	    case S_IFBLK:
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4658
		type = @symbol(blockSpecial);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4659
		break;
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4660
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4661
    # ifdef S_IFMPC
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4662
	    case S_IFMPC:
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4663
		type = @symbol(multiplexedCharacterSpecial);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4664
		break;
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4665
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4666
    # ifdef S_IFMPB
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4667
	    case S_IFMPB:
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4668
		type = @symbol(multiplexedBlockSpecial);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4669
		break;
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4670
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4671
    # ifdef S_IFSOCK
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4672
	    case S_IFSOCK:
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4673
		type = @symbol(socket);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4674
		break;
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4675
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4676
    # ifdef S_IFIFO
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4677
	    case S_IFIFO:
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4678
		type = @symbol(fifo);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4679
		break;
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4680
    # endif
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4681
	    default:
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4682
		type = @symbol(unknown);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4683
		break;
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4684
	}
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4685
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4686
	if (sizeof(buf.st_ino) == 8) {
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4687
	    id = __MKUINT64(&buf.st_ino);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4688
	} else {
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4689
	    id = __MKUINT(buf.st_ino);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4690
	}
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4691
	mode = __mkSmallInteger(buf.st_mode & 0777);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4692
	uid = __mkSmallInteger(buf.st_uid);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4693
	gid = __mkSmallInteger(buf.st_gid);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4694
	nLink = __mkSmallInteger(buf.st_nlink);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4695
	if (sizeof(buf.st_size) == 8) {
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4696
	    size = __MKINT64(&buf.st_size);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4697
	} else {
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4698
	    size = __MKINT(buf.st_size);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4699
	}
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4700
	aOStime = __MKUINT(buf.st_atime);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4701
	mOStime = __MKUINT(buf.st_mtime);
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4702
	cOStime = __MKUINT(buf.st_ctime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4703
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4704
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4705
    RETURN ( nil );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4706
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4707
%}.
14563
466905625978 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14435
diff changeset
  4708
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4709
    mode notNil ifTrue:[
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4710
	^ FileStatusInfo
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4711
	    type:type
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4712
	    mode:mode
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4713
	    uid:uid
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4714
	    gid:gid
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4715
	    size:size
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4716
	    id:id
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4717
	    accessed:aOStime
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4718
	    modified:mOStime
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4719
	    statusChanged:cOStime
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4720
	    path:(self decodePath:path)
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
  4721
	    numLinks:nLink.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4722
   ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4723
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4725
   "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4726
    OperatingSystem infoOf:'Make.proto'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4727
    OperatingSystem linkInfoOf:'Make.proto'
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4728
    OperatingSystem linkInfoOf:'/usr/tmp'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4729
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4730
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4731
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4732
mountPoints
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4733
    "return a collection of mountPoints (aka. topDirectories of mounted file systems).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4734
     As this might be expensive on some systems,
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4735
     the info is cached for some time (5 minutes)"
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4736
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4737
    CacheMountPointsTimeStamp notNil ifTrue:[
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4738
	Timestamp now < (CacheMountPointsTimeStamp addSeconds:5*60) ifTrue:[
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4739
	    ^ CachedMountPoints
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4740
	].
8735
531252ebbbe3 Fix a race in #mountPoints
Stefan Vogel <sv@exept.de>
parents: 8705
diff changeset
  4741
    ].
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4742
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4743
    '/proc/mounts' asFilename exists ifTrue:[
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4744
	CachedMountPoints := self mountPointsFromProcFS.
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4745
	CacheMountPointsTimeStamp := Timestamp now.
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4746
	^ CachedMountPoints
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4747
    ].
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4748
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4749
    "/ TODO: add fallback code for other OS's (i.e. reading /etc/mtab)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4750
    ^ #()
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4751
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4752
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4753
     OperatingSystem mountPoints
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4754
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4755
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4756
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4757
parentDirectoryName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4758
    "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
  4759
     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
  4760
     for other systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4761
     (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
  4762
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4763
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4764
    ^ '..'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4765
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4766
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4767
pathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4768
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4769
     - 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
  4770
     This method needs the path to be valid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4771
     (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
  4772
     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
  4773
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4774
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4775
    |p path command|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4776
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4777
    path = '.' ifTrue:[
15155
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4778
        ^ self getCurrentDirectory.
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4779
    ].
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4780
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4781
    "some systems have a convenient function for this ..."
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4782
    path := self primPathNameOf:(self encodePath:pathName).
14575
c696ca8d05bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14568
diff changeset
  4783
    path notNil ifTrue:[
15155
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4784
        path := self decodePath:path.
14575
c696ca8d05bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14568
diff changeset
  4785
    ] ifFalse:[
15155
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4786
        (self isValidPath:pathName) ifFalse:[
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4787
            p := pathName.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4788
            [(p size > 1)
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4789
             and:[p endsWith:(self fileSeparator)]
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4790
            ] whileTrue:[
15157
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  4791
                p := p copyButLast:1.
15155
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4792
            ].
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4793
            ^ p
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4794
        ].
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4795
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4796
        (SlowFork==true or:[PipeFailed==true]) ifFalse:[
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4797
            |directoryName fileBaseName|
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4798
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4799
            (self isDirectory:pathName) ifTrue:[
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4800
                directoryName := pathName.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4801
                fileBaseName := nil.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4802
            ] ifFalse:[
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4803
                |pathFilename|
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4804
                pathFilename := pathName asFilename.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4805
                directoryName := pathFilename directoryName.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4806
                fileBaseName := pathFilename baseName.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4807
            ].
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4808
            
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4809
            PipeStream openErrorSignal handle:[:ex |
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4810
                PipeFailed := true.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4811
                'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4812
                ex return.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4813
            ] do:[
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4814
                "have to fall back ..."
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4815
                command := 'cd "' , directoryName , '"; pwd'.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4816
                p := PipeStream readingFrom:command.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4817
            ].
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4818
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4819
            (p isNil or:[p atEnd]) ifTrue:[
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4820
                ('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4821
            ] ifFalse:[
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4822
                path := p nextLine.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4823
                p close.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4824
            ].
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4825
            fileBaseName notNil ifTrue:[
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4826
                path := path, '/', fileBaseName.
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4827
            ].
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4828
        ].
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4829
        path isNil ifTrue:[
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4830
            "/
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4831
            "/ return the original - there is nothing else can we do
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4832
            "/
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4833
            path := pathName
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4834
        ].
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4835
        (SlowFork==true or:[ForkFailed==true]) ifTrue:[
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4836
            path := self compressPath:path
e6df51948b20 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15153
diff changeset
  4837
        ]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4838
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4839
    ^ path.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4840
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4841
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4842
     OperatingSystem pathNameOf:'.'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4843
     OperatingSystem pathNameOf:'../smalltalk/../smalltalk'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4844
     OperatingSystem pathNameOf:'../../..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4845
     OperatingSystem pathNameOf:'..'
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4846
     OperatingSystem pathNameOf:'/tmp////'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4847
     OperatingSystem pathNameOf:'/foo/bar'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4848
     OperatingSystem pathNameOf:'/foo/bar/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4849
     OperatingSystem pathNameOf:'/foo/bar//'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4850
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4851
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4852
    "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
  4853
    "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
  4854
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4855
14584
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4856
primGetCurrentDirectory
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4857
    "return the name of the current directory"
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4858
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4859
    |path|
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4860
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4861
%{  /* UNLIMITEDSTACK */
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4862
	char nameBuffer[MAXPATHLEN + 1];
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4863
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4864
	if (getcwd(nameBuffer, MAXPATHLEN)) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4865
	    path = __MKSTRING(nameBuffer);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4866
	    RETURN(path);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4867
	}
14584
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4868
%}.
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4869
    ^ self primitiveFailed.
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4870
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4871
    "
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4872
	self primGetCurrentDirectory
14584
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4873
    "
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4874
!
123279afebb9 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14582
diff changeset
  4875
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4876
primIdOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4877
    "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
  4878
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4879
    |encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4880
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4881
    encodedPathName := self encodePath:aPathName.
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  4882
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4883
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4884
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4885
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4886
    OBJ retVal;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4887
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4888
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4889
# ifdef TRACE_STAT_CALLS
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4890
	printf("stat on '%s' for id\n", __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4891
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4892
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4893
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4894
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4895
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4896
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4897
	if (ret >= 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4898
	    ino = buf.st_ino;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4899
	    retVal = __MKUINT(ino);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4900
	    RETURN (retVal);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4901
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4902
	@global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4903
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4904
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4905
    RETURN (nil);
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4908
5492
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4909
primInfoOf:aPathName
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4910
   "for rel5 only"
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4911
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4912
   ^ self primitiveFailed
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4913
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4914
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4915
!
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  4916
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4917
primPathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4918
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4919
     - 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
  4920
     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
  4921
     realPath library function.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4922
     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
  4923
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4924
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4925
    |error|
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4926
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  4927
%{  /* UNLIMITEDSTACK */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4928
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4929
    if (__isStringLike(pathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4930
#ifdef HAS_REALPATH
15175
1239f9959ed8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 15157
diff changeset
  4931
	extern char *realpath();
1239f9959ed8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 15157
diff changeset
  4932
15157
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  4933
        // POSIX-2008 says, that a NULL namebuffer causes realPath to malloc()
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  4934
        // the required memory. But this does not work as of 2013-04
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  4935
        char nameBuffer[MAXPATHLEN+1];
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  4936
        char *nameP = realpath(__stringVal(pathName), nameBuffer);
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4937
        if (nameP) {
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4938
            OBJ ret = __MKSTRING(nameP);
15157
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  4939
            // free(nameP);
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4940
            RETURN ( ret );
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4941
        }
15157
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  4942
        // fprintf(stderr, "stx[warning]: realpath(\"%s\") failed: %s\n", __stringVal(pathName), strerror(errno));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4943
#endif /* ! HAS_REALPATH */
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4944
    } else {
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4945
        error = @symbol(argument);     // argument is not a string
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4946
    }
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4947
%}.
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4948
"/ Does not work as of 2013-04 (UNLIMITEDSTACK problem?)
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4949
"/    error notNil ifTrue:[
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4950
"/        ^ self primitiveFailed:error.
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4951
"/    ].
5451
2e21cd54b656 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5448
diff changeset
  4952
    ^ nil
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4953
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4954
    "
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4955
        self primPathNameOf:'.'
15157
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  4956
        self primPathNameOf:'/murks/quatsch/bla/.'
15153
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4957
        self primPathNameOf:5555
445368176cf3 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15152
diff changeset
  4958
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4959
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4960
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4961
timeOfLastAccess:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4962
    "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
  4963
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4964
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4965
    "could be implemented as:
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4966
	(self infoOf:aPathName) accessed
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4967
    "
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4968
    |osSeconds i encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4969
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4970
    encodedPathName := self encodePath:aPathName.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4971
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4972
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4973
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4974
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4975
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4976
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  4977
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4978
# ifdef TRACE_STAT_CALLS
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4979
	printf("stat on '%s' for timeOfLastAccess\n", __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4980
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4981
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4982
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4983
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4984
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4985
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4986
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4987
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4988
	    RETURN (nil);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4989
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  4990
	osSeconds = __MKUINT(buf.st_atime);
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  4991
    }
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  4992
%}.
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  4993
    osSeconds notNil ifTrue:[^ Timestamp fromOSTime:(osSeconds * 1000)].
3496
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
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4996
    i notNil ifTrue:[^ i accessed].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4997
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4998
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4999
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5000
     OperatingSystem timeOfLastAccess:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5001
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5002
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5003
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5004
timeOfLastChange:aPathName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5005
    "return the time, when the file was last changed.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5006
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5007
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5008
    "could be implemented as:
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5009
	(self infoOf:aPathName) modified
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5010
    "
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5011
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5012
    |osSeconds i encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5013
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5014
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5015
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5016
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5017
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5018
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5019
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5020
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5021
# ifdef TRACE_STAT_CALLS
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5022
	printf("stat on '%s' for timeOfLastChange\n", __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5023
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5024
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5025
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5026
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5027
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5028
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5029
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5030
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5031
	    RETURN ( nil );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5032
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5033
	osSeconds = __MKUINT(buf.st_mtime);
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5034
    }
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5035
%}.
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5036
    osSeconds notNil ifTrue:[^ Timestamp fromOSTime:(osSeconds * 1000)].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5037
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5038
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5039
    i notNil ifTrue:[^ i modified].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5040
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5041
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5042
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5043
     OperatingSystem timeOfLastChange:'/'
3496
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5046
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5047
typeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5048
    "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
  5049
     nil is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5050
     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
  5051
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5052
    |i osSeconds encodedPathName|
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5053
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5054
    encodedPathName := self encodePath:aPathName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5055
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5056
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5057
     this could have been implemented as:
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5058
	(self infoOf:aPathName) type
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5059
     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
  5060
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5061
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
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5064
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5065
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  5066
    if (__isStringLike(encodedPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5067
# ifdef TRACE_STAT_CALLS
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5068
	printf("stat on '%s' for type\n", __stringVal(encodedPathName));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5069
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5070
	__BEGIN_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5071
	do {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5072
	    ret = stat((char *) __stringVal(encodedPathName), &buf);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5073
	} while (ret < 0 && errno == EINTR);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5074
	__END_INTERRUPTABLE__
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5075
	if (ret < 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5076
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5077
	    RETURN ( nil );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5078
	}
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5079
	switch (buf.st_mode & S_IFMT) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5080
	    case S_IFDIR:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5081
		RETURN ( @symbol(directory) );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5082
	    case S_IFREG:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5083
		RETURN ( @symbol(regular) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5084
# ifdef S_IFCHR
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5085
	    case S_IFCHR:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5086
		RETURN ( @symbol(characterSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5087
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5088
# ifdef S_IFBLK
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5089
	    case S_IFBLK:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5090
		RETURN ( @symbol(blockSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5091
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5092
# ifdef S_IFLNK
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5093
	    case S_IFLNK:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5094
		RETURN ( @symbol(symbolicLink) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5095
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5096
# ifdef S_IFSOCK
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5097
	    case S_IFSOCK:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5098
		RETURN ( @symbol(socket) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5099
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5100
# ifdef S_IFIFO
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5101
	    case S_IFIFO:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5102
		RETURN ( @symbol(fifo) );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5103
# endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5104
	    default:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5105
		RETURN ( @symbol(unknown) );
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  5106
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5107
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5108
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5109
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5110
    i notNil ifTrue:[^ i type].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5111
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5112
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5113
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5114
     OperatingSystem typeOf:'/'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5115
     OperatingSystem typeOf:'.'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5116
     OperatingSystem typeOf:'Make.proto'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5117
     OperatingSystem typeOf:'resources/motif.style'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5118
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5119
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5120
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5121
volumeNameOf:aPathString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5122
    "return the volumeName of the argument, aPath
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5123
     - thats the name of the volume where aPath is.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5124
     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
  5125
     this always returns an empty string."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5126
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5127
    ^ ''
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5128
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5129
    "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
  5130
! !
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
!UnixOperatingSystem class methodsFor:'interrupts & signals'!
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
defaultSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5135
    "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
  5136
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5137
     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
  5138
     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
  5139
     default for SIGQUIT (^ \) is to dump core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5140
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5141
     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
  5142
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5143
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5144
%{  /* NOCONTEXT */
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
    if (__isSmallInteger(signalNumber)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5147
#ifdef SIG_DFL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5148
	signal(__intVal(signalNumber), SIG_DFL);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5149
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5150
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5151
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5152
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5153
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5154
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5155
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5156
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5157
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5158
    "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
  5159
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5160
     'if you hit ^C now, Smalltalk will exit immediately' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5161
     OperatingSystem defaultSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5162
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5163
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5164
     'normal ^C handling again.' printNewline
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5167
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5168
disableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5169
    "turn off IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5170
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5171
%{  /* NOCONTEXT */
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
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5174
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5175
#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
  5176
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5177
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5178
# if defined(SYSV4)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5179
	ret = ioctl(f, I_SETSIG, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5180
# else /*! SYSV4*/
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5181
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5182
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5183
	 * if already clear, there is no need for this syscall ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5184
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5185
	if (flags & FASYNC) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5186
	    ret = fcntl(f, F_SETFL, flags & ~FASYNC);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5187
	    if (ret >= 0) ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5188
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5189
	    ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5190
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5191
# endif /* !SYSV4 */
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5192
	RETURN ( __mkSmallInteger(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5193
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5194
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5195
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5196
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5197
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5198
     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
  5199
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5200
    ^ self primitiveFailed
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5203
disableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5204
    "disable (Unix-) signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5205
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5206
     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
  5207
     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
  5208
     handling.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5209
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5210
     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
  5211
     a signal.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5212
     Use only for fully debugged stand alone applications."
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
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5215
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5216
    if (__isSmallInteger(signalNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5217
	int sigNo = __intVal(signalNumber);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5218
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5219
	if (sigNo == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5220
	    RETURN (self);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5221
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5222
#ifdef SIG_IGN
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5223
	signal(sigNo, SIG_IGN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5224
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5225
#endif
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
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5228
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5229
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5230
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5231
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5232
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5233
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5234
     'now, ^C is totally ignored ...' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5235
     OperatingSystem disableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5236
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5237
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5238
     '^C handled again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5239
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5240
!
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
disableTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5243
    "disable timer interrupts.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5244
     WARNING:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5245
	the system will not operate correctly with timer interrupts
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5246
	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
  5247
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5248
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5249
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5250
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5251
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5252
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5253
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5254
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5255
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5256
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5257
    setitimer(ITIMER_REAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5258
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5259
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5260
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5261
# if defined(USE_SLOW_ALARM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5262
#  if defined(SIGALRM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5263
    alarm(0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5264
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5265
#  endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5266
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5267
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5268
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5269
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5270
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5271
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5272
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5273
enableChildSignalInterrupts
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5274
    "enable childSignal interrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5275
     (SIGCHLD, if the architecture supports it).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5276
     After enabling, these signals will send the message
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5277
     'childSignalInterrupt' to the ChildSignalInterruptHandler object."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5278
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5279
    self enableSignal:(self sigCHLD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5280
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5281
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5282
enableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5283
    "turn on IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5284
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5285
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5286
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5287
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5288
#ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5289
    extern void __signalIoInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5290
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5291
    static int firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5292
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5293
#if (defined(F_GETFL) && defined(F_SETFL) && defined(FASYNC)) || defined(SYSV4)
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5294
    /*
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5295
     * SIGIO/SIGPOLL - data available for I/O
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5296
     * (used to wake up waiting processes)
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5297
     */
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5298
# ifdef SIGIO
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5299
#  define THESIGNAL SIGIO
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5300
# else
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5301
#  ifdef SIGPOLL
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5302
#   define THESIGNAL SIGPOLL
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5303
#  else
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5304
#   ifdef SIGURG
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5305
#    define THESIGNAL SIGURG
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5306
#   endif
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5307
#  endif
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5308
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5309
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5310
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5311
	if (firstCall) {
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5312
# ifdef HAS_SIGACTION
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5313
	    struct sigaction act;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5314
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5315
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5316
	     * Do not add SA_RESTART here. A signal can cause a
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5317
	     * thread switch, another thread can do a garbage collect
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5318
	     * and restarted system calls may write into old
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5319
	     * (collected) addresses.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5320
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5321
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5322
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5323
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5324
	    act.sa_handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5325
	    sigaction(THESIGNAL, &act, 0);
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5326
# else
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5327
#  ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5328
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5329
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5330
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5331
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5332
	    vec.sv_handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5333
	    sigvec(THESIGNAL, &vec, NULL);
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5334
#  else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5335
	    signal(THESIGNAL, __signalIoInterrupt);
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5336
#  endif /* SIGVEC */
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5337
# endif /* SIGACTION */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5338
	    firstCall = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5339
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5340
#undef THESIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5341
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5342
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5343
# if defined(SYSV4)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5344
	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
  5345
# else /*! SYSV4*/
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5346
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5347
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5348
	 * if already set, there is no need for this syscall ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5349
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5350
	if (flags & FASYNC) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5351
	    ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5352
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5353
	    ret = fcntl(f, F_SETFL, flags | FASYNC);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5354
	    if (ret >= 0) ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5355
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5356
# endif /*!SYSV4*/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5357
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5358
# if defined(F_SETOWN) || defined(FIOSETOWN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5359
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5360
	    int pid;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5361
	    int ok;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5362
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5363
	    pid = getpid();
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5364
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5365
#  if defined(F_SETOWN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5366
	    ok = fcntl(f, F_SETOWN, pid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5367
	    /* printf("F_SETOWN returns %d (%d)\n", ret, errno); */
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5368
#  else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5369
	    ok = ioctl(f, FIOSETOWN, &pid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5370
	    /* printf("FIOSETOWN returns %d (%d)\n", ret, errno); */
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5371
#  endif
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5372
	    if (ok < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5373
		ret = ok;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5374
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5375
	}
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5376
# endif
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5377
	RETURN ( __MKUINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5378
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5379
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5380
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5381
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5382
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5383
     or if the system does not support SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5384
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5385
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5386
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5387
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5388
enableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5389
    "enable (Unix-)signal processing for signalNumber.
15234
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5390
     Don't confuse Unix signals with smalltalk signals.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5391
     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
  5392
     (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
  5393
     sends #signalInterrupt:.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5394
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5395
     NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5396
     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
  5397
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5398
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5399
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5401
#ifdef NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5402
# define SIG_LIMIT NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5403
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5404
# ifdef SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5405
#  define SIG_LIMIT SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5406
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5407
#  ifdef SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5408
#   define SIG_LIMIT SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5409
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5410
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5411
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5412
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5413
#if defined(SIGPOLL) && !defined(SIGIO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5414
# define SIGIO SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5415
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5416
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5417
#ifdef SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5418
# define CHILD_SIGNAL   SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5419
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5420
# ifdef SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5421
#  define CHILD_SIGNAL  SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5422
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5423
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5424
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5425
    int sigNr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5426
#if defined(SIGINT) || defined(SIGQUIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5427
# ifndef __signalUserInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5428
    extern void __signalUserInterrupt(SIGHANDLER_ARG);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5431
#ifdef SIGFPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5432
# ifndef __signalFpExceptionInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5433
    extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5434
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5435
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5436
#ifdef SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5437
# ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5438
    extern void __signalIoInterrupt(SIGHANDLER_ARG);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5441
#ifdef CHILD_SIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5442
# ifndef __signalChildInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5443
    extern void __signalChildInterrupt(SIGHANDLER_ARG);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5446
#ifdef SIGPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5447
# ifndef __signalPIPEInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5448
    extern void __signalPIPEInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5449
# endif
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5452
# ifndef __signalBUSInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5453
    extern void __signalBUSInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5454
# endif
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5457
# ifndef __signalSEGVInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5458
    extern void __signalSEGVInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5459
# endif
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
#if defined(SIGILL) || defined(SIGEMT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5462
# ifndef __signalTrapInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5463
    extern void __signalTrapInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5464
# endif
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 SIGALRM
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
  5467
# ifndef __signalTimerInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5468
    extern void __signalTimerInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5469
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5470
#endif
15234
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5471
#ifdef SIGABRT
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5472
# ifndef __signalAbortInterrupt
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5473
    extern void __signalAbortInterrupt(SIGHANDLER_ARG);
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5474
# endif
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5475
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5476
#ifndef __signalInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5477
    extern void __signalInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5478
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5479
    void (*handler)(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5480
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5481
    if (__isSmallInteger(signalNumber)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5482
     && ((sigNr = __intVal(signalNumber)) >= 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5483
#ifdef SIG_LIMIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5484
     &&  (sigNr <= SIG_LIMIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5485
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5486
    ) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5487
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5488
	 * standard signals are forced into standard handlers
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5489
	 * - all others go into general signalInterrupt
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5490
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5491
#if defined(SIGPOLL) && defined(SIGIO)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5492
	if (sigNr == SIGPOLL)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5493
	    sigNr = SIGIO;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5494
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5495
	switch (sigNr) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5496
	    case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5497
		/* enabling a non-supported signal */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5498
		RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5499
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5500
#ifdef SIGBREAK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5501
	    case SIGBREAK:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5502
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5503
#ifdef SIGINT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5504
	    case SIGINT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5505
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5506
#ifdef SIGQUIT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5507
	    case SIGQUIT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5508
#endif
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  5509
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5510
		handler = __signalUserInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5511
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5512
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5513
#ifdef SIGFPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5514
	    case SIGFPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5515
		handler = __signalFpExceptionInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5516
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5517
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5518
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5519
#ifdef SIGPIPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5520
	    case SIGPIPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5521
		handler = __signalPIPEInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5522
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5523
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5524
#ifdef SIGBUS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5525
	    case SIGBUS:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5526
		handler = __signalBUSInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5527
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5528
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5529
#ifdef SIGSEGV
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5530
	    case SIGSEGV:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5531
		handler = __signalSEGVInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5532
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5533
#endif
15234
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5534
#ifdef SIGABRT
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5535
	    case SIGABRT:
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5536
		handler = __signalAbortInterrupt;
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5537
		break;
7ff81418f7b3 allow setting a SIGABRT handler
Claus Gittinger <cg@exept.de>
parents: 15211
diff changeset
  5538
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5539
#ifdef SIGILL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5540
	    case SIGILL:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5541
		handler = __signalTrapInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5542
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5543
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5544
#ifdef SIGEMT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5545
	    case SIGEMT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5546
		handler = __signalTrapInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5547
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5548
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5549
#ifdef SIGIO
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5550
	    case SIGIO:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5551
		handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5552
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5553
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5554
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5555
#ifdef CHILD_SIGNAL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5556
	    case CHILD_SIGNAL:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5557
		handler = __signalChildInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5558
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5559
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5560
#ifdef SIGALRM
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5561
	    case SIGALRM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5562
		handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5563
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5564
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5565
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5566
	    default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5567
		handler = __signalInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5568
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5569
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5570
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5571
	{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5572
#ifdef HAS_SIGACTION
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5573
	    struct sigaction act;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5574
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5575
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5576
	     * Do not add SA_RESTART here. A signal can cause a
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5577
	     * thread switch, another thread can do a garbage collect
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5578
	     * and restarted system calls may write into old
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5579
	     * (collected) addresses.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5580
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5581
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5582
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5583
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5584
	    act.sa_handler = handler;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5585
	    sigaction(sigNr, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5586
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5587
# ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5588
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5589
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5590
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5591
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5592
	    vec.sv_handler = handler;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5593
	    sigvec(sigNr, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5594
# else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5595
	    (void) signal(sigNr, handler);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5596
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5597
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5598
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5599
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5600
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5601
	 * maybe, we should ret the old enable-status
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5602
	 * as boolean here ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5603
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5604
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5605
    }
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
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5609
     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
  5610
     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
  5611
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5612
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5613
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5614
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5615
enableTimer:milliSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5616
    "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
  5617
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5618
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5619
    int millis;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5620
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5621
    millis = __intVal(milliSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5622
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5623
#ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5624
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5625
	static int firstCall = 1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5626
# ifndef __signalTimerInterrupt
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5627
	extern void __signalTimerInterrupt(SIGHANDLER_ARG);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5628
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5629
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5630
	if (firstCall) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5631
# ifdef HAS_SIGACTION
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5632
	    struct sigaction act;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5633
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5634
	    act.sa_flags = SA_SIGINFO; /* <- if you add more, remember dummys at the top */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5635
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5636
	    act.sa_handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5637
	    sigaction(SIGALRM, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5638
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5639
#  ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5640
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5641
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5642
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5643
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5644
	    vec.sv_handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5645
	    sigvec(SIGALRM, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5646
#  else /* neither SIGACTION nor SIGVEC */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5647
	    signal(SIGALRM, __signalTimerInterrupt);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5648
#  endif /* stupid system  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5649
# endif
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5650
	    firstCall = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5651
	}
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
#endif /* SIGALRM */
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5656
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5657
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5658
	struct itimerval dt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5659
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5660
	dt.it_interval.tv_sec = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5661
	dt.it_interval.tv_usec = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5662
	dt.it_value.tv_sec = millis / 1000;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5663
	dt.it_value.tv_usec = (millis % 1000) * 1000;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5664
	setitimer(ITIMER_REAL, &dt, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5665
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5666
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5667
#else /* no ITIMER_REAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5668
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5669
# ifdef USE_SLOW_ALARM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5670
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5671
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5672
	 * last fallback - use alarm (which only gives 1 second resolution).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5673
	 * If the system does not support any of the above, you have to life
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5674
	 * with this. The consequence is that pressing CTRL-C processing and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5675
	 * thread switching will take place much delayed.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5676
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5677
	alarm(1);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5678
	RETURN(true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5679
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5680
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5681
#endif /* ITIMER_REAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5682
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5683
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5684
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5685
6536
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5686
isFatalSignal:aNumber
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5687
   "return true if a signal with number aNumber is a fatal signal,
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5688
    i.e. some severe internal error occured"
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5689
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5690
   ^ (aNumber == self sigSEGV)
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5691
     or:[aNumber == self sigILL
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5692
     or:[aNumber == self sigBUS]]
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5693
!
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5694
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5695
killProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5696
    "kill a unix process.
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5697
     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
  5698
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5699
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5700
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5701
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5702
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5703
    self sendSignal:(self sigKILL) to:processId.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5704
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5705
    "Modified: / 10.6.1998 / 11:59:12 / cg"
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5706
!
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5707
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5708
killProcessGroup:processGroupId
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5709
    "kill a unix process group.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5710
     The process has a no chance to do some cleanup.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5711
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5712
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5713
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5714
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5715
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5716
    self sendSignal:(self sigKILL) to:(processGroupId negated).
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5717
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5718
    "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
  5719
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5720
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5721
sendSignal:signalNumber to:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5722
    "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
  5723
     Returns false if any error occurred, true otherwise.
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
     Do not confuse UNIX signals with Smalltalk-Signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5726
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5727
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5728
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5729
	      OperatingSystem>>getStatusOfProcess:aProcessId
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5730
	      if the signal terminates that process."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5731
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5732
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5733
    if (__bothSmallInteger(signalNumber, processId)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5734
	if (kill(__intVal(processId), __intVal(signalNumber)) < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5735
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5736
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5737
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5738
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5739
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5740
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5741
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5742
    "/ either invalid argument (non-integers)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5743
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5744
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5745
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5746
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5747
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5748
startSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5749
    "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
  5750
     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
  5751
     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
  5752
     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
  5753
     (which is of course less correct).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5754
     OBSOLETE: the new messageTally runs as a high prio process, not using
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5755
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5756
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5757
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5758
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5759
#ifndef __spyInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5760
    extern void __spyInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5761
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5762
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5763
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5764
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5765
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5766
# ifdef SIGVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5767
    signal(SIGVTALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5768
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5769
#  ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5770
    signal(SIGALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5771
#  else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5772
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5773
     * mhmh - system has neither SIGBTALRM nor SIGALRM ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5774
     * what should we do here ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5775
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5776
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5777
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5778
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5779
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5780
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5781
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5782
    dt.it_value.tv_usec = 1000;   /* 1000 Hz */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5783
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5784
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5785
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5786
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5787
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5788
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5789
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5790
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5791
stopSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5792
    "stop spy timing - disable spy timer.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5793
     OBSOLETE: the new messageTally runs as a high prio process, not using
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5794
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5795
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5796
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5797
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5798
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5799
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5800
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5801
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5802
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5803
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5804
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5805
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5806
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5807
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5808
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5809
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5810
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5811
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5812
terminateProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5813
    "terminate a unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5814
     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
  5815
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5816
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5817
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5818
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5819
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  5820
    self sendSignal:(self sigTERM) to:processId.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5821
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5822
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5823
    "Modified: / 27.1.1998 / 20:05:47 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5824
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5825
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5826
terminateProcessGroup:processGroupId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5827
    "terminate a unix process group.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5828
     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
  5829
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5830
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5831
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5832
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5833
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  5834
    self sendSignal:(self sigTERM) to:(processGroupId negated).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5835
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5836
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5837
    "Created: / 23.4.1996 / 16:40:34 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5838
    "Modified: / 27.1.1998 / 20:05:59 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5839
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5840
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5841
!UnixOperatingSystem class methodsFor:'ipc support'!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5842
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5843
makeBidirectionalPipe
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5844
    "make a socketPair, return array with two filedescriptors on success,
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5845
     nil on failure.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5846
     This is a lowLevel entry, not for public use."
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5847
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5848
    |fd1 fd2|
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5849
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5850
%{
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5851
#ifndef NO_SOCKET
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5852
     int fds[2];
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5853
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5854
     if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  5855
	@global(LastErrorNumber) = __mkSmallInteger(errno);
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  5856
	RETURN ( nil );
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5857
     }
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5858
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5859
     fd1 = __mkSmallInteger(fds[0]);
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5860
     fd2 = __mkSmallInteger(fds[1]);
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5861
#endif
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5862
%}.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5863
    fd1 notNil ifTrue:[
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  5864
	^ Array with:fd1 with:fd2.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5865
    ].
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5866
    ^ nil
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5867
!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5868
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  5869
makePTY
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  5870
    "make a pty-pair, return a triple with two filedescriptors and the pty's name
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  5871
     on success, nil on failure.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5872
     This is a lowLevel entry, not for public use.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5873
     See NonPositionableExternalStream>>makePTYPair for a more user-friendly,
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5874
     public interface."
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5875
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  5876
    |fdS fdM ptyName|
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5877
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5878
%{
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5879
    /*
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5880
     * Find a pseudo tty to use and open both sides.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5881
     *  _fdM receives the master file descriptor while _fdS
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  5882
     *  receives the slave.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5883
     */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5884
3536
adad0d12c9a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3534
diff changeset
  5885
#ifdef IRIX5
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5886
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5887
    char *slaveName;
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5888
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5889
    slaveName = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0);
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5890
    if ((slaveName != 0) && (_fdM >= 0)) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5891
	_fdS = open(slaveName, O_RDWR);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5892
	if (_fdS < 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5893
	    (void)close(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5894
	    _fdS = _fdM = -1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5895
	}
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5896
    } else {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5897
	_fdM -1;
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5898
    }
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5899
    if ((_fdM >= 0) && (_fdS >= 0)) {
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  5900
	fdM = __mkSmallInteger(_fdM);
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  5901
	fdS = __mkSmallInteger(_fdS);
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  5902
	ptyName = __MKSTRING(slaveName);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5903
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5904
#   define PTY_IS_IMPLEMENTED 1
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5905
#endif /* IRIX5 */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5906
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5907
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  5908
#if defined(HAS_UNIX98_PTY)
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5909
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  5910
    char *slaveName;
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5911
    extern char *ptsname();     /* also in #include <stdlib.h> */
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5912
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  5913
    _fdM = open("/dev/ptmx", O_RDWR | O_NOCTTY);
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5914
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5915
    if (_fdM >= 0) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5916
	/*
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5917
	** grantpt() changes owner, group and mode of the pseudo-tty
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5918
	*/
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5919
	grantpt(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5920
	unlockpt(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5921
	slaveName = ptsname(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5922
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5923
	if (slaveName != NULL) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5924
	    /* printf("slave is: %s\n", slaveName); */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5925
	    _fdS = open(slaveName, O_RDWR);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5926
	    if (_fdS < 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5927
		(void)close(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5928
		_fdS = _fdM = -1;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5929
	    }
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  5930
#if defined(UNIXWARE) || defined(solaris)
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5931
	    else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5932
		/* push terminal modules on stream */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5933
		ioctl(_fdS, I_PUSH, "ptem");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5934
		ioctl(_fdS, I_PUSH, "ldterm");
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5935
	    }
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5936
#endif
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5937
	} else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5938
	    (void)close(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5939
	    _fdS = _fdM = -1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  5940
	}
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5941
    }
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5942
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  5943
    if ((_fdM >= 0) && (_fdS >= 0)) {
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  5944
	fdM = __mkSmallInteger(_fdM);
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  5945
	fdS = __mkSmallInteger(_fdS);
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  5946
	ptyName = __MKSTRING(slaveName);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5947
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5948
#   define PTY_IS_IMPLEMENTED 1
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  5949
#endif /* HAS_UNIX98_PTY */
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5950
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5951
#if !defined(PTY_IS_IMPLEMENTED)
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5952
# ifdef LINUX
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5953
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5954
#   define PT_INDEX      5
3550
6c3824d07eac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  5955
#   define PTY_1_CHARS  "pqrstuabcdevwxyz"
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5956
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5957
# endif /* LINUX */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5958
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5959
# ifdef solaris
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5960
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5961
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5962
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5963
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5964
# endif /* solaris */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5965
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5966
# ifdef aix
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5967
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5968
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5969
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5970
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5971
# endif /* aix */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5972
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5973
# ifdef next3
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5974
#   define PTY_TEMPL    "/dev/ptyXX"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5975
#   define PT_INDEX      5
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5976
#   define PTY_1_CHARS  "pqr"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5977
#   define PTY_2_CHARS  "0123456789abcdef"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5978
# endif /* next3 */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5979
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5980
# ifdef hpux
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5981
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5982
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5983
#   define PTY_1_CHARS  "pqrs"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5984
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5985
# endif /* hpux */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5986
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5987
# if defined(__osf__)
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5988
#   define PTY_TEMPL    "/dev/ptyXX"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5989
#   define PT_INDEX      5
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5990
#   define PTY_1_CHARS  "pq"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  5991
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5992
# endif /* osf1 */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5993
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5994
# if defined(BSD) && !defined(PTY_TEMPL)
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5995
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  5996
#   define PT_INDEX      5
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5997
#   define PTY_1_CHARS  "p"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  5998
#   define PTY_2_CHARS  "0123456789abcdefghijklmnopqrstuv"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  5999
# endif /* BSD */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6000
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6001
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6002
#   include <grp.h>
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6003
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6004
    static int ttygid = -2;
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6005
    char line[128];
3575
39723f691a0e hp-cc does not recognize const keyword
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
  6006
    register CONST char *cp1, *cp2;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6007
    int len, _fdM = -1, _fdS = -1;
15484
840d6cc94534 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 15483
diff changeset
  6008
    char *slaveName = NULL;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6009
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6010
    len = sizeof(PTY_TEMPL) - 1;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6011
    strncpy(line, PTY_TEMPL, sizeof(PTY_TEMPL));
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6012
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6013
    if (ttygid == -2) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6014
	struct group *gr;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6015
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6016
	if ((gr = getgrnam("tty")) != NULL)
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6017
	    ttygid = gr->gr_gid;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6018
	else
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6019
	    ttygid = -1;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6020
    }
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6021
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6022
    for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6023
	line[len-2] = * cp1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6024
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6025
	for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6026
	    line[PT_INDEX] = 'p';
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6027
	    line[len-1] = *cp2;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6028
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6029
	    if ((_fdM = open(line, O_RDWR, 0)) < 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6030
		if (errno == ENOENT) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6031
		    _fdM = _fdS = -1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6032
		    goto getOutOfHere; /* out of ptys */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6033
		}
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6034
	    } else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6035
		line[PT_INDEX] = 't';
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6036
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6037
		/*
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6038
		 * try to set owner and mode.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6039
		 * this works only if running under root
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6040
		 */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6041
		(void) chown( line, getuid(), ttygid );
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6042
		(void) chmod( line, S_IRUSR | S_IWUSR | S_IWGRP );
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6043
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6044
		if( (_fdS = open(line, O_RDWR, 0)) >= 0 ) {
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6045
		    slaveName = line;
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6046
		    goto getOutOfHere; /* success */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6047
		}
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6048
		(void) close(_fdM );
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6049
	    }
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6050
	}
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6051
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6052
  getOutOfHere: ;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6053
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6054
    if ((_fdM >= 0) && (_fdS >= 0)) {
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6055
	fdM = __mkSmallInteger(_fdM);
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6056
	fdS = __mkSmallInteger(_fdS);
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6057
	ptyName = __MKSTRING(slaveName);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6058
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6059
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6060
#endif /* ! defined(PTY_IS_IMPLEMENTED) */
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6061
%}.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6062
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6063
    fdM notNil ifTrue:[
15481
6595109cb9e2 added makePTY, which also provides the name of the pty
Claus Gittinger <cg@exept.de>
parents: 15312
diff changeset
  6064
	^ Array with:fdM with:fdS with:ptyName.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6065
    ].
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6066
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6067
    ^ nil
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6068
!
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6069
15492
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6070
makePTYPair
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6071
    "make a pty-pair, return an array with two filedescriptors on success,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6072
     nil on failure.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6073
     This is a leftover compatibility lowLevel entry, not for public use.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6074
     See NonPositionableExternalStream>>makePTYPair for a more user-friendly,
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6075
     public interface."
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6076
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6077
    |triple|
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6078
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6079
    triple := self makePTY.
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6080
    triple isNil ifTrue:[^ nil].
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6081
    ^ Array with:(triple at:1) with:(triple at:2)
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6082
!
626feb0ef3a5 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15484
diff changeset
  6083
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6084
makePipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6085
    "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
  6086
     nil on failure.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6087
     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
  6088
     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
  6089
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6090
    |fd1 fd2|
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6091
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6092
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6093
     int fds[2];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6094
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6095
     if (pipe(fds) < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6096
	@global(LastErrorNumber) = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6097
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6098
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6099
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6100
     fd1 = __mkSmallInteger(fds[0]);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6101
     fd2 = __mkSmallInteger(fds[1]);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6102
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6103
    fd1 notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6104
	^ Array with:fd1 with:fd2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6105
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6106
    ^ nil
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6107
!
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6108
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6109
resetTerminalInputOutputModes:fd
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6110
    "reset the terminal attributes"
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6111
%{
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6112
    struct termios switcher;
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6113
15176
aae943ef2519 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 15175
diff changeset
  6114
    printf("setMappingMaster fd:%d\n", (int)__intVal(fd));
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6115
    if (__isSmallInteger(fd)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6116
	if (tcgetattr( __intVal(fd), &switcher) < 0) RETURN (false);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6117
	switcher.c_iflag = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6118
	switcher.c_oflag = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6119
	if (tcsetattr( __intVal(fd), TCSANOW, &switcher) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6120
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6121
	}
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6122
    }
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6123
%}.
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6124
    ^ false
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6125
!
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6126
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6127
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
  6128
    "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
  6129
%{
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6130
#ifdef TIOCSWINSZ
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6131
    struct winsize wsize;
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6132
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6133
    if (__isSmallInteger(fd)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6134
     && __isSmallInteger(w)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6135
     && __isSmallInteger(h)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6136
	wsize.ws_row = (unsigned short)__intVal(h);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6137
	wsize.ws_col = (unsigned short)__intVal(w);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6138
	if (ioctl(__intVal(fd), TIOCSWINSZ, (char *)&wsize) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6139
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6140
	}
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6141
    }
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6142
#endif
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6143
%}.
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6144
    ^ false
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6145
!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6146
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6147
shutdownBidirectionalPipeOutput:fileDescriptor
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6148
    "inform the other end of the bidirectional pipe represented by fileDescriptor, that
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6149
     we will send no more data to the pipe, i.e. EOF is reached"
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6150
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6151
%{
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6152
#ifndef NO_SOCKET
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6153
    if (__isSmallInteger(fileDescriptor)) {
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  6154
	shutdown(__smallIntegerVal(fileDescriptor), 1);
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  6155
	RETURN(self);
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6156
    }
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6157
#endif
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6158
%}.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6159
    self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6160
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6161
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6162
!UnixOperatingSystem class methodsFor:'misc'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6163
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6164
closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6165
    "a bad bad kludge and workaround for a big bug in the linux
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6166
     getAddrInfo implementation:
15157
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6167
        if it gets interrupted (via a timer, for example), its domain-name
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6168
        socket remains open and is NEVER closed.
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6169
        These open files collect up and lead to no-more-files eventually.
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6170
     Invoking this method helps in this situation."
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6171
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6172
    |p|
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6173
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6174
    p := PipeStream
15157
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6175
            readingFrom:('lsof -p ' , (OperatingSystem getProcessId printString)).
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6176
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6177
    p linesDo:[:line |
15157
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6178
        |words fd|
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6179
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6180
        words := line asCollectionOfWords.
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6181
        "/ COMMAND PID USER   FD   TYPE     DEVICE    SIZE    NODE NAME
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6182
        words first = 'stx' ifTrue:[
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6183
            words second = (OperatingSystem getProcessId printString) ifTrue:[
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6184
                (words fourth endsWith:'u') ifTrue:[
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6185
                    (words fifth = 'IPv4') ifTrue:[
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6186
                        (words seventh = 'UDP') ifTrue:[
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6187
                            (words last endsWith:'domain') ifTrue:[
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6188
                                fd := Number readFrom:(words fourth copyButLast:1).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6189
Transcript showCR:line.
15157
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6190
                                OperatingSystem closeFd:fd.
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6191
                            ]
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6192
                        ]
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6193
                    ]
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6194
                ]
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6195
            ]
a04922c5376b class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15155
diff changeset
  6196
        ]
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6197
    ].
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6198
    p close.
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6199
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6200
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6201
     self closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6202
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6203
!
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6204
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6205
closePid:pid
7133
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  6206
    "free pid resource.
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  6207
     Not required for Unix, but Windoze requires it."
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6208
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6209
    ^ true.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6210
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6211
    "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
  6212
    "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
  6213
    "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
  6214
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6215
10983
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6216
dup:aFileDescriptor
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6217
    "duplicate a file descriptor.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6218
     Only use internally"
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6219
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6220
%{
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6221
    int dupFd;
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6222
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6223
    if (__isSmallInteger(aFileDescriptor)) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6224
	dupFd = dup(__smallIntegerVal(aFileDescriptor));
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6225
	if (dupFd >= 0) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6226
	    RETURN(__mkSmallInteger(dupFd));
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6227
	}
10983
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6228
    }
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6229
%}.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6230
    ^ self primitiveFailed.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6231
!
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6232
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6233
slowFork:aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6234
    "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
  6235
     Only used internally on SYSV3 systems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6236
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6237
    SlowFork := aBoolean
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
    "Modified: 22.4.1996 / 13:13:09 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6240
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6241
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6242
!UnixOperatingSystem class methodsFor:'os queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6243
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6244
executableFileExtensions
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6245
    "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
  6246
     Only req'd for msdos like systems ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6247
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6248
    ^ #('')
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6249
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6250
    "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
  6251
    "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
  6252
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6253
14590
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
  6254
getCodeset
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  6255
    "get the codeset the system is running under"
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  6256
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  6257
    ^ Codeset
14587
d32cbeb8ca41 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14584
diff changeset
  6258
!
d32cbeb8ca41 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14584
diff changeset
  6259
18015
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6260
getCodesetEncoder
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6261
    "Initialize CodesetEncoder used to encode/decode strings passed to/from
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6262
     the operating system (like file names, command output, environment ect.).
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6263
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6264
     NOTE: DO NOT CALL this in #initialize as CharacterEncoder might not yet 
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6265
     be initialized. Therefore this method is called from CharacterEncoder class>>
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6266
     #initialize. Certainly a hack, but class initialization order is undefined,
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6267
     so some sort of hack is necessary.
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6268
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6269
     NOTE2: This should be called initializeCodesetEncoder but to make it consistent
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6270
     with getCodeset it is getCodesetEncoder
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6271
     "
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6272
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6273
    Codeset isNil ifTrue:[self getCodeset].
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6274
    CodesetEncoder := CharacterEncoder encoderFor: Codeset.
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6275
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6276
    "Created: / 23-01-2013 / 09:54:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6277
!
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  6278
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6279
getDomainName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6280
    "return the domain this host is in.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6281
     Notice:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6282
	not all systems support this; on some, #unknown is returned."
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6283
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6284
    |domainName idx hostName|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6285
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6286
    DomainName notNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6287
	^ DomainName
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6288
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6289
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6290
    domainName := self primGetDomainName.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6291
    domainName isEmptyOrNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6292
	"sometimes, we can extract the domainName from the hostName ..."
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6293
	hostName := self primGetHostName.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6294
	hostName notNil ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6295
	    idx := hostName indexOf:$..
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6296
	    idx ~~ 0 ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6297
		domainName := hostName copyFrom:idx+1.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6298
	    ]
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6299
	].
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6300
	domainName isNil ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6301
	    "/ fallBack
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6302
	    domainName := self getEnvironment:'DOMAIN'.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6303
	    domainName isNil ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6304
		domainName := self getCommandOutputFrom:'/bin/domainname'
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6305
	    ].
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6306
	    domainName isNil ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6307
		'UnixOperatingSystem [warning]: cannot find out domainname' errorPrintCR.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6308
		domainName := #unknown.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6309
	    ].
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6310
	    "cache only, if domain name fetching is expensive"
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6311
	    DomainName := domainName.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6312
	].
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6313
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6314
    ^ domainName
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6317
     OperatingSystem getDomainName
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6318
     OperatingSystem getHostName
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6319
     OperatingSystem primGetHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6320
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6321
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6322
    "Modified: 26.4.1996 / 10:04:54 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6323
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6324
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6325
getEnvironment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6326
    "answer the whole environment as a Dictionary"
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6327
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6328
    |resultArray error dict sz "{ Class: SmallInteger }"|
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6329
14799
756f1c78a9df *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14707
diff changeset
  6330
%{
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  6331
#ifdef __osx__
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  6332
    char **environ = _NSGetEnviron();
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  6333
#else
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6334
    extern char **environ;
14694
7583652011e2 a shared lib cannot access environ in OSX
Claus Gittinger <cg@exept.de>
parents: 14667
diff changeset
  6335
#endif
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6336
    char **env;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6337
    int nEnv = 0;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6338
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6339
    /*
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6340
     * get the size of the environment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6341
     */
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6342
    if (environ) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6343
	for (env = environ; *env; env++) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6344
	    nEnv++;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6345
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6346
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6347
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6348
    /*
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6349
     * allcate an array for keys and values
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6350
     */
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  6351
    resultArray = __ARRAY_NEW_INT(nEnv * 2);
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6352
    if (resultArray == nil) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6353
	error = @symbol(allocationFailure);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6354
	goto bad;
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6355
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6356
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6357
    if (environ) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6358
	int envIndex;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6359
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6360
	for (env = environ, envIndex = 0; *env; env++) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6361
	    OBJ t;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6362
	    char *separatorPtr;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6363
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6364
	    separatorPtr = strchr(*env, '=');
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6365
	    t = __MKSTRING_L(*env, separatorPtr-*env);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6366
	    __arrayVal(resultArray)[envIndex++] = t;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6367
	    __STORE(resultArray, t);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6368
	    if (separatorPtr == 0) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6369
		t = nil;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6370
	    } else {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6371
		t = __MKSTRING(separatorPtr+1);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6372
	    }
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6373
	    __arrayVal(resultArray)[envIndex++] = t;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6374
	    __STORE(resultArray, t);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6375
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6376
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6377
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6378
bad:;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6379
%}.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6380
    error notNil ifTrue:[
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6381
	^ self primitiveFailed:error.
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6382
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6383
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6384
    sz := resultArray size.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6385
    dict := Dictionary new:(sz // 2).
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6386
    1 to:sz by:2 do:[:i |
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6387
	|key|
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6388
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6389
	key := resultArray at:i.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6390
	"same behavior as getenv() - the first entry takes precedence"
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6391
	(dict includesKey:key) ifFalse:[
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6392
	    dict at:key put:(resultArray at:i+1)
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6393
	].
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6394
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6395
    ^ dict
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6396
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6397
    "
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6398
     OperatingSystem getEnvironment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6399
    "
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6400
!
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6401
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6402
getEnvironment:aStringOrSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6403
    "get an environment string"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6404
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6405
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6406
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6407
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6408
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  6409
    if (__isStringLike(aStringOrSymbol)) {
14370
66a4b9c492b9 Fixed: bad definition of MAXPATHLEN from PATH_MAX
Stefan Vogel <sv@exept.de>
parents: 13801
diff changeset
  6410
	char *env =  getenv(__stringVal(aStringOrSymbol));
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6411
	if (env) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6412
	    RETURN ( __MKSTRING(env) );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6413
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6414
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6415
    }
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6416
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  6417
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6418
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6419
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6420
     OperatingSystem getEnvironment:'LANG'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6421
     OperatingSystem getEnvironment:'LOGIN'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6422
     OperatingSystem getEnvironment:'HOME'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6423
     OperatingSystem getEnvironment:'NNTPSERVER'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6424
     OperatingSystem getEnvironment:'MAIL'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6425
     OperatingSystem getEnvironment:'PATH'
3496
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6428
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6429
getHostName
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6430
    "return the hostname we are running on.
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6431
     The host name returned is fully qualified - if returned so by the system."
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6432
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6433
    |hostName|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6434
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6435
    HostName notNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6436
	^ HostName
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6437
    ].
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6438
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6439
    hostName := self primGetHostName.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6440
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6441
    hostName isNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6442
	"fallBack - in non-antique systes we never come here"
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6443
	hostName := self getEnvironment:'HOST'.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6444
	hostName isNil ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6445
	    hostName := self getCommandOutputFrom:'/bin/hostname'
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6446
	].
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6447
	hostName isNil ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6448
	    'UnixOperatingSystem [warning]: cannot find out hostname' errorPrintCR.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6449
	    hostName := #unknown.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6450
	].
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6451
	"cache, only because hostname fetching was expensive,
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6452
	 otherwise we want to see a changed hostname"
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  6453
	HostName := hostName.
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6454
    ].
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6455
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6456
    ^ hostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6457
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6458
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6459
     OperatingSystem getHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6460
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6461
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6462
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6463
getLocaleInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6464
    "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
  6465
     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
  6466
     Possible fields are:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6467
	decimalPoint                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6468
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6469
	thousandsSep                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6470
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6471
	internationalCurrencySymbol     <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6472
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6473
	currencySymbol                  <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6474
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6475
	monetaryDecimalPoint            <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6476
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6477
	monetaryThousandsSeparator      <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6478
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6479
	positiveSign                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6480
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6481
	negativeSign                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6482
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6483
	internationalFractionalDigits   <Integer>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6484
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6485
	fractionalDigits                <Integer>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6486
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6487
	positiveSignPrecedesCurrencySymbol      <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6488
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6489
	negativeSignPrecedesCurrencySymbol      <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6490
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6491
	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6492
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6493
	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6494
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6495
	positiveSignPosition                            <Symbol>
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6496
							one of: #parenthesesAround,
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6497
								#signPrecedes,
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6498
								#signSuceeds,
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6499
								#signPrecedesCurrencySymbol,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6500
								#signSuceedsCurrencySymbol
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6501
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6502
	negativeSignPosition                            <like above>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6503
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6504
     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
  6505
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6506
     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
  6507
     it should be used by applications as required.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6508
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6509
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6510
    |info val|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6511
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6512
    LocaleInfo notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6513
	"/ return the internal info; useful on systems which do not
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6514
	"/ support this.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6515
	^ LocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6516
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6517
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6518
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6519
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6520
    char *decimalPoint;         /* something like "." (US) or "," (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6521
    char *thousandsSep;         /* something like "," (US) or "." (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6522
    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
  6523
    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
  6524
    char *monDecimalPoint;      /* money: decimal point */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6525
    char *monThousandsSep;      /* money: thousands sep */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6526
    char *positiveSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6527
    char *negativeSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6528
    int   intFractDigits;       /* money: international digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6529
    int   fractDigits;          /* money: local digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6530
    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
  6531
    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
  6532
    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
  6533
    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
  6534
    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
  6535
    int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6536
				/*        2: sign succeeds the value & currency symbol */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6537
				/*        3: sign immediately precedes the currency symbol */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6538
				/*        4: sign immediately suceeds the currency symbol */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6539
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6540
#if defined(HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6541
    struct lconv *conf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6542
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6543
    conf = localeconv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6544
    if (conf) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6545
	decimalPoint = conf->decimal_point;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6546
	thousandsSep = conf->thousands_sep;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6547
	intCurrencySymbol = conf->int_curr_symbol;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6548
	currencySymbol = conf->currency_symbol;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6549
	monDecimalPoint = conf->mon_decimal_point;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6550
	monThousandsSep = conf->mon_thousands_sep;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6551
	positiveSign = conf->positive_sign;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6552
	negativeSign = conf->negative_sign;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6553
	intFractDigits = conf->int_frac_digits;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6554
	fractDigits = conf->frac_digits;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6555
	csPosPrecedes = conf->p_cs_precedes;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6556
	csNegPrecedes = conf->n_cs_precedes;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6557
	csPosSepBySpace = conf->p_sep_by_space;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6558
	csNegSepBySpace = conf->n_sep_by_space;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6559
	csPosSignPosition = conf->p_sign_posn;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6560
	csNegSignPosition = conf->n_sign_posn;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6561
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6562
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6563
    decimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6564
    thousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6565
    intCurrencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6566
    currencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6567
    monDecimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6568
    monThousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6569
    positiveSign =  (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6570
    negativeSign =(char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6571
    intFractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6572
    fractDigits = -1;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6573
    csPosPrecedes = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6574
    csNegPrecedes = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6575
    csPosSepBySpace = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6576
    csNegSepBySpace = -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6577
    csPosSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6578
    csNegSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6579
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6580
    if (decimalPoint) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6581
	val = __MKSTRING(decimalPoint);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6582
	__AT_PUT_(info, @symbol(decimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6583
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6584
    if (thousandsSep) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6585
	val = __MKSTRING(thousandsSep);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6586
	__AT_PUT_(info, @symbol(thousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6587
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6588
    if (intCurrencySymbol) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6589
	val = __MKSTRING(intCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6590
	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6591
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6592
    if (currencySymbol) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6593
	val = __MKSTRING(currencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6594
	__AT_PUT_(info, @symbol(currencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6595
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6596
    if (monDecimalPoint) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6597
	val = __MKSTRING(monDecimalPoint);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6598
	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6599
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6600
    if (monThousandsSep) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6601
	val = __MKSTRING(monThousandsSep);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6602
	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6603
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6604
    if (positiveSign) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6605
	val = __MKSTRING(positiveSign);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6606
	__AT_PUT_(info, @symbol(positiveSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6607
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6608
    if (negativeSign) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6609
	val = __MKSTRING(negativeSign);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6610
	__AT_PUT_(info, @symbol(negativeSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6611
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6612
    if (intFractDigits >= 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6613
	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __mkSmallInteger(intFractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6614
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6615
    if (fractDigits >= 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6616
	__AT_PUT_(info, @symbol(fractionalDigits),  __mkSmallInteger(fractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6617
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6618
    if (csPosPrecedes >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6619
	if (csPosPrecedes == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6620
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6621
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6622
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6623
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6624
	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6625
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6626
    if (csNegPrecedes >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6627
	if (csNegPrecedes == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6628
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6629
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6630
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6631
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6632
	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6633
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6634
    if (csPosSepBySpace >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6635
	if (csPosSepBySpace == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6636
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6637
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6638
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6639
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6640
	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6641
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6642
    if (csNegSepBySpace >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6643
	if (csNegSepBySpace == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6644
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6645
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6646
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6647
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6648
	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6649
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6650
    switch (csPosSignPosition) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6651
	case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6652
	    val = @symbol(parenthesesAround);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6653
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6654
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6655
	case 1:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6656
	    val = @symbol(signPrecedes);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6657
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6658
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6659
	case 2:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6660
	    val = @symbol(signSuceeds);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6661
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6662
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6663
	case 3:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6664
	    val = @symbol(signPrecedesCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6665
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6666
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6667
	case 4:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6668
	    val = @symbol(signSuceedsCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6669
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6670
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6671
	default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6672
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6673
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6674
    if (val != nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6675
	__AT_PUT_(info, @symbol(positiveSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6676
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6677
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6678
    switch (csNegSignPosition) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6679
	case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6680
	    val = @symbol(parenthesesAround);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6681
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6682
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6683
	case 1:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6684
	    val = @symbol(signPrecedes);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6685
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6686
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6687
	case 2:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6688
	    val = @symbol(signSuceeds);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6689
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6690
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6691
	case 3:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6692
	    val = @symbol(signPrecedesCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6693
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6694
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6695
	case 4:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6696
	    val = @symbol(signSuceedsCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6697
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6698
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6699
	default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6700
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6701
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6702
    if (val != nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6703
	__AT_PUT_(info, @symbol(negativeSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6704
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6705
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6706
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6707
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6708
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6709
     OperatingSystem getLocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6710
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6711
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6712
    "Created: 23.12.1995 / 14:19:20 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6713
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6714
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6715
getNetworkAddressInfo
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6716
    "return a Dictionary of network interface information. 
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6717
        key -> name of interface
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6718
        value -> a Set of network address 
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6719
                information for the interface - a dictionaries containing the 
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6720
                information about the configuration of each interface in the system. 
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6721
                The dictionary keys are:
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6722
                    #address
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6723
                    #netmask
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6724
                    #flags
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6725
                    #destAddress"
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6726
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6727
    |returnArray addressArray nameArray noOfIf retDictionary error retIndex|
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6728
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6729
    noOfIf := 0.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6730
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6731
%{
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6732
#if defined(LINUX)
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6733
# include <ifaddrs.h>
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6734
# include <netinet/in.h>
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6735
# include <sys/socket.h>
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6736
# include <netpacket/packet.h>
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6737
# include <net/ethernet.h> /* the L2 protocols */
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6738
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6739
    struct ifaddrs *ifap, *ifaLoop;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6740
    int n_ifa = 0;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6741
    int retI = 0;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6742
    OBJ t;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6743
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6744
    if (getifaddrs(&ifap) < 0) {
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6745
        error = __MKSTRING("getifaddrs() failed");
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6746
        goto out;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6747
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6748
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6749
    for (ifaLoop = ifap; ifaLoop != 0; ifaLoop = ifaLoop->ifa_next) n_ifa++;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6750
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6751
    returnArray = __ARRAY_NEW_INT(n_ifa*5);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6752
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6753
    if (returnArray == nil) {
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6754
        /* Creating a string wouldn't work here */
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6755
        error = @symbol(allocationFailure);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6756
        goto bad;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6757
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6758
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6759
    for (ifaLoop = ifap; ifaLoop != 0; ifaLoop = ifaLoop->ifa_next) {
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6760
        int family, len;
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6761
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6762
        if (ifaLoop->ifa_addr == 0)
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6763
               continue;
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6764
        family = ifaLoop->ifa_addr->sa_family;
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6765
        switch (family) {
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6766
        case AF_INET:
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6767
            len = sizeof(struct sockaddr_in);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6768
            break;
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6769
        case AF_INET6:
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6770
            len = sizeof(struct sockaddr_in6);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6771
            break;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6772
#if 0
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6773
        case AF_PACKET:
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6774
            len = sizeof(sockaddr_ll);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6775
            break;
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6776
#endif
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6777
        default:
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6778
            /* skip */
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6779
            continue;
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6780
        };
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6781
        t = __MKSTRING(ifaLoop->ifa_name);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6782
        __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6783
        t = __MKUINT(ifaLoop->ifa_flags);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6784
        __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6785
        t = __MKBYTEARRAY((char *)ifaLoop->ifa_addr, len);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6786
        __arrayVal(returnArray)[retI++] = t; __STORE(returnArray, t);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6787
        if (ifaLoop->ifa_netmask != 0) {
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6788
            t = __MKBYTEARRAY((char *)ifaLoop->ifa_netmask, len);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6789
            __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6790
        }
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6791
        retI++;
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6792
        if (ifaLoop->ifa_dstaddr != 0) {
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6793
            t = __MKBYTEARRAY((char *)ifaLoop->ifa_dstaddr, len);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6794
            __arrayVal(returnArray)[retI] = t; __STORE(returnArray, t);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6795
        }
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6796
        retI++;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6797
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6798
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6799
    noOfIf = __mkSmallInteger(n_ifa);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6800
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6801
bad:
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6802
    freeifaddrs(ifap);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6803
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6804
#elif !defined(__osx__) && defined(SIOCGIFADDR) && defined(SIOCGIFCONF)
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6805
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6806
    int             afinet_socket = -1;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6807
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6808
    struct ifconf   ifc;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6809
    struct ifreq    *ifr;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6810
    struct ifreq    ifreq;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6811
    unsigned char   buf[1024];
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6812
    int             n_ifs, i, countOfIf;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6813
    OBJ             t;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6814
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6815
    /*
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6816
    ** Open an INET socket
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6817
    */
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6818
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6819
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6820
    if (afinet_socket < 0) {
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6821
        goto bad;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6822
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6823
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6824
    /*
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6825
    ** Get the list of network interfaces
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6826
    */
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6827
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6828
    ifc.ifc_len = sizeof (buf);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6829
    ifc.ifc_buf = (caddr_t) buf;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6830
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6831
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6832
        close(afinet_socket);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6833
        error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6834
        goto bad;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6835
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6836
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6837
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6838
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6839
    nameArray    = __ARRAY_NEW_INT(n_ifs);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6840
    addressArray = __ARRAY_NEW_INT(n_ifs);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6841
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6842
    if (nameArray == nil || addressArray == nil) {
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6843
        /* Creating a string wouldn/t work here */
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6844
        error = @symbol(allocationFailure);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6845
        goto bad;
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6846
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6847
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6848
    /*
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6849
    ** Iterate of the list of the system's netif. Find all
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6850
    ** active interfaces and their ethernet addresses
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6851
    */
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6852
    countOfIf = 0;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6853
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6854
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6855
        /*
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6856
        ** Get address for this interface
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6857
        */
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6858
        memset (&ifreq, 0, sizeof(ifreq));
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6859
        memcpy (ifreq.ifr_name, ifr->ifr_name, sizeof(ifr->ifr_name));
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6860
        if (ioctl (afinet_socket, SIOCGIFADDR, &ifreq) >= 0) {
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6861
            t = __MKBYTEARRAY((char *)&ifreq.ifr_addr, sizeof(ifreq.ifr_addr));
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6862
            __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6863
            t = __MKSTRING(&ifreq.ifr_name);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6864
            __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6865
            countOfIf++;
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6866
        } else {
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6867
            fprintf(stderr, "SIOCGIFADDR failed: %s\n", errno);
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6868
        }
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6869
        error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6870
    }
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6871
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6872
    noOfIf = __mkSmallInteger(countOfIf);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6873
bad:
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6874
    if (afinet_socket >= 0)
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6875
        close(afinet_socket);
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6876
#else
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6877
    error = @symbol(notSupported);
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6878
#endif /* defined(SIOCGIFADDR) */
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6879
out:;
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6880
%}.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6881
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6882
    retDictionary := Dictionary new:noOfIf.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6883
    error notNil ifTrue:[
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6884
        self primitiveFailed:error.
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6885
        "return empty dictionary if proceeding from error"
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6886
        ^  retDictionary.
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6887
    ].
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6888
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6889
    retIndex := 1.
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6890
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6891
    1 to:noOfIf do:[:cnt|
15508
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6892
        |name addressBytes set dict|
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6893
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6894
        name := returnArray at:retIndex.
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6895
        addressBytes := returnArray at:retIndex+2.
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6896
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6897
        addressBytes notNil ifTrue:[
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6898
            set := retDictionary at:name ifAbsentPut:[Set new].
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6899
            dict := Dictionary new:5.
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6900
            dict at:#flags put:(returnArray at:retIndex+1).
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6901
            dict at:#address put:(SocketAddress fromBytes:addressBytes).
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6902
            addressBytes := returnArray at:retIndex+3.
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6903
            addressBytes notNil ifTrue:[
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6904
                dict at:#netMask put:(SocketAddress fromBytes:addressBytes).
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6905
            ].
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6906
            addressBytes := returnArray at:retIndex+4.
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6907
            addressBytes notNil ifTrue:[
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6908
                dict at:#destAddress put:(SocketAddress fromBytes:addressBytes).
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6909
            ].
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6910
            set add:dict.
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6911
        ].
38541f2887de class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15492
diff changeset
  6912
        retIndex := retIndex + 5.
13365
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6913
    ].
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6914
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6915
    ^ retDictionary
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6916
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6917
    "
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6918
      OperatingSystem getNetworkAddressInfo
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6919
    "
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6920
!
352699e52383 added: #getNetworkAddressInfo
Stefan Vogel <sv@exept.de>
parents: 13110
diff changeset
  6921
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6922
getNetworkAddresses
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6923
    "return a dictionary filled with
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6924
	key -> name of interface
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6925
	value -> the socket adress of the interface
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6926
     for each interface"
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6927
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6928
    |addressArray nameArray noOfIf retDictionary error|
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6929
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6930
    noOfIf := 0.
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6931
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6932
%{
10787
6bce0b8c7e4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10662
diff changeset
  6933
#if !defined(__osx__) && defined(SIOCGIFADDR) && defined(SIOCGIFCONF)
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6934
    int             afinet_socket = -1;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6935
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6936
    struct ifconf   ifc;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6937
    struct ifreq    *ifr;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6938
    struct ifreq    ifreq;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6939
    unsigned char   buf[1024];
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6940
    int             n_ifs, i, countOfIf;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6941
    OBJ             t;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6942
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6943
    /*
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6944
    ** Open an INET socket
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6945
    */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6946
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6947
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6948
    if (afinet_socket < 0) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6949
	error = __MKSTRING("Cannot open socket");
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6950
	goto bad;
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6951
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6952
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6953
    /*
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6954
    ** Get the list of network interfaces
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6955
    */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6956
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6957
    ifc.ifc_len = sizeof (buf);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6958
    ifc.ifc_buf = (caddr_t) buf;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6959
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6960
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6961
	close(afinet_socket);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6962
	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6963
	goto bad;
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6964
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6965
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6966
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6967
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  6968
    nameArray    = __ARRAY_NEW_INT(n_ifs);
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  6969
    addressArray = __ARRAY_NEW_INT(n_ifs);
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6970
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6971
    if (nameArray == nil || addressArray == nil) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6972
	/* Creating a string wouldn/t work here */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6973
	error = @symbol(allocationFailure);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6974
	goto bad;
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6975
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6976
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6977
    /*
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6978
    ** Iterate of the list of the system's netif. Find all
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6979
    ** active interfaces and their ethernet addresses
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6980
    */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6981
    countOfIf = 0;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6982
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6983
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6984
	/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6985
	** Get Flags for this interface
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6986
	*/
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6987
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6988
	memcpy(&ifreq, ifr, sizeof(ifreq));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6989
	/*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6990
	** Get address for this interface
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6991
	*/
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6992
	memcpy(&ifreq, ifr, sizeof(ifreq));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6993
	if (ioctl (afinet_socket, SIOCGIFADDR, &ifreq) >= 0) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6994
	    t = __MKBYTEARRAY((char *)&ifreq.ifr_addr, sizeof(ifreq.ifr_addr));
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6995
	    __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6996
	    t = __MKSTRING(&ifreq.ifr_name);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6997
	    __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6998
	    countOfIf += 1;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  6999
	}
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7000
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7001
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7002
    noOfIf = __mkSmallInteger(countOfIf);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7003
bad:
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7004
    if (afinet_socket >= 0)
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7005
	close(afinet_socket);
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7006
#else
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7007
    error = @symbol(notSupported);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7008
#endif /* defined(SIOCGIFADDR) */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7009
%}.
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7010
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7011
    retDictionary := Dictionary new:noOfIf.
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7012
    error notNil ifTrue:[
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7013
	self primitiveFailed:error.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7014
	"return empty dictionary if proceed from error"
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7015
	^  retDictionary.
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7016
    ].
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7017
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7018
    1 to:noOfIf do:[:cnt|
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7019
	"take the first address, if there is more than one!!"
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7020
	retDictionary at:(nameArray at:cnt) ifAbsentPut:(SocketAddress fromBytes:(addressArray at:cnt)).
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7021
    ].
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7022
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7023
    ^ retDictionary
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7024
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7025
    "
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7026
      OperatingSystem getNetworkAddresses
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7027
    "
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7028
!
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  7029
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7030
getNetworkMACAddresses
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7031
    "return a dictionary filled with
15129
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7032
        key -> name of interface
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7033
        value -> the MAC adress (as ByteArray)
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7034
     for each interface"
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7035
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7036
    |addressArray nameArray noOfIf retDictionary error|
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7037
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7038
    noOfIf := 0.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7039
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7040
%{
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  7041
#ifdef SIOCGIFHWADDR
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7042
    int             afinet_socket = -1;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7043
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7044
    struct ifconf   ifc;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7045
    struct ifreq    *ifr;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7046
    struct ifreq    ifreq;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7047
    unsigned char   buf[1024];
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7048
    int             n_ifs, i, countOfIf;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7049
    OBJ             t;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7050
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7051
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7052
    ** Open an INET socket
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7053
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7054
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7055
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7056
    if (afinet_socket < 0) {
15129
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7057
        error = __MKSTRING("Cannot open socket");
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7058
        goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7059
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7060
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7061
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7062
    ** Get the list of network interfaces
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7063
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7064
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7065
    ifc.ifc_len = sizeof (buf);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7066
    ifc.ifc_buf = (caddr_t) buf;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7067
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7068
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
15129
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7069
        error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7070
        goto bad;
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7071
    }
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7072
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7073
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7074
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  7075
    nameArray    = __ARRAY_NEW_INT(n_ifs);
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  7076
    addressArray = __ARRAY_NEW_INT(n_ifs);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7077
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7078
    if (nameArray == nil || addressArray == nil) {
15129
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7079
        /* Creating a string wouldn/t work here */
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7080
        error = @symbol(allocationFailure);
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7081
        goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7082
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7083
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7084
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7085
    ** Iterate of the list of the system's netif. Find all
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7086
    ** active interfaces and their ethernet addresses
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7087
    */
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7088
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7089
    countOfIf = 0;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7090
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7091
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
15129
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7092
        /*
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7093
        ** Get Flags for this interface
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7094
        */
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7095
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7096
        memcpy(&ifreq, ifr, sizeof(ifreq));
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7097
        if (ioctl (afinet_socket, SIOCGIFFLAGS, &ifreq) < 0) {
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7098
            if (@global(InfoPrinting) == true) {
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7099
                fprintf(stderr, "OS [warning]: ioctl(SIOCGIFFLAGS) failed");
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7100
            }
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7101
        } else {
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7102
            /*
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7103
            ** Get Hardware address for this interface
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7104
            */
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7105
            memcpy(&ifreq, ifr, sizeof(ifreq));
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7106
            if (ioctl (afinet_socket, SIOCGIFHWADDR, &ifreq) >= 0) {
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7107
                t = __MKBYTEARRAY(&ifreq.ifr_hwaddr.sa_data, IFHWADDRLEN);
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7108
                __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7109
                t = __MKSTRING(&ifreq.ifr_name);
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7110
                __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7111
                countOfIf += 1;
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7112
            }
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7113
        }
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  7114
    }
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  7115
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7116
    noOfIf = __mkSmallInteger(countOfIf);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7117
bad:
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7118
    if (afinet_socket >= 0)
15129
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7119
        close(afinet_socket);
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  7120
#else
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  7121
    error = @symbol(notSupported);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  7122
#endif /* SIOCGIFHWADDR */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7123
%}.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7124
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7125
    error notNil ifTrue:[
15129
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7126
        self primitiveFailed:error.
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7127
        "return an empty dictionary if proceed from error"
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7128
        ^  Dictionary new.
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7129
    ].
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7130
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7131
    "we prefer OrderedDictionary here, because we want to keep the 
15152
2252471df4ae class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15151
diff changeset
  7132
     order as defined in the OS."
15151
60e0fcf07b17 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15129
diff changeset
  7133
    retDictionary := OrderedDictionary new:noOfIf.
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7134
    1 to:noOfIf do:[:cnt|
15129
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7135
        |macAddress|
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7136
        
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7137
        macAddress := addressArray at:cnt.
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7138
        macAddress ~= #[0 0 0 0 0 0] ifTrue:[
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7139
            retDictionary at:(nameArray at:cnt) put:macAddress.
2a0db5d6749f class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15072
diff changeset
  7140
        ].
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7141
    ].
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7142
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  7143
    ^ retDictionary
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7144
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7145
    "
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7146
      OperatingSystem getNetworkMACAddresses
6542
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  7147
    "
6363
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  7148
!
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  7149
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7150
getNumberOfProcessors
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7151
    "answer the number of physical processors in the system"
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7152
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7153
%{ /* NOCONTEXT */
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7154
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7155
#ifdef _SC_NPROCESSORS_CONF
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7156
    RETURN(__mkSmallInteger(sysconf(_SC_NPROCESSORS_CONF)));
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7157
#endif
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7158
%}.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7159
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7160
    self shouldImplement.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7161
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7162
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7163
      self getNumberOfProcessors
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7164
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7165
!
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7166
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7167
getProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7168
    "return the (unix-)processId"
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
%{  /* NOCONTEXT */
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7171
    RETURN ( __mkSmallInteger(getpid()) );
3496
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7174
     OperatingSystem getProcessId
3496
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
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7177
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7178
getSystemID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7179
    "if supported by the OS, return the systemID;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7180
     a unique per machine identification.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7181
     WARNING:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7182
	not all systems support this; on some, #unknown is returned."
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7183
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7184
%{  /* NOCONTEXT */
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7185
#if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7186
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7187
	char buffer[128];
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7188
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7189
	buffer[0] = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7190
	if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7191
	    buffer[127] = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7192
	    if (strlen(buffer) > 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7193
		RETURN(__MKSTRING(buffer));
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7194
	    }
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7195
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7196
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7197
#elif defined(HAS_GETHOSTID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7198
    int runningId;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7199
    OBJ arr;
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
    runningId = gethostid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7202
    arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7203
    *(int *)(__byteArrayVal(arr)) = runningId;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7204
    RETURN (arr);
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7205
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7206
#elif defined(IRIX5)
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7207
    char idBuffer[MAXSYSIDSIZE];
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7208
    int retVal;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7209
    OBJ arr;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7210
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7211
    if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7212
	arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7213
	bcopy(idBuffer, __byteArrayVal(arr), MAXSYSIDSIZE);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7214
	RETURN (arr);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7215
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7216
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7217
%}.
13726
73a69112be21 comment/format in: #getSystemType
Stefan Vogel <sv@exept.de>
parents: 13365
diff changeset
  7218
    ^ #unknown
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7219
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7220
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7221
     OperatingSystem getSystemID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7222
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7223
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7224
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7225
getSystemInfo
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7226
    "return info on the system we are running on.
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7227
     If the system supports uname and sysinfo-like system calls, that info is returned;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7228
     otherwise, some simulated info is returned.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7229
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7230
     WARNING:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7231
       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
  7232
       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
  7233
       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
  7234
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7235
       This method is mainly provided to augment error reports with some system
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7236
       information.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7237
       (in case of system/version specific OS errors, conditional workarounds and patches
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7238
	may be based upon this info).
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7239
       Also, applications could enable/disable buffering or otherwise reduce
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7240
       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
  7241
       Your application may make use of available information for tuning,
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7242
       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
  7243
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7244
     The returned info may (or may not) contain:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7245
	#system -> some operating system identification (irix, Linux, nt, win32s ...)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7246
	#version -> OS version (some os version identification)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7247
	#release -> OS release (3.5, 1.2.1 ...)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7248
	#node   -> some host identification (hostname)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7249
	#domain  -> domain name (hosts domain)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7250
	#machine -> type of CPU (i586, mips ...)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7251
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7252
     those are currently returned on some machines (no warranty)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7253
     linux:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7254
	#totalRam         -> total amount of memory available
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7255
	#sharedRam        -> amount of memory which is shared among processes
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7256
			     (i.e. shared code)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7257
	#bufferRam        -> amount used for buffers
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7258
	#swapSize         -> total size of swap space
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7259
	#freeSwap         -> free amount in swapSpace
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7260
	#numberOfCPUs     -> number of cpus in box
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7261
	#extendedInstructions -> extended instruction set info
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7262
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7263
     osf:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7264
	#physicalRam      -> total amount of physical memory
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7265
	#cpuType          -> type of cpu (more detailed than machine)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7266
	#numberOfCPUs     -> number of cpus in box
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7267
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7268
     osx:
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7269
	#physicalRam      -> total amount of physical memory
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7270
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7271
     solaris:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7272
	#physicalRam      -> total amount of physical memory
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7273
	#availableRam     -> total available amount of physical memory (i.e. unused ram)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7274
	#freeRam          -> amount of free memory
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7275
	#numberOfCPUs     -> number of cpus in box (online CPUS)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7276
	[#dCacheSize]     -> bytes in data cache (only available on some solaris versions)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7277
	[#iCacheSize]     -> bytes in data cache (only available on some solaris versions)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7278
	[#instructionSets]-> instruction sets available (only available on some solaris versions)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7279
	[#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
  7280
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7281
     hpux:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7282
	#physicalRam      -> total amount of physical memory in box
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7283
	#activeRealMemory -> ? - read pstat documentation
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7284
	#activeVirtualRam -> ? - read pstat documentation
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7285
	#freeMemory       -> ? - read pstat documentation
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7286
	#realMemory       -> ? (amount of memory left to user programs)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7287
	#virtualRam       -> ? - read pstat documentation
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7288
    "
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7289
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7290
    |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
  7291
     physicalRam availableRam totalRam sharedRam bufferRam swapSize freeSwap
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7292
     numberOfCPUs numberOfPhysicalCPUs pageSize physicalPages availablePages dCacheSize iCacheSize
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7293
     virtualRam activeVirtualRam realMemory activeRealMemory freeMemory
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7294
     instructionSets extendedInstructions platform|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7295
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7296
%{  /* STACK: 4096 */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7297
#ifdef LINUX
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  7298
# ifdef ELF /* old a.out unixes do not have this ... */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7299
    /*
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7300
     * additional info available ...
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7301
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7302
    struct sysinfo infoBuffer;
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7303
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7304
    if (sysinfo(&infoBuffer) >= 0) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7305
	totalRam   = __MKUINT(infoBuffer.totalram);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7306
	sharedRam = __MKUINT(infoBuffer.sharedram);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7307
	bufferRam = __MKUINT(infoBuffer.bufferram);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7308
	swapSize  = __MKUINT(infoBuffer.totalswap);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7309
	freeSwap  = __MKUINT(infoBuffer.freeswap);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7310
    }
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  7311
# endif
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7312
#endif /* LINUX */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7313
4088
622551d3c0d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  7314
#if defined(hpux) && !defined(__GNUC__)
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7315
# include <sys/pstat.h>
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7316
    struct pst_static stat_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7317
    struct pst_dynamic dynam_buf;
11285
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7318
    union pstun pstun_static;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7319
    union pstun pstun_dynamic;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7320
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7321
    pstun_static.pst_static = &stat_buf;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7322
    pstun_dynamic.pst_dynamic = &dynam_buf;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7323
    pstat(PSTAT_STATIC, pstun_static, (size_t)(sizeof(stat_buf)), (size_t)0, 0);
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7324
    pstat(PSTAT_DYNAMIC, pstun_dynamic, (size_t)(sizeof(dynam_buf)), (size_t)0, 0);
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7325
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7326
    physicalRam        = __MKUINT(stat_buf.physical_memory/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7327
    virtualRam         = __MKUINT(dynam_buf.psd_vm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7328
    activeVirtualRam   = __MKUINT(dynam_buf.psd_avm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7329
    realMemory         = __MKUINT(dynam_buf.psd_rm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7330
    activeRealMemory   = __MKUINT(dynam_buf.psd_arm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7331
    freeMemory         = __MKUINT(dynam_buf.psd_free/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7332
#endif
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7333
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7334
#if defined(HAS_UNAME)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7335
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7336
	struct utsname ubuff;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7337
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7338
	if (uname(&ubuff) >= 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7339
	    sys  = __MKSTRING(ubuff.sysname);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7340
	    node = __MKSTRING(ubuff.nodename);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7341
	    rel  = __MKSTRING(ubuff.release);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7342
	    ver  = __MKSTRING(ubuff.version);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7343
	    mach = __MKSTRING(ubuff.machine);
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7344
# if defined(HAS_UTS_DOMAINNAME) || defined(_GNU_SOURCE)
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7345
	    dom  = __MKSTRING(ubuff.domainname);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7346
# endif /* no HAS_UTS_DOMAINNAME */
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7347
	}
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7348
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7349
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7350
#else /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7351
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7352
    /*
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7353
     * use fallBack code below
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7354
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7355
#endif /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7356
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7357
#if defined(HAS_SYSINFO)
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7358
# if defined(SI_ARCHITECTURE)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7359
    if (arch == nil) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7360
	char buffer[128];
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7361
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7362
	if (sysinfo(SI_ARCHITECTURE, buffer, sizeof(buffer))) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7363
	    arch = __MKSTRING(buffer);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7364
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7365
    }
4923
1cacdcfc82c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4922
diff changeset
  7366
# endif /* SI_ARCHITECTURE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7367
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7368
# if defined(SI_ISALIST)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7369
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7370
	char buffer[128];
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7371
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7372
	if (sysinfo(SI_ISALIST, buffer, sizeof(buffer))) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7373
	    instructionSets = __MKSTRING(buffer);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7374
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7375
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7376
# endif /* SI_ISALIST */
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7377
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7378
# if defined(SI_PLATFORM)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7379
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7380
	char buffer[128];
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7381
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7382
	if (sysinfo(SI_PLATFORM, buffer, sizeof(buffer))) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7383
	    platform = __MKSTRING(buffer);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7384
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7385
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7386
# endif /* SI_PLATFORM */
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7387
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7388
# if defined(SI_RELEASE)
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7389
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7390
	char buffer[128];
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7391
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7392
	if (sysinfo(SI_RELEASE, buffer, sizeof(buffer))) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7393
	    rel = __MKSTRING(buffer);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7394
	}
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7395
    }
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7396
# endif /* SI_RELEASE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7397
#endif /* HAS_SYSINFO */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7398
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7399
#if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7400
# ifdef _SC_NPROCESSORS_ONLN
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7401
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7402
	long val;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7403
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7404
	val = sysconf(_SC_NPROCESSORS_ONLN);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7405
	if (val > 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7406
	    numberOfCPUs = __MKINT(val);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7407
	}
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7408
    }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7409
# endif
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7410
# ifdef _SC_NPROCESSORS_CONF
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7411
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7412
	long val;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7413
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7414
	val = sysconf(_SC_NPROCESSORS_CONF);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7415
	if (val > 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7416
	    numberOfPhysicalCPUs = __MKINT(val);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7417
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7418
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7419
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7420
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7421
# if defined(_SC_PAGESIZE)
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7422
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7423
	long val;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7424
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7425
	val = sysconf(_SC_PAGESIZE);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7426
	if (val != -1) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7427
	    pageSize = __MKUINT(val);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7428
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7429
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7430
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7431
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7432
# if defined(_SC_PHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7433
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7434
	long val;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7435
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7436
	val = sysconf(_SC_PHYS_PAGES);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7437
	if (val != -1) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7438
	    physicalPages = __MKUINT(val);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7439
	}
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7440
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7441
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7442
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7443
# if defined(_SC_AVPHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7444
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7445
	long val;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7446
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7447
	val = sysconf(_SC_AVPHYS_PAGES);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7448
	if (val != -1) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7449
	    availablePages = __MKUINT(val);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7450
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7451
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7452
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7453
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7454
# if defined(_SC_ICACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7455
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7456
	long val;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7457
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7458
	val = sysconf(_SC_ICACHE_SZ);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7459
	if (val != -1) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7460
	    iCacheSize = __MKUINT(val);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7461
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7462
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7463
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7464
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7465
# if defined(_SC_DCACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7466
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7467
	long val;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7468
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7469
	val = sysconf(_SC_DCACHE_SZ);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7470
	if (val != -1) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7471
	    dCacheSize = __MKUINT(val);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7472
	}
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7473
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7474
# endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7475
#endif /* HAS_SYSCONF */
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7476
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7477
#if defined(HAS_GETSYSINFO)
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7478
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7479
	INT index;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7480
	int retInt32 = 0;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7481
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7482
# if defined(GSI_CPU)
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7483
	index = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7484
	if (getsysinfo(GSI_CPU, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7485
	    switch (retInt32) {
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7486
#  ifdef VAX_780
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7487
		case VAX_780:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7488
		    cpuType = __MKSTRING("VAX_780");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7489
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7490
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7491
#  ifdef VAX_750
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7492
		case VAX_750:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7493
		    cpuType = __MKSTRING("VAX_750");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7494
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7495
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7496
#  ifdef VAX_730
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7497
		case VAX_730:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7498
		    cpuType = __MKSTRING("VAX_730");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7499
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7500
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7501
#  ifdef VAX_8600
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7502
		case VAX_8600:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7503
		    cpuType = __MKSTRING("VAX_8600");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7504
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7505
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7506
#  ifdef VAX_8200
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7507
		case VAX_8200:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7508
		    cpuType = __MKSTRING("VAX_8200");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7509
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7510
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7511
#  ifdef VAX_8800
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7512
		case VAX_8800:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7513
		    cpuType = __MKSTRING("VAX_8800");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7514
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7515
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7516
#  ifdef MVAX_I
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7517
		case MVAX_I:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7518
		    cpuType = __MKSTRING("MVAX_I");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7519
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7520
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7521
#  ifdef MVAX_II
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7522
		case MVAX_II:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7523
		    cpuType = __MKSTRING("MVAX_II");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7524
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7525
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7526
#  ifdef V_VAX
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7527
		case V_VAX:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7528
		    cpuType = __MKSTRING("V_VAX");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7529
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7530
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7531
#  ifdef VAX_3600
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7532
		case VAX_3600:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7533
		    cpuType = __MKSTRING("VAX_3600");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7534
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7535
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7536
#  ifdef VAX_6200
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7537
		case VAX_6200:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7538
		    cpuType = __MKSTRING("VAX_6200");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7539
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7540
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7541
#  ifdef VAX_3400
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7542
		case VAX_3400:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7543
		    cpuType = __MKSTRING("VAX_3400");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7544
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7545
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7546
#  ifdef C_VAXSTAR
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7547
		case C_VAXSTAR:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7548
		    cpuType = __MKSTRING("C_VAXSTAR");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7549
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7550
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7551
#  ifdef VAX_60
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7552
		case VAX_60:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7553
		    cpuType = __MKSTRING("VAX_60");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7554
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7555
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7556
#  ifdef VAX_3900
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7557
		case VAX_3900:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7558
		    cpuType = __MKSTRING("VAX_3900");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7559
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7560
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7561
#  ifdef DS_3100
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7562
		case DS_3100:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7563
		    cpuType = __MKSTRING("DS_3100");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7564
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7565
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7566
#  ifdef VAX_8820
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7567
		case VAX_8820:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7568
		    cpuType = __MKSTRING("VAX_8820");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7569
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7570
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7571
#  ifdef DS_5400
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7572
		case DS_5400:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7573
		    cpuType = __MKSTRING("DS_5400");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7574
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7575
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7576
#  ifdef DS_5800
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7577
		case DS_5800:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7578
		    cpuType = __MKSTRING("DS_5800");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7579
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7580
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7581
#  ifdef DS_5000
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7582
		case DS_5000:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7583
		    cpuType = __MKSTRING("DS_5000");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7584
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7585
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7586
#  ifdef DS_CMAX
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7587
		case DS_CMAX:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7588
		    cpuType = __MKSTRING("DS_CMAX");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7589
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7590
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7591
#  ifdef VAX_6400
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7592
		case VAX_6400:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7593
		    cpuType = __MKSTRING("VAX_6400");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7594
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7595
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7596
#  ifdef VAXSTAR
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7597
		case VAXSTAR:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7598
		    cpuType = __MKSTRING("VAXSTAR");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7599
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7600
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7601
#  ifdef DS_5500
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7602
		case DS_5500:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7603
		    cpuType = __MKSTRING("DS_5500");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7604
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7605
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7606
#  ifdef DS_5100
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7607
		case DS_5100:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7608
		    cpuType = __MKSTRING("DS_5100");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7609
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7610
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7611
#  ifdef VAX_9000
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7612
		case VAX_9000:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7613
		    cpuType = __MKSTRING("VAX_9000");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7614
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7615
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7616
#  ifdef DS_500_100
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7617
		case DS_500_100:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7618
		    cpuType = __MKSTRING("DS_500_100");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7619
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7620
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7621
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7622
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7623
#  ifdef ALPHA_ADU
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7624
		case ALPHA_ADU:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7625
		    cpuType = __MKSTRING("ALPHA_ADU");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7626
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7627
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7628
#  ifdef DEC_4000
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7629
		case DEC_4000:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7630
		    cpuType = __MKSTRING("DEC_4000");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7631
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7632
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7633
#  ifdef DEC_3000_500
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7634
		case DEC_3000_500:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7635
		    cpuType = __MKSTRING("DEC_3000_500");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7636
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7637
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7638
#  ifdef DEC_7000
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7639
		case DEC_7000:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7640
		    cpuType = __MKSTRING("DEC_7000");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7641
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7642
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7643
#  ifdef DS_5000_300
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7644
		case DS_5000_300:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7645
		    cpuType = __MKSTRING("DS_5000_300");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7646
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7647
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7648
#  ifdef DEC_3000_300
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7649
		case DEC_3000_300:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7650
		    cpuType = __MKSTRING("DEC_3000_300");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7651
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7652
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7653
#  ifdef DEC_2000_300
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7654
		case DEC_2000_300:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7655
		    cpuType = __MKSTRING("DEC_2000_300");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7656
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7657
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7658
#  ifdef DEC_2100_A500
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7659
		case DEC_2100_A500:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7660
		    cpuType = __MKSTRING("DEC_2100_A500");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7661
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7662
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7663
#  ifdef DEC_2100_A50
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7664
		case DEC_2100_A50:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7665
		    cpuType = __MKSTRING("DEC_2100_A50");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7666
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7667
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7668
#  ifdef ALPHA_KN20AA
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7669
		case ALPHA_KN20AA:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7670
		    cpuType = __MKSTRING("ALPHA_KN20AA");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7671
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7672
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7673
#  ifdef DEC_21000
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7674
		case DEC_21000:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7675
		    cpuType = __MKSTRING("DEC_21000");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7676
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7677
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7678
#  ifdef DEC_AXPVME_64
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7679
		case DEC_AXPVME_64:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7680
		    cpuType = __MKSTRING("DEC_AXPVME_64");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7681
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7682
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7683
#  ifdef DEC_2100_C500
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7684
		case DEC_2100_C500:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7685
		    cpuType = __MKSTRING("DEC_2100_C500");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7686
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7687
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7688
#  ifdef DEC_AXPPCI_33
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7689
		case DEC_AXPPCI_33:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7690
		    cpuType = __MKSTRING("DEC_AXPPCI_33");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7691
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7692
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7693
#  ifdef DEC_1000
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7694
		case DEC_1000:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7695
		    cpuType = __MKSTRING("DEC_1000");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7696
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7697
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7698
#  ifdef EB64_PLUS
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7699
		case EB64_PLUS:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7700
		    cpuType = __MKSTRING("EB64_PLUS");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7701
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7702
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7703
#  ifdef LCA_EB66
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7704
		case LCA_EB66:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7705
		    cpuType = __MKSTRING("LCA_EB66");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7706
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7707
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7708
#  ifdef ALPHA_EB164
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7709
		case ALPHA_EB164:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7710
		    cpuType = __MKSTRING("ALPHA_EB164");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7711
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7712
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7713
#  ifdef DEC_EV45_PBP
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7714
		case DEC_EV45_PBP:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7715
		    cpuType = __MKSTRING("DEC_EV45_PBP");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7716
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7717
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7718
#  ifdef DEC_1000A
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7719
		case DEC_1000A:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7720
		    cpuType = __MKSTRING("DEC_1000A");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7721
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7722
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7723
#  ifdef DEC_4100
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7724
		case DEC_4100:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7725
		    cpuType = __MKSTRING("DEC_4100");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7726
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7727
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7728
#  ifdef DEC_ALPHAVME_224
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7729
		case DEC_ALPHAVME_224:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7730
		    cpuType = __MKSTRING("DEC_ALPHAVME_224");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7731
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7732
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7733
#  ifdef DEC_1000_5
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7734
		case DEC_1000_5:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7735
		    cpuType = __MKSTRING("DEC_1000_5");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7736
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7737
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7738
#  ifdef DEC_1000A_5
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7739
		case DEC_1000A_5:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7740
		    cpuType = __MKSTRING("DEC_1000A_5");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7741
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7742
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7743
#  ifdef DEC_EV56_PBP
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7744
		case DEC_EV56_PBP:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7745
		    cpuType = __MKSTRING("DEC_EV56_PBP");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7746
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7747
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7748
#  ifdef ALPHABOOK
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7749
		case ALPHABOOK:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7750
		    cpuType = __MKSTRING("ALPHABOOK");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7751
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7752
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7753
#  ifdef DEC_ALPHAVME_320
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7754
		case DEC_ALPHAVME_320:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7755
		    cpuType = __MKSTRING("DEC_ALPHAVME_320");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7756
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7757
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7758
#  ifdef DEC_550
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7759
		case DEC_550:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7760
		    cpuType = __MKSTRING("DEC_550");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7761
		    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7762
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7763
#  ifdef DEC_6600
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7764
		case DEC_6600:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7765
		    cpuType = __MKSTRING("DEC_6600");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7766
		    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7767
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7768
#  ifdef UNKN_SYSTEM
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7769
		case UNKN_SYSTEM:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7770
		    cpuType = __MKSTRING("UNKN_SYSTEM");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7771
		    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7772
#  endif
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7773
		default:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7774
		    cpuType = __MKSTRING("OTHER_DEC_SYSTEM");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7775
		    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7776
	    }
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7777
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7778
# endif /* GSI_CPU */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7779
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7780
# if defined(GSI_CPU_INFO)
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7781
	/*
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7782
	 * stupid: OSF1 pre V4.0 has no mhz, but V4.0 has it.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7783
	 * use the GSI_PLATFORM_NAME as a hint - it is only defined in
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7784
	 * V4.0 and higher ... (sigh)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7785
	 */
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  7786
#  if defined GSI_PLATFORM_NAME
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7787
	{
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7788
	    struct cpu_info cpuInfo;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7789
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7790
	    index = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7791
	    if (getsysinfo(GSI_CPU_INFO, &cpuInfo, sizeof(cpuInfo), &index, NULL) > 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7792
		cpuSpeed   = __MKUINT(cpuInfo.mhz);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7793
	    }
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7794
	}
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  7795
#  endif
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7796
# endif /* GSI_CPU_INFO */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7797
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7798
# if defined(GSI_CPUS_IN_BOX)
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7799
	index = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7800
	if (getsysinfo(GSI_CPUS_IN_BOX, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7801
	    numberOfCPUs   = __MKUINT(retInt32);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7802
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7803
# endif /* GSI_CPUS_IN_BOX */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7804
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7805
# if defined(GSI_PHYSMEM)
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7806
	index = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7807
	if (getsysinfo(GSI_PHYSMEM, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7808
	    INT bytes = retInt32 * 1024;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7809
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7810
	    physicalRam   = __MKUINT(bytes);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7811
	}
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7812
# endif /* GSI_PHYSMEM */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7813
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7814
# if defined(GSI_PLATFORM_NAME) && (!defined(HAS_SYSINFO) || !defined(SI_PLATFORM))
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7815
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7816
	char buffer[128];
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7817
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7818
	index = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7819
	if (getsysinfo(GSI_PLATFORM_NAME, buffer, sizeof(buffer), &index, NULL) > 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7820
	    platform = __MKSTRING(buffer);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7821
	}
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7822
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7823
# endif /* GSI_PLATFORM_NAME */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7824
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7825
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7826
#endif /* HAS_GETSYSINFO */
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7827
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7828
#if defined(HAS_SYSCTL) /* __osx__ */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7829
    int mib[3];
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7830
    long _physmem;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7831
    size_t _len;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7832
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7833
    mib[0] = CTL_HW;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7834
    mib[1] = HW_MEMSIZE;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7835
    _len = sizeof(_physmem);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7836
    sysctl(mib, 2, &_physmem, &_len, NULL, 0);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7837
    physicalRam   = __MKUINT(_physmem);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7838
#endif /* __osx__ */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7839
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7840
#if defined(__x86_64__)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7841
    cpuType = __MKSTRING("x86_64");
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7842
#endif
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7843
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  7844
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7845
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7846
	extern OBJ __getInstructionSetInfo();
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7847
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7848
	extendedInstructions = __getInstructionSetInfo();
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7849
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7850
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7851
    sys isNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7852
	sys := self getSystemType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7853
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7854
    node isNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7855
	node := self getHostName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7856
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7857
    dom isNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7858
	dom := self getDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7859
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7860
    mach isNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7861
	mach := self getCPUType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7862
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7863
    arch isNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7864
	arch := sys.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7865
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7866
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7867
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7868
    info at:#system put:sys.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7869
    info at:#node put:node.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7870
    rel notNil ifTrue:[info at:#release put:rel].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7871
    ver notNil ifTrue:[info at:#version put:ver].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7872
    mach notNil ifTrue:[info at:#machine put:mach].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7873
    arch notNil ifTrue:[info at:#architecture put:arch].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7874
    dom notNil ifTrue:[info at:#domain put:dom].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7875
    (pageSize notNil and:[physicalPages notNil]) ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7876
	physicalRam := pageSize * physicalPages. "/ done here - could be largeInt.
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7877
    ].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7878
    physicalRam notNil ifTrue:[info at:#physicalRam put:physicalRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7879
    (pageSize notNil and:[availablePages notNil]) ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7880
	availableRam := pageSize * availablePages. "/ done here - could be largeInt.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7881
	availableRam notNil ifTrue:[info at:#availableRam put:availableRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7882
    ].
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7883
    totalRam notNil ifTrue:[info at:#totalRam put:totalRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7884
    sharedRam notNil ifTrue:[info at:#sharedRam put:sharedRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7885
    bufferRam notNil ifTrue:[info at:#bufferRam put:bufferRam].
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7886
    virtualRam notNil ifTrue:[info at:#virtualRam put:virtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7887
    activeVirtualRam notNil ifTrue:[info at:#activeVirtualRam put:activeVirtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7888
    realMemory notNil ifTrue:[info at:#realMemory put:realMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7889
    activeRealMemory notNil ifTrue:[info at:#activeRealMemory put:activeRealMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7890
    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
  7891
    swapSize notNil ifTrue:[info at:#swapSize put:swapSize].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7892
    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
  7893
    numberOfCPUs notNil ifTrue:[info at:#numberOfCPUs put:numberOfCPUs].
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7894
    numberOfPhysicalCPUs notNil ifTrue:[info at:#numberOfPhysicalCPUs put:numberOfPhysicalCPUs].
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7895
    cpuType notNil ifTrue:[info at:#cpuType put:cpuType].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7896
    cpuSpeed notNil ifTrue:[info at:#cpuSpeed put:cpuSpeed].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7897
    dCacheSize notNil ifTrue:[info at:#dCacheSize put:dCacheSize].
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7898
    iCacheSize notNil ifTrue:[info at:#iCacheSize put:iCacheSize].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7899
    instructionSets notNil ifTrue:[info at:#instructionSets put:instructionSets].
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7900
    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
  7901
    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
  7902
    info at:#osType put:(self getOSType).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7903
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7904
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7905
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7906
     OperatingSystem getSystemInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7907
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7908
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7909
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7910
getSystemType
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7911
    "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
  7912
     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
  7913
     is slightly different for some systems (i.e. iris vs. irix).
13726
73a69112be21 comment/format in: #getSystemType
Stefan Vogel <sv@exept.de>
parents: 13365
diff changeset
  7914
     Don't depend on this - use getOSType. I dont really see a point
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7915
     here ...
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7916
     (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
  7917
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7918
    |sys|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7919
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7920
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7921
#   ifdef NEXT
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7922
#    define SYS_SYMBOL @symbol(next)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7923
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7924
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7925
#   ifdef IRIS
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7926
#    define SYS_SYMBOL @symbol(iris)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7927
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7928
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7929
#   ifdef SYS_SYMBOL
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7930
     sys = SYS_SYMBOL;
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7931
#    undef SYS_SYMBOL
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7932
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7933
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7934
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7935
    sys isNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7936
	^ self getOSType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7937
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7938
    ^ sys
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7939
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7940
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7941
     OperatingSystem getSystemType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7942
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7943
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7944
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7945
isBSDlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7946
    "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
  7947
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7948
%{  /* NOCONTEXT */
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
#if defined(BSD) || defined(MACH) || defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7951
    RETURN ( true );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7952
#endif
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
    ^ false
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7955
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7956
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7957
     OperatingSystem isBSDlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7958
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7959
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7960
14802
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7961
isOSXlike
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7962
    "return true, if the OS we're running on is a mac OSX unix (not A/UX or OS9)."
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7963
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7964
%{  /* NOCONTEXT */
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7965
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7966
#if defined(__osx__)
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7967
    RETURN ( true );
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7968
#endif
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7969
%}.
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7970
    ^ false
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7971
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7972
    "
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7973
     OperatingSystem isOSXlike
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7974
    "
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7975
!
9730b178dbcc *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14799
diff changeset
  7976
12640
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7977
isProcessIdPresent:pid
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7978
    "answer true, if a process with process id pid is present, false if not"
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7979
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7980
%{
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7981
    if (__isSmallInteger(pid)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7982
	/* in UNIX, a kill(pid, 0) is a noop used to check if a pid exists */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7983
	if (kill(__smallIntegerVal(pid), 0) < 0 && errno != EPERM) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7984
	    RETURN ( false );
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7985
	}
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7986
	RETURN ( true );
12640
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7987
    }
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7988
%}.
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7989
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7990
    ^ self primitiveFailed:#invalidParameter
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7991
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7992
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7993
    "
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7994
      self isProcessIdPresent:self getProcessId
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7995
      self isProcessIdPresent:1
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7996
      self isProcessIdPresent:4711
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  7997
    "
12640
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7998
!
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7999
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8000
isUNIXlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8001
    "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
  8002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8003
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8004
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8005
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8006
     OperatingSystem isUNIXlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  8007
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8008
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8009
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8010
maxFileNameLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8011
    "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
  8012
     CAVEAT:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8013
	 Actually, the following is somewhat wrong - some systems
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8014
	 support different sizes, depending on the volume.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8015
	 We return a somewhat conservative number here.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8016
	 Another entry, to query for volume specific max
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8017
	 will be added in the future."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8018
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8019
%{  /* NOCONTEXT */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8020
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8021
    /*
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8022
     * 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
  8023
     */
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8024
#   if defined(MAXFILENAMELEN)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8025
      RETURN ( __mkSmallInteger(MAXFILENAMELEN) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8026
#   else
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8027
#    if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8028
      RETURN ( __mkSmallInteger(255) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8029
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8030
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8031
#    ifdef realIX
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8032
       RETURN ( __mkSmallInteger(127) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8033
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8034
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8035
#    ifdef SYSV
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8036
       RETURN ( __mkSmallInteger(14) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8037
#    endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8038
#   endif
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
    "unix default"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8041
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8042
    ^ 14
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8043
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8044
    "
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8045
     OperatingSystem maxFileNameLength
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  8046
    "
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
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8049
maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8050
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8051
%{
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8052
     long l;
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8053
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8054
     l = sysconf(_SC_OPEN_MAX);
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8055
     if (l >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8056
	 RETURN(__mkSmallInteger(l));
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8057
     }
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8058
%}.
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8059
     self primitiveFailed
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8060
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8061
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8062
      self maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8063
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8064
!
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  8065
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8066
maxPathLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8067
    "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
  8068
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8069
%{  /* NOCONTEXT */
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8070
    RETURN ( __mkSmallInteger(MAXPATHLEN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8071
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8072
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8073
     OperatingSystem maxPathLength
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8074
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8075
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8076
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8077
pathSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8078
    "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
  8079
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8080
    ^ $:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8081
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8082
    "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
  8083
    "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
  8084
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8085
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8086
platformName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8087
    "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
  8088
     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
  8089
     #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
  8090
     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
  8091
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8092
    ^ #unix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8093
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8094
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8095
     OperatingSystem platformName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8096
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8097
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8098
    "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
  8099
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8100
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8101
primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8102
    "return the domain this host is in.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8103
     Notice:
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  8104
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8105
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8106
%{  /* STACK: 2048 */
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8107
#if defined(HAS_GETDOMAINNAME)
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  8108
    char buffer[256];
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8109
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8110
    if (getdomainname(buffer, sizeof(buffer)) == 0) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  8111
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8112
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8113
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8114
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8115
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8116
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8117
    if (uname(&ubuff) >= 0) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  8118
	RETURN (__MKSTRING(ubuff.domainname));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8119
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8120
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8121
#  if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8122
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8123
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8124
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8125
    if ((ret = sysinfo(SI_SRPC_DOMAIN, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  8126
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8127
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8128
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8129
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8130
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8131
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8132
    ^ nil
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8133
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8134
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8135
     OperatingSystem primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8136
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8137
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8138
    "Modified: 26.4.1996 / 10:04:54 / stefan"
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8139
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8140
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8141
primGetHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8142
    "return the hostname we are running on - if there is
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8143
     a HOST environment variable, we are much faster here ...
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8144
     Notice:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8145
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8146
6960
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  8147
%{  /* STACK: 100000 */
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  8148
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  8149
    /* sigh - with libc.so.6, gethostname needs huge amounts of stack
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  8150
     * actually this is linux specific, but should not hurt others
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  8151
     */
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8152
#if defined(HAS_GETHOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8153
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8154
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8155
    if (gethostname(buffer, sizeof(buffer)) == 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8156
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8157
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8158
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8159
# if defined(HAS_UNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8160
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8161
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8162
    if (uname(&ubuff) >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8163
	RETURN (__MKSTRING(ubuff.nodename));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8164
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8165
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8166
#  if defined(HAS_SYSINFO) && defined(SI_HOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8167
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8168
    int ret;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8169
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8170
    if ((ret = sysinfo(SI_HOSTNAME, buffer, sizeof(buffer))) >= 0 && ret <= sizeof(buffer)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8171
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8172
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8173
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8174
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8175
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8176
%}.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8177
    ^ nil
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8178
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8179
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8180
     OperatingSystem getHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8181
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8182
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8183
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8184
setEnvironment:aKeyStringOrSymbol to:aString
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8185
    "put a string to the environment.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8186
     If aString isNil, the variable will be removed from the environment.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8187
     Currently there is some malloced memory lost each time a variable is put to the environment.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8188
     We could use ExternalBytes and keep the references in a Dictionary to free the
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8189
     memory on change or delete"
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8190
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8191
%{  /* NOCONTEXT */
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8192
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8193
    char *env;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8194
    int valueSize;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8195
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8196
    if (__isStringLike(aKeyStringOrSymbol)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8197
	if (aString == nil) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8198
	    /* env used only temporary for deregistration */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8199
	    valueSize = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8200
	    env = __stringVal(aKeyStringOrSymbol);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8201
	} else if (__isStringLike(aString)) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8202
	    /* have to use stable memory for env */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8203
	    valueSize = __stringSize(aString);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8204
	    env = (char *)malloc(__stringSize(aKeyStringOrSymbol) + valueSize + 2);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8205
	    if (env == 0)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8206
		goto err;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8207
	    strcpy(env, __stringVal(aKeyStringOrSymbol));
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8208
	    strcat(env, "=");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8209
	    strncat(env, __stringVal(aString), valueSize);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8210
	} else
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8211
	    goto err;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8212
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8213
	if (putenv(env) == 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8214
	    RETURN(self);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8215
	}
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8216
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8217
	if (valueSize > 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8218
	    /* could not register, free */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8219
	    free(env);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8220
	}
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8221
err:;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8222
    }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8223
%}.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8224
    ^ self primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8225
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8226
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8227
     OperatingSystem setEnvironment:#TEST to:'abc'.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8228
     OperatingSystem getEnvironment:#TEST.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8229
     OperatingSystem executeCommand:'echo $TEST' outputTo:Transcript.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8230
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8231
     OperatingSystem setEnvironment:#TEST to:nil.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8232
     OperatingSystem setEnvironment:#TEST to:''.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8233
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8234
     OperatingSystem setEnvironment:#LD_LIBRARY_PATH to:'/opt/oracle/instantclient10_1'.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8235
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8236
!
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8237
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8238
setLocale:categorySymbol to:localeStringOrNil 
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8239
    "set (and get) the locale for categorySymbol (e.g. #LC_ALL, #LC_CTYPE,....).
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8240
     If localeStringOrNil is nil, nothing is set.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8241
     If localeStringOrNil is empty, the locale for categorySymbol ist set from the environment.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8242
     If localeStringOrNil is 'C', the locale for categorySymbol ist set to the default.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8243
     If localeStringOrNil is to a locale name, the locale for categorySymbol ist set.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8244
     The current locale setting is returned."
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8245
    
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8246
    |locale error|
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8247
    
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8248
%{
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8249
    int __category;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8250
    char *__locale, *ret;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8251
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8252
    if (categorySymbol == @symbol(LC_ALL)) {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8253
        __category = LC_ALL;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8254
    } else if (categorySymbol == @symbol(LC_COLLATE)) {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8255
        __category = LC_COLLATE;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8256
    } else if (categorySymbol == @symbol(LC_CTYPE)) {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8257
        __category = LC_CTYPE;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8258
    } else if (categorySymbol == @symbol(LC_MESSAGES)) {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8259
        __category = LC_MESSAGES;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8260
    } else if (categorySymbol == @symbol(LC_MONETARY)) {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8261
        __category = LC_MONETARY;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8262
    } else if (categorySymbol == @symbol(LC_NUMERIC)) {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8263
        __category = LC_NUMERIC;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8264
    } else if (categorySymbol == @symbol(LC_TIME)) {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8265
        __category = LC_TIME;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8266
    } else {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8267
        error = @symbol(argument1);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8268
        goto out;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8269
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8270
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8271
    if (localeStringOrNil == nil) {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8272
        __locale = 0;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8273
    } else if (__isStringLike(localeStringOrNil)){
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8274
        __locale = __stringVal(localeStringOrNil);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8275
    } else {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8276
        error = @symbol(argument1);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8277
        goto out;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8278
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8279
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8280
    ret = setlocale(__category, __locale);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8281
    if (ret) {
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8282
        locale = __MKSTRING(ret);
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8283
    }
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8284
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8285
out:;
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8286
%}.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8287
    locale notNil ifTrue:[
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8288
        ^ locale.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8289
    ].
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8290
    ^ self primitiveFailed:error.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8291
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8292
    "
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8293
     OperatingSystem setLocale:#LC_ALL to:nil
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8294
     OperatingSystem setLocale:#LC_CTYPE to:nil
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8295
     OperatingSystem setLocale:#LC_CTYPE to:'C'
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8296
     OperatingSystem setLocale:#LC_CTYPE to:''
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8297
    "
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8298
!
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
  8299
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8300
setLocaleInfo:anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8301
    "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
  8302
     (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
  8303
     See description of fields in #getLocaleInfo.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8304
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8305
     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
  8306
     it should be used by applications as required."
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
    LocaleInfo := anInfoDictionary
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
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8311
     |d|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8312
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8313
     d := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8314
     d at:#decimalPoint                 put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8315
     d at:#thousandsSeparator           put:','         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8316
     d at:#currencySymbol               put:'USD'       .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8317
     d at:#monetaryDecimalPoint         put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8318
     d at:#monetaryThousandsSeparator   put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8319
     d at:#fractionalDigits             put:2           .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8320
     d at:#positiveSign                 put:'+'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8321
     d at:#negativeSign                 put:'-'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8322
     d at:#positiveSignPrecedesCurrencySymbol put:true          .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8323
     d at:#negativeSignPrecedesCurrencySymbol put:false         .
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8324
     OperatingSystem setLocaleInfo:d
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8325
    "
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
supportsChildInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8329
    "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
  8330
     through interrupts (i.e. SIGCHILD)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8332
%{  /* NOCONTEXT */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8333
#if defined(SIGCHLD) || defined(SIGCLD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8334
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8335
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8336
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8337
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8338
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8339
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8340
     OperatingSystem supportsChildInterrupts
3496
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
!
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
supportsIOInterrupts
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8345
    "return true, if the OS supports IO availability interrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8346
     (i.e. SIGPOLL/SIGIO).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8347
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8348
     Currently, this mechanism does not work on all
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8349
     systems ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8350
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8351
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8352
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8353
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8354
  /* positive defines here
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8355
   *  - irix5.2 does not work
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8356
   */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8357
#if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8358
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8359
# if defined(SIGIO) || defined(SIGPOLL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8360
#  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
  8361
#   if defined(F_SETOWN) || defined(FIOSETOWN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8362
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8363
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8364
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8365
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8366
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8367
# endif
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
#endif /* machines where it works */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8370
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8371
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8372
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8373
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8374
     OperatingSystem supportsIOInterrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8375
    "
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8376
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8379
supportsNonBlockingIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8380
    "return true, if the OS supports nonblocking IO."
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
%{  /* NOCONTEXT */
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8383
#if defined(F_GETFL) && defined(F_SETFL)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8384
# if defined(O_NONBLOCK) || defined(O_NDELAY) || defined(FNDELAY)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8385
       RETURN (true);
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8386
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8387
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8388
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8389
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8390
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8391
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8392
     OperatingSystem supportsNonBlockingIO
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8393
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8394
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8395
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8396
supportsSymbolicLinks
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8397
    "return true, if the OS supports symbolic (soft) links;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8398
     most UNIX'es do; many other OS's do not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8399
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8400
%{  /* NOCONTEXT */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8401
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8402
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8403
    /*
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8404
     * assume yes - if that is defined.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8405
     */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8406
    RETURN(true);
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8407
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8408
%}.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8409
    ^ false
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8410
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8411
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8412
     OperatingSystem supportsSymbolicLinks
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8413
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8414
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8415
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8416
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8417
!UnixOperatingSystem class methodsFor:'path queries'!
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8418
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8419
decodePath:encodedPathName
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8420
    "decode the pathName as returned by system calls.
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8421
     E.g. linux system calls return sigle byte strings only,
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8422
     so the pathName has been UTF-8 decoded."
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8423
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8424
    "linux strings are in UTF8 (in contemporary linux versions)"
18015
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8425
    encodedPathName notNil ifTrue:[
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8426
        [
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8427
            Codeset == #utf8 ifTrue:[
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8428
                ^ encodedPathName utf8Decoded.
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8429
            ].
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8430
            "/ Codeset encoder might not yet be initialized, sigh...
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8431
            CodesetEncoder notNil ifTrue:[
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8432
                ^ CodesetEncoder decodeString: encodedPathName             
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8433
            ].
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8434
        ] on:InvalidEncodingError do:[:ex|
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8435
            "maybe there are old filenames in ISO8859-x,
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8436
             just keep them untranslated"
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8437
        ].
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8438
    ].
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8439
    ^ encodedPathName
18015
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8440
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8441
    "Modified: / 23-01-2013 / 10:02:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8442
!
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8443
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8444
defaultSystemPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8445
    "add additional directories to the systemPath
5647
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  8446
     (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
  8447
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
  8448
    |sysPath majorVersionNr releaseFile s v|
5647
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  8449
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  8450
    majorVersionNr := Smalltalk majorVersionNr.
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8451
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8452
    sysPath := super defaultSystemPath.
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8453
    #(
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8454
	'/usr/local/lib/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8455
	'/usr/local/lib/smalltalk'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8456
	'/usr/lib/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8457
	'/usr/lib/smalltalk'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8458
	'/lib/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8459
	'/lib/smalltalk'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8460
	'/opt/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8461
	'/opt/smalltalk'
7698
d8cd175e8e29 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7681
diff changeset
  8462
    ) do:[:dirName |
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8463
	|dir|
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8464
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8465
	dir := dirName asFilename.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8466
	(dir isDirectory) ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8467
	    "/ try to guess a gnu-smalltalk; skip it
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8468
	    (dir construct:'initialize.st') exists ifFalse:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8469
		releaseFile := dir construct:'RELEASE'.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8470
		releaseFile exists ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8471
		    s := releaseFile readStreamOrNil.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8472
		    s notNil ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8473
			v := Integer readFrom:s onError:-1.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8474
			s close.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8475
			v == majorVersionNr ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8476
			    sysPath add:dirName
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8477
			] ifFalse:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8478
			    ('UnixOperatingSystem [info]: ignore files in ' , dir pathName , ' (RELEASE mismatch)') infoPrintCR.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8479
			]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8480
		    ] ifFalse:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8481
			('UnixOperatingSystem [info]: ignore files in ' , dir pathName , ' (RELEASE missing)') infoPrintCR.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8482
		    ]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8483
		]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8484
	    ]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8485
	]
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8486
    ].
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8487
    ^ sysPath
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8488
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8489
    "
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8490
     OperatingSystem defaultSystemPath
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8491
    "
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8492
!
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8493
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8494
encodePath:pathName
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8495
    "encode the pathName for use with system calls.
14839
f79ff27d7e52 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14802
diff changeset
  8496
     E.g. linux system calls accept single byte strings only,
14568
ca342ae94cb7 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14564
diff changeset
  8497
     so the pathName has been UTF-8 encoded, before using it in a system call."
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8498
18015
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8499
    pathName notNil ifTrue:[
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8500
        Codeset == #utf8 ifTrue:[
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8501
            ^ pathName utf8Encoded
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8502
        ].
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8503
        "/ Codeset encoder might not yet be initialized, sigh...
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8504
        CodesetEncoder notNil ifTrue:[
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8505
            ^ CodesetEncoder encodeString: pathName.            
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8506
        ].
14590
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
  8507
    ].
32a92bd392dd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14588
diff changeset
  8508
    ^ pathName
18015
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8509
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
  8510
    "Modified: / 23-01-2013 / 10:00:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8511
! !
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8512
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8513
!UnixOperatingSystem class methodsFor:'private'!
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8514
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8515
mountPointsFromProcFS
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8516
    "return a collection of mountPoints (aka. topDirectories of mounted file systems)"
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8517
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8518
    |entries|
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8519
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8520
    entries := OrderedCollection new.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8521
    ('/proc/mounts' asFilename) readingLinesDo:[:eachLine |
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8522
	|items mountInfo|
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8523
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8524
	items := eachLine asCollectionOfWords.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8525
	mountInfo := (MountInfo new
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8526
	    mountPointPath:(items at:2)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8527
	    deviceOrRemotePath:(items at:1)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8528
	    fsType:(items at:3)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8529
	    attributeString:(items at:4)).
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8530
	entries add:mountInfo
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8531
    ].
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8532
    ^ entries
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8533
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8534
    "
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8535
     OperatingSystem mountPointsFromProcFS
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8536
    "
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8537
!
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8538
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8539
osProcessStatusClass
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8540
    ^ OSProcessStatus
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8541
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8542
    "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
  8543
! !
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8544
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8545
!UnixOperatingSystem class methodsFor:'shared memory access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8546
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8547
shmAttach:id address:addr flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8548
    "low level entry to shmat()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8549
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8550
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8551
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8552
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8553
    void *address, *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8554
    int shmflg, shmid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8555
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8556
    if (__isSmallInteger(addr)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8557
     && __bothSmallInteger(flags, id)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8558
	shmaddr = (void *) __intVal(addr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8559
	shmflg = __intVal(flags);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8560
	shmid = __intVal(id);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8561
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8562
	address = shmat(shmid, shmaddr, shmflg);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8563
	if (address != (void *)-1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8564
	    RETURN (__MKEXTERNALBYTES(addr));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8565
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8566
	@global(LastErrorNumber) = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8567
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8568
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8569
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8570
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8571
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8572
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8573
    "Modified: 22.4.1996 / 13:15:12 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8574
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8575
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8576
shmDetach:addr
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8577
    "low level entry to shmdt()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8578
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8579
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8580
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8581
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8582
    void *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8583
    int rslt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8584
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8585
    if (__isSmallInteger(addr)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8586
	shmaddr = (void *) __intVal(addr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8587
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8588
	rslt = shmdt(shmaddr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8589
	if (rslt != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8590
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8591
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8592
	@global(LastErrorNumber) = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8593
	RETURN (false);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8594
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8595
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8596
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8597
    ^ self primitiveFailed
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
    "Modified: 22.4.1996 / 13:15:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8600
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8601
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8602
shmGet:key size:size flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8603
    "low level entry to shmget()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8604
     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
  8605
     - use the provided wrapper class SharedExternalBytes instead."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8606
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8607
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8608
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8609
    if (__bothSmallInteger(key, size)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8610
     && __isSmallInteger(flags)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8611
	int rslt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8612
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8613
	rslt = shmget(__intVal(key), __intVal(size), __intVal(flags));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8614
	if (rslt != -1) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8615
	    RETURN (__mkSmallInteger(rslt));
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8616
	}
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8617
	@global(LastErrorNumber) = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8618
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8619
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8620
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8621
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8622
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8623
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8624
    "Modified: 22.4.1996 / 13:14:46 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8625
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8626
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8627
!UnixOperatingSystem class methodsFor:'socket creation'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8628
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8629
socketAccessor
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8630
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8631
    ^ SocketHandle
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8632
!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8633
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8634
socketWithDomain:domainArg type:typeArg protocol:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8635
    "set up socket with domain, type and protocol number.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8636
     This is a low level entry; no binding, listening or connect
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8637
     is done. Both arguments must be symbols from one of
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8638
     #inet,#unix, #appletalk, #x25 .. and #stream, #datagram, #raw resp."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8639
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8640
    ^ SocketHandle new domain:domainArg type:typeArg protocol:protocolArg
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8641
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8642
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8643
!UnixOperatingSystem class methodsFor:'time and date'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8644
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8645
computeOSTimeFromUTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8646
    "return the OS-dependent time for the given time and day.
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8647
     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
  8648
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8649
    ^ self
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8650
	computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis utc:true
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8651
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8652
    "
5639
2e750f87b419 Fix UTC Time handling when daylight saving time applies.
Stefan Vogel <sv@exept.de>
parents: 5625
diff changeset
  8653
     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
  8654
     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
  8655
     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
  8656
     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
  8657
    "
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8658
!
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8659
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8660
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8661
    "return the OS-dependent time for the given time and day.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8662
     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
  8663
     any daylight saving adjustings."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8664
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8665
    ^ self
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8666
	computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis utc:false
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8667
    "
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8668
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8669
    "
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8670
!
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8671
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8672
computeOSTimeFromYear:y month:m day:d hour:h minute:min seconds:s millis:millis utc:utcBoolean
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8673
    "return the OS-dependent time for the given time and day.
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8674
     If utcBoolean is true, the arguments are assumed to be in UTC;
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8675
     otherwise, in localtime including any daylight saving adjustings."
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8676
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8677
    |osSeconds|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8678
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8679
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8680
    struct tm tm;
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8681
    time_t t;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8682
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8683
    if (__bothSmallInteger(y, m)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8684
     && __bothSmallInteger(d, h)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8685
     && __bothSmallInteger(min, s)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8686
	tm.tm_hour = __intVal(h);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8687
	tm.tm_min = __intVal(min);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8688
	tm.tm_sec = __intVal(s);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8689
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8690
	tm.tm_year = __intVal(y) - 1900;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8691
	tm.tm_mon = __intVal(m) - 1;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8692
	tm.tm_mday = __intVal(d);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8693
	tm.tm_isdst = -1;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8694
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8695
	t = mktime(&tm);                        /* mktime() interprets tm as localtime */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8696
	if ((INT)t != -1) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8697
	    if (utcBoolean == true) {           /* convert to utc time */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8698
		t = (INT)t - TIMEZONE(&tm);     /* TIMZONE = seconds westward from 0 */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8699
	    }
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8700
	    osSeconds = __MKINT((INT)t);        /* be careful, t can be negative at the start of the epoch ! */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8701
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8702
    }
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
    osSeconds notNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8705
	^ osSeconds * 1000 + millis
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8706
    ].
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8707
    ^ TimeConversionError raiseRequest.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8708
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8709
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8710
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0 utc:true
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8711
     OperatingSystem computeOSTimeFromYear:1970 month:1 day:1 hour:0 minute:0 seconds:0 millis:0 utc:false
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8712
    "
3496
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
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8715
getMicrosecondTime
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8716
    "This returns the microsecond timers value - if available.
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8717
     On some machines, times with this precision may not be available,
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8718
     on those, the returned value may be rounded towards some internal
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8719
     clock resolution value."
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8720
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8721
    |seconds micros error|
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8722
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8723
%{
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8724
    unsigned long _secs, _micros;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8725
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
  8726
#if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8727
    struct timespec ts;
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8728
    static int has_clock_gettime = 1;
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8729
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8730
    if (has_clock_gettime) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8731
	if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8732
	    _secs = ts.tv_sec;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8733
	    _micros  = ts.tv_nsec / 1000;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8734
	    goto out;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8735
	} else {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8736
	    /*
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8737
	     * clock_gettime is not implemented in the kernel
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8738
	     * fall through to alternative implementation
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8739
	     */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8740
	    has_clock_gettime = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8741
	}
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8742
    }
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8743
#endif
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8744
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8745
#if defined(HAS_GETTIMEOFDAY)
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8746
    struct timeval tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8747
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8748
    gettimeofday(&tb, NULL /* &tzb */);
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8749
    if (tb.tv_usec >= (1000000)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8750
	error = @symbol(bad);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8751
	goto err;
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8752
    }
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8753
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8754
    _secs = tb.tv_sec;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8755
    _micros  = tb.tv_usec;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8756
#endif
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8757
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8758
out:
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8759
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8760
#if __POINTER_SIZE__ == 8
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8761
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8762
	unsigned INT rslt;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8763
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8764
	rslt = (unsigned INT)_secs * 1000000 + _micros;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8765
	RETURN (__MKUINT(rslt));
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8766
    }
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8767
#else
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8768
# ifdef HAS_LONGLONG
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8769
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8770
	unsigned long long rslt;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8771
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8772
	rslt = (unsigned long long)_secs * 1000000 + _micros;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8773
	RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8774
    }
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8775
# else
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8776
    seconds = __MKUINT(_secs);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8777
    micros = __MKUINT(_micros);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8778
# endif /* long long */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8779
#endif /* __POINTER_SIZE__ == 8 */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8780
err:;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8781
%}.
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8782
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8783
    seconds notNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8784
	^ (seconds * 1000000) + micros
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8785
    ].
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8786
    error isNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8787
	^ self getMillisecondTime * 1000
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8788
    ].
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8789
    self primitiveFailed:error.
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8790
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8791
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8792
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8793
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8794
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8795
!
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8796
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8797
getMillisecondTime
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8798
    "Return the millisecond timers value.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8799
     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
  8800
     LargeInteger arithmetic when doing timeouts and delays.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8801
     Since this value is wrapping around in regular intervals, this can only be used for
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8802
     short relative time deltas.
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8803
     Use the XXXmillisecondTime:-methods to compare and add time deltas - these know about the wrap.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8804
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8805
     BAD DESIGN:
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8806
	This should be changed to return some instance of RelativeTime,
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8807
	and these computations moved there.
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8808
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8809
     Don't use this method in application code since it is an internal (private)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8810
     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
  8811
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8812
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8813
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8814
13801
6e060254590d changed: #getMillisecondTime
Stefan Vogel <sv@exept.de>
parents: 13778
diff changeset
  8815
    unsigned long t = 0;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8816
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
  8817
#if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8818
    static has_clock_gettime = 1;
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8819
    struct timespec ts;
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8820
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8821
    if (has_clock_gettime) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8822
	if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8823
	    t = ts.tv_sec*1000 + ts.tv_nsec/1000000;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8824
	    goto out;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8825
	} else {
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8826
	    /*
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8827
	     * clock_gettime is not implemented in the kernel
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8828
	     * fall through to alternative implementation
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8829
	     */
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8830
	    has_clock_gettime = 0;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8831
	}
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8832
    }
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8833
#endif /*  _POSIX_MONOTONIC_CLOCK */
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8834
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8835
#if defined(_SC_CLK_TCK)
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8836
/*
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8837
 * We prefer times here, since it is monotonic and immune to clock changes
8601
bf2b973a9a0e unimpl clock-syscall handling
Claus Gittinger <cg@exept.de>
parents: 8599
diff changeset
  8838
 * but: it has less precision!
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8839
 */
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8840
# include <sys/times.h>
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8841
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8842
    static int millisecondsPerTick;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8843
    clock_t ticks;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8844
    struct tms tb;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8845
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8846
    if (!millisecondsPerTick) {
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8847
	int ticksPerSecond = sysconf(_SC_CLK_TCK);
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8848
	if (ticksPerSecond <= 0)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8849
	    goto err;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8850
	if (ticksPerSecond > 1000)
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8851
	    goto err;
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8852
	millisecondsPerTick = 1000 / ticksPerSecond;
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8853
/*
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8854
printf("milliSecondsPerTick: %d\n", millisecondsPerTick);
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8855
*/
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8856
    }
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8857
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8858
    ticks = times(&tb);
8672
f93733514fec Fix times() systemcall overflow into negative values (onl Solaris 9).
Stefan Vogel <sv@exept.de>
parents: 8618
diff changeset
  8859
    if (ticks == -1)
14657
6610eb2df25c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 14598
diff changeset
  8860
	goto err;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8861
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8862
    t = ticks * millisecondsPerTick;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8863
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8864
#else /* !times */
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8865
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8866
    /* assume HAS_GETTIMEOFDAY
13801
6e060254590d changed: #getMillisecondTime
Stefan Vogel <sv@exept.de>
parents: 13778
diff changeset
  8867
     * - will result in a linkage error if not fixed.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8868
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8869
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8870
    struct timeval tb;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8871
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8872
    gettimeofday(&tb, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8873
    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
  8874
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8875
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8876
out:
12832
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
  8877
    RETURN ( __mkSmallInteger(t & 0x1FFFFFFF) );
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8878
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8879
err:;
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8880
%}.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8881
    self primitiveFailed
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8882
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8883
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8884
    "
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8885
      self getMillisecondTime
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8886
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8887
      Transcript showCR:(OperatingSystem getMillisecondTime).
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8888
      Transcript showCR:(OperatingSystem getMillisecondTime).
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8889
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8890
!
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
getOSTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8893
    "This returns the OS time.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8894
     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
  8895
     different OS's - some return the number of millis since jan, 1st 1970;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8896
     others since 1900. The Time classes are prepared for this, and
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8897
     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
  8898
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8899
     Don't use this method in application code since it is an internal (private)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8900
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8901
     or use instances of Time, Date or Timestamp to work with."
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8902
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8903
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8904
    |seconds millis|
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8905
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8906
%{
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8907
    unsigned long _secs, _millis;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8908
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8909
#if !defined(HAS_GETTIMEOFDAY)
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8910
# if defined(HAS_FTIME)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8911
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8912
	struct timeb timebuffer;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8913
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8914
	ftime(&timebuffer);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8915
	_secs = timebuffer.time;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8916
	_millis = timebuffer.millitm;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8917
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8918
#   define HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8919
# endif /* HAS_FTIME */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8920
#endif /* no HAS_GETTIMEOFDAY */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8921
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8922
#ifndef HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8923
    /*
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8924
     * use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8925
     * 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
  8926
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8927
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8928
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8929
	/*
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8930
	 * bsd time
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8931
	 */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8932
	struct timeval tb;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8933
	/* struct timezone tzb; */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8934
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8935
	gettimeofday(&tb, NULL /* &tzb */);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8936
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8937
	_secs = tb.tv_sec;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8938
	_millis = tb.tv_usec / 1000;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8939
    }
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8940
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8941
8901
824a89d0b5c7 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 8883
diff changeset
  8942
#if __POINTER_SIZE__ == 8
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8943
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8944
	unsigned INT rslt;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8945
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8946
	rslt = (unsigned INT)_secs * 1000 + _millis;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8947
	RETURN (__MKUINT(rslt));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8948
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8949
#else
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8950
# ifdef HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8951
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8952
	unsigned long long rslt;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8953
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8954
	rslt = (unsigned long long)_secs * 1000 + _millis;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8955
	RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8956
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8957
# else
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8958
    seconds = __MKUINT(_secs);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8959
    millis = __MKUINT(_millis);
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8960
# endif /* long long */
8901
824a89d0b5c7 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 8883
diff changeset
  8961
#endif /* __POINTER_SIZE__ == 8 */
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8962
%}.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8963
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8964
    seconds notNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  8965
	^ (seconds * 1000) + millis
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8966
    ].
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8967
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8968
    self primitiveFailed.
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8969
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8970
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8971
    "
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8972
     OperatingSystem getOSTime printCR.
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8973
     Delay waitForSeconds:0.2.
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8974
     OperatingSystem getOSTime printCR.
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8975
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8976
!
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8977
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8978
sleep:numberOfSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8979
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8980
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8981
    "cease ANY action for some time. This suspends the whole smalltalk
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8982
     (unix-) process for some time if running threadless;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8983
     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
  8984
     only block until the next clock tick and return with the next
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8985
     timer interrupt.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8986
     Use either OperatingSystem>>millisecondDelay: (which makes all
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8987
     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
  8988
     only the calling thread sleep)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8989
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8990
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8991
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8992
    if (__isSmallInteger(numberOfSeconds)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8993
	sleep(__intVal(numberOfSeconds));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8994
	RETURN ( self );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8995
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8996
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8997
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8998
     argument not integer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8999
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9000
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9002
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9003
     OperatingSystem sleep:2
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9004
    "
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9005
!
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9006
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  9007
timeInfoFromSeconds:osSeconds milliseconds:osMilliseconds localTime:isLocalTime
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9008
    "return a timeInfo structure containing values for the given
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9009
     OS-second value.
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9010
     An internal helper"
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9011
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9012
    |year month day hours minutes seconds utcOffset
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9013
     dst yDay wDay info|
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9014
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9015
%{
10285
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9016
    struct tm tmValue;
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9017
    time_t tt;
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9018
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9019
    tt = __longIntVal(osSeconds);
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  9020
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  9021
    /* try cache */
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  9022
    {
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9023
	OBJ lastSeconds, lastTimeInfo;
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9024
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9025
	lastSeconds = @global(LastTimeInfoSeconds);
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9026
	if (lastSeconds
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9027
	 && (__longIntVal(lastSeconds) == tt)
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9028
	 && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9029
	 && (@global(LastTimeInfoIsLocal) == isLocalTime)
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9030
	) {
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9031
	    lastTimeInfo = @global(LastTimeInfo);
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9032
	    if (lastTimeInfo != nil) {
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9033
		RETURN (lastTimeInfo);
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9034
	    }
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9035
	}
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9036
    }
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9037
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9038
    if (isLocalTime == true) {
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9039
	localtime_r(&tt, &tmValue);
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9040
    } else {
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9041
	gmtime_r(&tt, &tmValue);
10285
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9042
    }
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9043
    hours = __mkSmallInteger(tmValue.tm_hour);
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9044
    minutes = __mkSmallInteger(tmValue.tm_min);
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9045
    seconds = __mkSmallInteger(tmValue.tm_sec);
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9046
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9047
    year = __mkSmallInteger(tmValue.tm_year + 1900);
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9048
    month = __mkSmallInteger(tmValue.tm_mon + 1);
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9049
    day = __mkSmallInteger(tmValue.tm_mday);
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9050
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9051
    yDay = __mkSmallInteger(tmValue.tm_yday+1);
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9052
    wDay = __mkSmallInteger(tmValue.tm_wday == 0 ? 7 : tmValue.tm_wday);
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9053
    utcOffset = __mkSmallInteger(TIMEZONE(&tmValue));
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  9054
    dst = (tmValue.tm_isdst == 0 ? false : true);
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9055
%}.
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  9056
    info := self timeInfoClass new.
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9057
    info
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9058
	year:year
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9059
	month:month
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9060
	day:day
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9061
	hours:hours
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9062
	minutes:minutes
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9063
	seconds:seconds
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9064
	milliseconds:osMilliseconds
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9065
	utcOffset:utcOffset
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9066
	dst:dst
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9067
	dayInYear:yDay
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  9068
	dayInWeek:wDay.
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  9069
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  9070
%{
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9071
    @global(LastTimeInfo) = info;                       __GSTORE(info);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9072
    @global(LastTimeInfoSeconds) = osSeconds;           __GSTORE(osSeconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9073
    @global(LastTimeInfoMilliseconds) = osMilliseconds; __GSTORE(osMilliseconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9074
    @global(LastTimeInfoIsLocal) = isLocalTime;         __GSTORE(isLocalTime);
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  9075
%}.
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  9076
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9077
    ^ info
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9078
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9079
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9080
     OperatingSystem timeInfoFromSeconds:0 localTime:false
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9081
     OperatingSystem timeInfoFromSeconds:3600 localTime:false
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  9082
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9083
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9084
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9085
!UnixOperatingSystem class methodsFor:'users & groups'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9086
15802
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9087
getDesktopDirectory
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9088
    "{ Pragma: +optSpace }"
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9089
    "return the name of the user's desktop directory."
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9090
    
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9091
    |home desktop|
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9092
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9093
    home := self getHomeDirectory.
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9094
    desktop := home,'/Desktop'.
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9095
    desktop asFilename exists ifTrue:[^ desktop].
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9096
    ^ home.
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9097
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9098
    "
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9099
     OperatingSystem getDesktopDirectory
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9100
    "
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9101
!
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
  9102
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9103
getEffectiveGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9104
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9105
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9106
    "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
  9107
     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
  9108
     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
  9109
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9110
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9111
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9112
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9113
    uid = getegid();
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9114
    RETURN ( __mkSmallInteger(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9115
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9116
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9117
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9118
     OperatingSystem getEffectiveGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9119
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9120
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9121
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9122
getEffectiveUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9123
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9124
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9125
    "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
  9126
     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
  9127
     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
  9128
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9129
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9130
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9131
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9132
    uid = geteuid();
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9133
    RETURN ( __mkSmallInteger(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9134
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9135
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9136
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9137
     OperatingSystem getEffectiveUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9138
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9139
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9140
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9141
getFullUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9142
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9143
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9144
    "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
  9145
     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
  9146
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9147
    |info gecos|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9148
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9149
    info := self userInfoOf:userID.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9150
    (info notNil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9151
    and:[info includesKey:#gecos]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9152
	gecos := info at:#gecos.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9153
	(gecos includes:$,) ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9154
	    ^ gecos copyTo:(gecos indexOf:$,) - 1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9155
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9156
	^ gecos
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9157
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9158
    ^ self getUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9159
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9160
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9161
     OperatingSystem getFullUserNameFromID:0
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9162
     OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9163
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9164
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9165
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9166
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9167
    "Modified: 15.7.1996 / 12:44:21 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9168
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9169
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9170
getGroupID
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  9171
    "return the current users (thats you) numeric group id"
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  9172
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9173
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9174
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9175
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9176
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9177
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  9178
    RETURN ( __mkSmallInteger(getgid()) );
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  9179
%}.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9180
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9181
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9182
     OperatingSystem getGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9183
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9184
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9185
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9186
getGroupNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9187
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9188
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9189
    "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
  9190
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9191
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9192
    struct group *g;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9193
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9194
    if (__isSmallInteger(aNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9195
	g = getgrgid(__intVal(aNumber));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9196
	if (g) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9197
	    RETURN ( __MKSTRING(g->gr_name) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9198
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9199
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9200
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9201
    ^ '???'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9202
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9203
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9204
     OperatingSystem getGroupNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9205
     OperatingSystem getGroupNameFromID:10
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9206
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9207
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9208
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9209
getHomeDirectory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9210
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9211
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9212
    "return the name of the users home directory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9213
     (i.e. yours)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9214
14575
c696ca8d05bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14568
diff changeset
  9215
    ^ self decodePath:(self getEnvironment:'HOME')
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9216
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9217
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9218
     OperatingSystem getHomeDirectory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9219
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9220
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9221
    "Modified: 24.1.1997 / 11:32:13 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9222
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9223
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9224
getLoginName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9225
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9226
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9227
    "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
  9228
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9229
%{  /* NOCONTEXT */
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  9230
    static char cachedName[128];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9231
    static firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9232
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9233
    extern char *getlogin();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9234
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9235
    char *name = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9236
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9237
    if (firstCall) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9238
	/*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9239
	 * try a few common environment variables ...
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9240
	 */
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9241
	name = getenv("LOGNAME");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9242
	if (! name || (name[0] == 0)) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9243
	    name = getlogin();
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9244
	    if (! name || (name[0] == 0) ) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9245
		name = getenv("LOGIN");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9246
		if (! name || (name[0] == 0) ) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9247
		    name = getenv("USER");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9248
		}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9249
	    }
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9250
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9251
	if (name && (strlen(name) < sizeof(cachedName))) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9252
	    strcpy(cachedName, name);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9253
	    firstCall = 0;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9254
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9255
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9256
	name = cachedName;
7767
1ee3973efa3a changed order getting login name in getLoginName
Michael Beyl <mb@exept.de>
parents: 7766
diff changeset
  9257
    }
1ee3973efa3a changed order getting login name in getLoginName
Michael Beyl <mb@exept.de>
parents: 7766
diff changeset
  9258
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9259
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9260
     * nope - I really font know who you are.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9261
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9262
    if (! name || (name[0] == 0) ) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9263
	name = "you";
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9264
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9265
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9266
    RETURN ( __MKSTRING(name) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9267
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9268
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9269
     OperatingSystem getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9270
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9271
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9272
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9273
getUserID
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  9274
    "return the current users (thats you) numeric user id"
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  9275
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9276
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9277
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9278
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9279
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  9280
    RETURN ( __mkSmallInteger(getuid()) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9281
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9282
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9283
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9284
     OperatingSystem getUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9285
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9286
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9287
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9288
getUserNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9289
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9290
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9291
    "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
  9292
     This is the login name, not the fullName."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9293
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9294
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9295
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9296
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9297
    struct passwd *p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9298
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9299
    if (__isSmallInteger(aNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9300
	p = getpwuid(__intVal(aNumber));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9301
	if (p) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9302
	    RETURN ( __MKSTRING(p->pw_name) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9303
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9304
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9305
#endif /* unix-like */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9306
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9307
    aNumber == self getUserID ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9308
	^ self getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9309
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9310
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9311
    ^ '? (' , aNumber printString , ')'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9312
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9313
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9314
     OperatingSystem getUserNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9315
     OperatingSystem getUserNameFromID:100
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9316
     OperatingSystem getUserNameFromID:9991
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9317
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9318
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9319
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9320
primUserInfoOf:aNameOrID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9321
    "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
  9322
     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
  9323
     Notice, that not all systems provide (all of) this info;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9324
     DOS systems return nothing;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9325
     non-SYSV4 systems have no age/comment.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9326
     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
  9327
     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
  9328
     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
  9329
     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
  9330
     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
  9331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9332
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9333
%{ /* UNLIMITEDSTACK */  /* Don't know whether NIS, LDAP or whatever is consulted */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9334
#if !defined(NO_PWD)
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9335
    struct passwd *result = 0;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9336
    int ret;
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9337
    int idx = 0;
12870
a2e6de216c3b changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12868
diff changeset
  9338
    OBJ returnArray;
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9339
    OBJ tmp;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9340
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9341
#if defined(_POSIX_SOURCE)
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9342
    char buf[4096];
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9343
    struct passwd pwd;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9344
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9345
    if (__isStringLike(aNameOrID)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9346
	getpwnam_r(__stringVal(aNameOrID), &pwd, buf, sizeof(buf), &result);
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9347
    } else if (__isSmallInteger(aNameOrID)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9348
	getpwuid_r(__intVal(aNameOrID), &pwd, buf, sizeof(buf), &result);
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9349
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9350
#else
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9351
    if (__isStringLike(aNameOrID)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9352
	result = getpwnam(__stringVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9353
    } else if (__isSmallInteger(aNameOrID)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9354
	result = getpwuid(__intVal(aNameOrID));
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9355
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9356
#endif /* ! _POSIX_SOURCE */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9357
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9358
    if (result) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9359
	returnArray = __ARRAY_NEW_INT(20);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9360
	__PROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9361
	tmp = __MKSTRING(result->pw_name);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9362
	__UNPROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9363
	__arrayVal(returnArray)[idx++] = @symbol(name);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9364
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9365
#  ifndef NO_PWD_PASSWD
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9366
	__PROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9367
	tmp = __MKSTRING(result->pw_passwd);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9368
	__UNPROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9369
	__arrayVal(returnArray)[idx++] = @symbol(passwd);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9370
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9371
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9372
#  ifdef SYSV4
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9373
	__PROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9374
	tmp = __MKSTRING(result->pw_age);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9375
	__UNPROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9376
	__arrayVal(returnArray)[idx++] = @symbol(age);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9377
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9378
	__PROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9379
	tmp = __MKSTRING(result->pw_comment);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9380
	__UNPROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9381
	__arrayVal(returnArray)[idx++] = @symbol(comment);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9382
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9383
#  endif
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9384
	__PROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9385
	tmp = __MKSTRING(result->pw_dir);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9386
	__UNPROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9387
	__arrayVal(returnArray)[idx++] = @symbol(dir);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9388
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9389
#  ifndef NO_PWD_GECOS
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9390
	__PROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9391
	tmp = __MKSTRING(result->pw_gecos);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9392
	__UNPROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9393
	__arrayVal(returnArray)[idx++] = @symbol(gecos);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9394
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9395
#  endif
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9396
	__PROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9397
	tmp = __MKSTRING(result->pw_shell);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9398
	 __UNPROTECT__(returnArray);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9399
	__arrayVal(returnArray)[idx++] = @symbol(shell);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9400
	__arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9401
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9402
	__arrayVal(returnArray)[idx++] = @symbol(uid);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9403
	__arrayVal(returnArray)[idx++] = __mkSmallInteger(result->pw_uid);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9404
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9405
	__arrayVal(returnArray)[idx++] = @symbol(gid);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9406
	__arrayVal(returnArray)[idx++] = __mkSmallInteger(result->pw_gid);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9407
	RETURN(returnArray);
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9408
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9409
# endif /* ! NO_PWD */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9410
%}.
12870
a2e6de216c3b changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12868
diff changeset
  9411
    ^ nil
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9412
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9413
    "
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9414
     OperatingSystem primUserInfoOf:'root'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9415
     OperatingSystem primUserInfoOf:1
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9416
     OperatingSystem primUserInfoOf:'cg'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9417
     OperatingSystem primUserInfoOf:'fooBar'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9418
     OperatingSystem primUserInfoOf:(OperatingSystem getUserID)
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9419
    "
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9420
!
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9421
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9422
userInfoOf:aNameOrID
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9423
    "{ Pragma: +optSpace }"
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9424
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9425
    "return a dictionary filled with userinfo. The argument can be either
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9426
     a string with the users name or its numeric id.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9427
     Notice, that not all systems provide (all of) this info;
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9428
     DOS systems return nothing;
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9429
     non-SYSV4 systems have no age/comment.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9430
     Portable applications may want to check the systemType and NOT depend
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9431
     on all keys to be present in the returned dictionary.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9432
     Another notice: on some systems (SYSV4), the gecos field includes multiple
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9433
     entries (i.e. not just the name), separated by commas. You may want to
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9434
     extract any substring, up to the first comma to get the real life name."
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9435
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9436
    |infoArray info name dir|
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9437
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9438
    infoArray := self primUserInfoOf:aNameOrID.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9439
    info := IdentityDictionary new.
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9440
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9441
    infoArray notNil ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9442
	infoArray pairWiseDo:[:key :value|
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9443
	    key notNil ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9444
		info at:key put:value.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9445
		key == #name ifTrue:[name := value].
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9446
		key == #dir  ifTrue:[dir := value].
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9447
	    ].
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9448
	].
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9449
    ].
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9450
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9451
    name isNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9452
	info at:#name put:#unknown
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9453
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9454
    dir isNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9455
	aNameOrID == self getUserID ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9456
	    info at:#dir put:self getHomeDirectory
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
  9457
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9458
    ].
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9459
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9460
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9461
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9462
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9463
     OperatingSystem userInfoOf:'root'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9464
     OperatingSystem userInfoOf:1
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9465
     OperatingSystem userInfoOf:'cg'
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9466
     OperatingSystem userInfoOf:'fooBar'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9467
     OperatingSystem userInfoOf:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9468
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9469
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9470
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9471
!UnixOperatingSystem class methodsFor:'waiting for events'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9472
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9473
blockingChildProcessWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9474
     "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
  9475
      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
  9476
      a subprocesses status (to avoid blocking)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9477
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9478
%{ /*NOCONTEXT*/
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  9479
#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9480
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9481
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9482
    RETURN(true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9483
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9484
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9485
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9486
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9487
childProcessWait:blocking pid:pidToWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9488
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9489
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9490
    "get status changes from child processes.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9491
     Return an OSProcessStatus or nil, if no process has terminated.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9492
     If blocking is true, we wait until a process changed state,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9493
     otherwise we return immediately.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9494
     Note that win32 needs to know the HANDLE of the process on which
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9495
     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
  9496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9497
    |pid status code core|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9498
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9499
    int p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9500
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9501
#if defined(HAS_WAITPID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9502
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9503
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9504
#   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
  9505
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9506
#else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9507
# if defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9508
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9509
    union wait s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9510
#   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
  9511
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9512
# 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
  9513
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9514
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9515
#   define __WAIT      wait(&s)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9516
#   define __BLOCKING_WAIT__ 1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9517
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9518
    if (blocking != true) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9519
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9520
	 * We do not support nonBlocking waits, so signal an error
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9521
	 * Sorry about the goto, but with all these ifdefs ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9522
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9523
	goto done;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9524
    }
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9525
# endif /*!HAS_WAIT3*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9526
#endif  /*!HAS_WAITPID*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9527
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9528
#if !defined(WIFEXITED)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9529
# define WIFEXITED(stat)      (((int)((stat)&0377))==0)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9530
# 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
  9531
# 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
  9532
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9533
# define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9534
# define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9535
# define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9536
#endif /*!WIFEXITED*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9537
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9538
#if !defined(WCOREDUMP)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9539
   /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9540
    * 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
  9541
    */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9542
# if defined(HAS_WAIT3)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9543
#  define WCOREDUMP(status)    (((union __wait*)&(status))->__w_coredump)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9544
# else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9545
#  define WCOREDUMP(status)    ((int)(((status)>>8)&0200))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9546
# endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9547
#endif /*!WCOREDUMP*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9548
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9549
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9550
    __BEGIN_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9551
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9552
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9553
    do {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9554
	p = __WAIT;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9555
    } while (p == -1 && errno == EINTR);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9556
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9557
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9558
    __END_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9559
#  undef __BLOCKING_WAIT__
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9560
#endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9561
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9562
#undef __WAIT
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9563
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9564
    if (p == 0)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9565
	RETURN(nil)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9566
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9567
    if (p == -1) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9568
	if (errno == ECHILD)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9569
	    RETURN(nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9570
    } else {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9571
	pid = __mkSmallInteger(p);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9572
	if (WIFEXITED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9573
	    status = @symbol(exit);
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9574
	    code = __mkSmallInteger(WEXITSTATUS(s));
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9575
	    core = WCOREDUMP(s) ? true : false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9576
	} else if (WIFSIGNALED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9577
	    status = @symbol(signal);
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9578
	    code = __mkSmallInteger(WTERMSIG(s));
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9579
	} else if (WIFSTOPPED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9580
	    status = @symbol(stop);
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9581
	    code = __mkSmallInteger(WSTOPSIG(s));
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9582
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9583
#if defined(WIFCONTINUED)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9584
	else if (WIFCONTINUED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9585
	    status = @symbol(continue);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9586
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9587
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9588
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9589
done: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9590
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9591
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9592
    (status isNil or:[pid isNil]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9593
	^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9594
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9595
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9596
"/ 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
  9597
"/ show:' code: '; show:code; show:' core:'; showCR:core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9599
    ^ 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
  9600
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9601
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9602
     OperatingSystem childProcessWait:false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9603
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9604
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9605
    "Created: 5.1.1996 / 16:39:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9606
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9607
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9608
isBlockingOn:fd
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9609
    "{ Pragma: +optSpace }"
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9610
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9611
    "return the blocking attribute - if set (which is the default)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9612
     a read on the fileDescriptor will block until data is available.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9613
     If clear, a read operation will immediately return with a value nil.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9614
     Also affects write operations, which may perform partial writes when
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9615
     blocking is off"
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9616
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9617
%{  /* NOCONTEXT */
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9618
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9619
    int flags;
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9620
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9621
#if defined(F_GETFL) && defined(F_SETFL)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9622
# undef DELAY_FLAG
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9623
# if defined(O_NONBLOCK)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9624
#  define DELAY_FLAG O_NONBLOCK
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9625
# elif defined(O_NDELAY)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9626
#  define DELAY_FLAG O_NDELAY
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9627
# elif defined(FNDELAY)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9628
#  define DELAY_FLAG FNDELAY
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9629
# endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9630
# if defined(DELAY_FLAG)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9631
    if (__isSmallInteger(fd)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9632
	int f = __intVal(fd);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9633
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9634
	flags = fcntl(f, F_GETFL, 0);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9635
	RETURN ((flags & DELAY_FLAG) ? false : true );
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9636
    }
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9637
#  undef DELAY_FLAG
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9638
# endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9639
#endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9640
%}.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9641
    "
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9642
     fd argument not integer or bad return code
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9643
    "
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9644
    ^ self primitiveFailed
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9645
!
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9646
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9647
numAvailableForReadOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9648
    "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
  9649
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9650
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9651
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9652
     * 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
  9653
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9654
# if 0 && defined(FIONREAD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9655
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9656
	int n;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9657
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9658
	if (__isSmallInteger(fd)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9659
	    if (ioctl(__intVal(fd), FIONREAD, &n) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9660
		RETURN (__MKINT(n));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9661
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9662
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9663
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9664
# endif /* FIONREAD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9665
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9666
    ^ (self readCheck:fd) ifTrue:[1] ifFalse:[0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9667
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9668
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9669
readCheck:fd
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9670
    "return true, if data is available on a filedescriptor
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9671
     (i.e. read is possible without blocking).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9672
     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
  9673
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9674
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9675
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9676
     * 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
  9677
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9678
#if 0 && defined(FIONREAD)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9679
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9680
	int result = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9681
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9682
	if (ioctl(__smallIntegerVal(fd), FIONREAD, &result) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9683
	    RETURN(result > 0 ? true : false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9684
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9685
    }
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9686
#endif /* FIONREAD */
3496
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
    ^ super readCheck:fd
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
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9692
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9693
	readableInto:readableResultFdArray writableInto:writableResultFdArray
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9694
	exceptionInto:exceptionResultFdArray
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9695
	withTimeOut:millis
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9696
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9697
    "wait for any fd in readFdArray (an Array of integers) to become ready for reading,
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9698
     writeFdArray to become ready for writing,
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9699
     or exceptFdArray to arrive exceptional data (i.e. out-of-band data).
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9700
     Timeout after t milliseconds or - if the timeout time is 0 - immediately..
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9701
     Empty fd-sets will always wait. Zero time can be used to poll file-
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9702
     descriptors (i.e. to check if I/O possible without blocking).
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9703
     The corresponding filedescriptors which are ready are returned in readableResultFdArray,
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9704
     writableResultFdArray and exceptionResultFdArray respectively.
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9705
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9706
     Return the (overall) number of selected filedescriptors.
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9707
     readableResultFdArray, writableResultFdArray and exceptionResultFdArray will
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9708
     get a nil-value stored into the slot after the last valid fileDescriptor;
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9709
     Thus, the caller can simply scan these arrays upTo the end or a nil value."
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9710
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9711
%{
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9712
    fd_set rset, wset, eset;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9713
    struct timeval wt, et;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9714
    int maxF;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9715
    INT t;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9716
    int ret;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9717
    int cntR = 0, cntW = 0, cntE = 0;
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9718
    int resultSizeReadable = 0, resultSizeWritable = 0, resultSizeException = 0;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9719
    int numFds = 0;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9720
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9721
    if (!__isSmallInteger(millis)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9722
	goto fail;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9723
    }
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9724
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9725
    if (readableResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9726
	if (! __isArrayLike(readableResultFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9727
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9728
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9729
	resultSizeReadable = __arraySize(readableResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9730
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9731
    if (writableResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9732
	if (! __isArrayLike(writableResultFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9733
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9734
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9735
	resultSizeWritable = __arraySize(writableResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9736
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9737
    if (exceptionResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9738
	if (! __isArrayLike(exceptionResultFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9739
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9740
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9741
	resultSizeException = __arraySize(exceptionResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9742
    }
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9743
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9744
    FD_ZERO(&rset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9745
    FD_ZERO(&wset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9746
    FD_ZERO(&eset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9747
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9748
    maxF = -1;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9749
    if (__isNonNilObject(readFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9750
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9751
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9752
	if (! __isArrayLike(readFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9753
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9754
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9755
	count = __arraySize(readFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9756
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9757
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9758
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9759
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9760
	    fd = __ArrayInstPtr(readFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9761
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9762
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9763
		    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9764
			fprintf(stderr, "OS [warning]: funny read-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9765
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9766
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9767
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9768
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9769
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9770
		    if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9771
			FD_SET(f, &rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9772
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9773
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9774
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9775
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9776
			    fprintf(stderr, "OS [warning]: huge read-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9777
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9778
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9779
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9780
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9781
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9782
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9783
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9784
    if (__isNonNilObject(writeFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9785
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9786
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9787
	if (! __isArrayLike(writeFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9788
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9789
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9790
	count = __arraySize(writeFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9791
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9792
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9793
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9794
	    fd = __ArrayInstPtr(writeFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9795
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9796
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9797
		    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9798
			fprintf(stderr, "OS [warning]: funny write-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9799
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9800
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9801
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9802
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9803
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9804
		    if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9805
			FD_SET(f, &wset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9806
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9807
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9808
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9809
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9810
			    fprintf(stderr, "OS [warning]: huge write-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9811
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9812
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9813
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9814
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9815
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9816
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9817
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9818
    if (__isNonNilObject(exceptFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9819
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9820
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9821
	if (! __isArrayLike(exceptFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9822
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9823
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9824
	count = __arraySize(exceptFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9825
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9826
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9827
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9828
	    fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9829
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9830
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9831
		    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9832
			fprintf(stderr, "OS [warning]: funny except-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9833
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9834
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9835
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9836
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9837
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9838
		    if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9839
			FD_SET(f, &eset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9840
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9841
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9842
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9843
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9844
			    fprintf(stderr, "OS [warning]: huge except-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9845
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9846
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9847
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9848
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9849
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9850
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9851
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9852
    t = __intVal(millis);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9853
    if (t) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9854
	wt.tv_sec = t / 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9855
	wt.tv_usec = (t % 1000) * 1000;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9856
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9857
	wt.tv_sec = wt.tv_usec = 0;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9858
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9859
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9860
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9861
     * make certain, that interrupt gets us out of the select
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9862
     * However, we must then care for moved objects.
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9863
     */
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9864
    __BEGIN_INTERRUPTABLE__
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9865
    errno = 0;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9866
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9867
    if (t == 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9868
	/*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9869
	 * if there is no timeout time, we can stay here interruptable.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9870
	 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9871
	do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9872
	    ret = select(maxF+1, &rset, &wset, &eset, &wt);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9873
	} while ((ret < 0) && (errno == EINTR));
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9874
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9875
	do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9876
	    ret = select(maxF+1, &rset, &wset, &eset, &wt);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9877
	    /*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9878
	     * for now: dont loop; if we did, we had to adjust the vt-timeval;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9879
	     * could otherwise stay in this loop forever ...
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9880
	     * Premature ret (before the time expired) must be handled by the caller.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9881
	     * A good solution is to update the wt-timeval and redo the select.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9882
	     */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9883
	} while (0 /* (ret < 0) && (errno == EINTR) */ );
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9884
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9885
    __END_INTERRUPTABLE__
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9886
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9887
    if (ret > 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9888
	OBJ *__resultR = __arrayVal(readableResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9889
	OBJ *__resultW = __arrayVal(writableResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9890
	OBJ *__resultE = __arrayVal(exceptionResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9891
	int i;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9892
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9893
	for (i=0; i <= maxF; i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9894
	    if (FD_ISSET(i, &rset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9895
		if (cntR < resultSizeReadable) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9896
		    __resultR[cntR] = __mkSmallInteger(i);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9897
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9898
		cntR++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9899
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9900
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9901
	    if (FD_ISSET(i, &wset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9902
		if (cntW < resultSizeWritable) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9903
		    __resultW[cntW] = __mkSmallInteger(i);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9904
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9905
		cntW++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9906
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9907
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9908
	    if (FD_ISSET(i, &eset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9909
		if (cntE < resultSizeException) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9910
		    __resultE[cntE] = __mkSmallInteger(i);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9911
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9912
		cntE++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9913
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9914
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9915
	/* add a delimiter */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9916
	if (cntR < resultSizeReadable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9917
	    __resultR[cntR] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9918
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9919
	if (cntW < resultSizeWritable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9920
	    __resultW[cntW] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9921
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9922
	if (cntE < resultSizeException) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9923
	    __resultE[cntE] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9924
	}
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9925
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9926
	RETURN (__mkSmallInteger(cntR+cntW+cntE));
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9927
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9928
	if (ret < 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9929
	    if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9930
		errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9931
		@global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9932
	    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9933
		if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9934
		    fprintf(stderr, "OS [info]: select errno = %d\n", errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9935
		}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9936
		@global(LastErrorNumber) = __mkSmallInteger(errno);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9937
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9938
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9939
	    @global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9940
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9941
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9942
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9943
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9944
     * Return 0 (no filedescriptor ready)
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9945
     */
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9946
    RETURN (__mkSmallInteger(0));
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9947
fail: ;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9948
%}.
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9949
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9950
     timeout argument not integer,
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9951
     or any fd-array nonNil and not an array
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9952
     or not supported by OS
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9953
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9954
    ^ self primitiveFailed
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9955
!
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9956
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9957
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9958
    "wait for any fd in readFdArray (an Array of integers) to become ready for reading,
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9959
     writeFdArray to become ready for writing,
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9960
     or exceptFdArray to arrive exceptional data (i.e. out-of-band data).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9961
     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
  9962
     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
  9963
     descriptors (i.e. to check if I/O possible without blocking).
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9964
     Return the first ready fd if I/O ok, nil if timed-out or interrupted."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9965
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9966
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9967
    fd_set rset, wset, eset;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9968
    struct timeval wt, et;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9969
    int f, maxF, i, lX, bX;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9970
    INT t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9971
    OBJ fd, retFd;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9972
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9973
    int count;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9974
    int numFds = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9975
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9976
    if (__isSmallInteger(millis)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9977
	FD_ZERO(&rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9978
	FD_ZERO(&wset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9979
	FD_ZERO(&eset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9980
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9981
	maxF = -1;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9982
	if (__isNonNilObject(readFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9983
	    if (! __isArrayLike(readFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9984
		goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9985
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9986
	    count = __arraySize(readFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9987
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9988
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9989
		fd = __ArrayInstPtr(readFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9990
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9991
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9992
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9993
			    fprintf(stderr, "OS [warning]: funny read-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9994
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9995
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9996
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9997
			if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9998
			    FD_SET(f, &rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9999
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10000
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10001
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10002
			    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
 10003
				fprintf(stderr, "OS [warning]: huge read-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10004
			    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10005
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10006
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10007
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10008
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10009
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10010
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10011
	if (__isNonNilObject(writeFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10012
	    if (! __isArrayLike(writeFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10013
		goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10014
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10015
	    count = __arraySize(writeFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10016
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10017
		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10018
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10019
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10020
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
 10021
			    fprintf(stderr, "OS [warning]: funny write-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10022
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10023
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10024
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10025
			if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10026
			    FD_SET(f, &wset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10027
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10028
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10029
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10030
			    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
 10031
				fprintf(stderr, "OS [warning]: huge write-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10032
			    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10033
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10034
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10035
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10036
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10037
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10038
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10039
	if (__isNonNilObject(exceptFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10040
	    if (! __isArrayLike(exceptFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10041
		goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10042
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10043
	    count = __arraySize(exceptFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10044
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10045
		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10046
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10047
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10048
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
 10049
			    fprintf(stderr, "OS [warning]: funny except-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10050
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10051
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10052
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10053
			if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10054
			    FD_SET(f, &eset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10055
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10056
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10057
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10058
			    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
 10059
				fprintf(stderr, "OS [warning]: huge except-fd (0x%lx) given to select\n", (unsigned long)fd);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10060
			    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10061
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10062
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10063
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10064
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10065
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10066
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10067
	t = __intVal(millis);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10068
	if (t) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10069
	    wt.tv_sec = t / 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10070
	    wt.tv_usec = (t % 1000) * 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10071
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10072
	    wt.tv_sec = wt.tv_usec = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10073
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10074
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10075
	/*
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10076
	 * make certain, that interrupt gets us out of the select
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10077
	 * However, we must then care for moved objects.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10078
	 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10079
	__BEGIN_INTERRUPTABLE__
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10080
	errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10081
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10082
	if (t == 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10083
	    /*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10084
	     * if there is no timeout time, we can stay here interruptable.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10085
	     */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10086
	    do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10087
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10088
	    } while ((ret < 0) && (errno == EINTR));
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10089
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10090
	    do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10091
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10092
		/*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10093
		 * for now: dont loop; if we did, we had to adjust the vt-timeval;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10094
		 * could otherwise stay in this loop forever ...
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10095
		 * Premature ret (before the time expired) must be handled by the caller.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10096
		 * A good solution is to update the wt-timeval and redo the select.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10097
		 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10098
	    } while (0 /* (ret < 0) && (errno == EINTR) */ );
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10099
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10100
	__END_INTERRUPTABLE__
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10101
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10102
	if (ret > 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10103
	    for (i=0; i <= maxF; i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10104
		if (FD_ISSET(i, &rset)
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10105
		 || FD_ISSET(i, &wset)
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10106
		 || FD_ISSET(i, &eset)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 10107
		    RETURN ( __mkSmallInteger(i) );
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10108
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10109
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10110
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10111
	    if (ret < 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10112
		if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10113
		    errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10114
		    @global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10115
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10116
		    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10117
			fprintf(stderr, "OS [info]: select errno = %d\n", errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10118
		    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 10119
		    @global(LastErrorNumber) = __mkSmallInteger(errno);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10120
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10121
	    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10122
		@global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10123
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10124
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10125
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10126
	/*
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10127
	 * Return nil (means time expired or interrupted)
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10128
	 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 10129
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10130
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10131
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10132
fail: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10133
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10134
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10135
     timeout argument not integer,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10136
     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
 10137
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10138
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10139
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10140
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10141
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10142
setBlocking:aBoolean on:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10143
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10144
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10145
    "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
 10146
     a read on the fileDescriptor will block until data is available.
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 10147
     If cleared, a read operation will immediately return with a value of nil.
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10148
     Also affects write operations, which may perform partial writes when
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
 10149
     blocking is off.
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 10150
     Return the previous blocking state."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10151
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10152
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10153
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 10154
    int ret = 0, flags;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10155
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10156
#if defined(F_GETFL) && defined(F_SETFL)
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10157
# undef DELAY_FLAG
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 10158
# if defined(O_NONBLOCK)
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 10159
#  define DELAY_FLAG O_NONBLOCK
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
 10160
# elif defined(O_NDELAY)
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10161
#  define DELAY_FLAG O_NDELAY
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10162
# elif defined(FNDELAY)
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10163
#  define DELAY_FLAG FNDELAY
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10164
# endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10165
# if defined(DELAY_FLAG)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10166
    if (__isSmallInteger(fd)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10167
	int f = __intVal(fd);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10168
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10169
	flags = fcntl(f, F_GETFL, 0);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10170
	if (aBoolean == true) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10171
	    ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10172
	} else if (aBoolean == false) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10173
	    ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10174
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10175
	if (ret >= 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10176
	    RETURN ((flags & DELAY_FLAG) ? false : true );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10177
	}
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10178
    }
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10179
#  undef DELAY_FLAG
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10180
# endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10181
#endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10182
%}.
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10183
    "
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
 10184
     fd argument not integer or bad return code
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10185
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10186
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10187
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 10188
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10189
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'change & update'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10190
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10191
update:aspect with:argument from:anObject
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10192
    "one of our registered handles has been collected"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10193
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10194
    aspect == #ElementExpired ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10195
	OpenFiles keysAndValuesDo:[:fd :handle |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10196
	    handle == 0 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10197
		"Have to close the file descriptor"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10198
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10199
		OperatingSystem closeFd:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10200
		OpenFiles at:fd put:nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10201
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10202
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10203
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10204
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10205
    "Created: 30.9.1997 / 12:57:35 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10206
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10207
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10208
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10209
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10210
initialize
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10211
    OpenFiles := WeakArray new:10.
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10212
    OpenFiles addDependent:self.
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10213
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10214
    "
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10215
        self initialize
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10216
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10217
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10218
    "Created: 26.9.1997 / 17:15:50 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10219
    "Modified: 30.9.1997 / 12:40:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10220
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10221
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10222
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'instance creation'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10223
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10224
for:aFileDescriptor
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10225
    "create an instance of myself for a given fileDescriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10226
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10227
    ^ self new for:aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10228
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10229
    "Created: 30.9.1997 / 14:00:00 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10230
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10231
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10232
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'error handling'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10233
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 10234
error:anErrorSymbolOrErrno
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 10235
    "got an error; arg is either a symbol specifying a primitive error
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 10236
     or the error number as returned by the OperatingSystem"
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 10237
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 10238
    anErrorSymbolOrErrno isInteger ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10239
	(UnixOperatingSystem errorHolderForNumber:anErrorSymbolOrErrno) reportError
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 10240
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 10241
    self primitiveFailed:anErrorSymbolOrErrno.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10242
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10243
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10244
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'file access'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10245
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10246
close
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10247
    "close the descriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10248
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10249
    |desc|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10250
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10251
    desc := fd.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10252
    self invalidate.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10253
    ^ OperatingSystem closeFd:desc.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10254
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10255
    "Modified: 30.9.1997 / 13:06:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10256
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10257
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10258
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10259
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10260
for:aFileDescriptor
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10261
    "create a file for a handle"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10262
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10263
    |oldHandle|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10264
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10265
    fd := aFileDescriptor.
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10266
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10267
    "JV@2013-03-15: It may happen that OS returns a filedescriptor whose value
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10268
     is larger than twice the lenght of the weakarray. Care for this. 
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10269
     Spotted by Martin Kobetic." 
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10270
    oldHandle := OpenFiles at:aFileDescriptor ifAbsent: [nil].
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10271
    "/ the 0 is possible, if an fd was open when saving a snapshot image,
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10272
    "/ and we come up in the new image with no one referring to it.
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10273
    (oldHandle notNil and:[oldHandle ~~ 0 and:[ oldHandle ~~ self]]) ifTrue:[
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10274
        oldHandle invalidate.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10275
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10276
    self register.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10277
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10278
    "Created: 26.9.1997 / 17:14:40 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10279
    "Modified: 30.9.1997 / 12:41:43 / stefan"
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10280
    "Modified (comment): / 16-03-2013 / 00:04:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10281
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10282
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10283
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'input/output'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10284
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10285
readBytes:count into:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10286
    "read count bytes into a byte-buffer;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10287
     Return the number of bytes read.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10288
     The read is non-blocking. If the operation would block
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10289
     either an incomplete count or nil will be returned.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10290
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10291
     An exception is raised on any other error"
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10292
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10293
    |error|
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10294
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10295
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10296
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10297
    int nRead = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10298
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10299
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10300
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10301
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10302
    if (! __isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10303
	error = @symbol(errorNotOpen);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10304
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10305
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10306
    if (! __bothSmallInteger(count, firstIndex)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10307
	error = @symbol(badArgument);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10308
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10309
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10310
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10311
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10312
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10313
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10314
    if (fd < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10315
	error = @symbol(internalError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10316
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 10317
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 10318
    if (__isExternalBytesLike(aByteBuffer)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10319
	OBJ sz;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10320
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10321
	nInstBytes = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10322
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
14667
f6a830b971f3 care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents: 14657
diff changeset
 10323
	if (extPtr == NULL) goto bad;
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10324
	sz = __externalBytesSize(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10325
	if (__isSmallInteger(sz)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10326
	    objSize = __smallIntegerVal(sz);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10327
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10328
	    objSize = -1; /* unknown */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10329
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10330
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10331
	OBJ oClass;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10332
	int nInstVars;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10333
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10334
	oClass = __Class(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10335
	switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10336
	    case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10337
	    case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10338
	    case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10339
	    case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10340
	    case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10341
	    case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10342
	    case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10343
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10344
	    default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10345
		error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10346
		goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10347
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10348
	extPtr = (char *)0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10349
	nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10350
	nInstBytes = __OBJS2BYTES__(nInstVars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10351
	objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10352
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10353
    if ((offs >= 0)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10354
	&& (cnt >= 0)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10355
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10356
	nRead = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10357
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10358
	do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10359
	    int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10360
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10361
	    if (extPtr) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10362
		n = read(fd, extPtr+offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10363
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10364
		char *bp;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10365
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10366
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10367
		 * on interrupt, anObject may be moved to another location.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10368
		 * So we recompute the byte-address here.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10369
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10370
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10371
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10372
		n = read(fd, bp + offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10373
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10374
	    if (n > 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10375
		cnt -= n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10376
		offs += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10377
		nRead += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10378
	    } else if (n == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10379
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10380
	    } else if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10381
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10382
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10383
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10384
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10385
#ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10386
		    || errno == EAGAIN
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10387
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10388
		) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10389
		     RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10390
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10391
		if (errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10392
		     error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10393
		     goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10394
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10395
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10396
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10397
	} while (cnt > 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10398
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10399
	RETURN (__mkSmallInteger(nRead));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10400
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10401
bad: ;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10402
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10403
    ^ self error:error.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10404
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10405
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10406
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10407
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10408
     h := OperatingSystem openFileForRead:'/etc/hosts'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10409
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10410
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10411
     Transcript show:n; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10412
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10413
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10414
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10415
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10416
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10417
     h := OperatingSystem openFileForRead:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10418
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10419
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10420
     Transcript show:n printString; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10421
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10422
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10423
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10424
writeBytes:count from:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10425
    "write count bytes from a byte-buffer;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10426
     Return the number of bytes written (negative on error)"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10427
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10428
    |error|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10429
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10430
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10431
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10432
    int nWritten = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10433
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10434
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10435
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10436
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10437
    if (! __isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10438
	error = @symbol(errorNotOpen);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10439
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10440
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10441
    if (! __bothSmallInteger(count, firstIndex)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10442
	error = @symbol(badArgument);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10443
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10444
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10445
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10446
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10447
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10448
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10449
    if (fd < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10450
	error = @symbol(internalError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10451
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 10452
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 10453
    if (__isExternalBytesLike(aByteBuffer)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10454
	OBJ sz;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10455
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10456
	nInstBytes = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10457
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
14667
f6a830b971f3 care for externalAddress being NULL before accessing an external buffer's contents
Claus Gittinger <cg@exept.de>
parents: 14657
diff changeset
 10458
	if (extPtr == NULL) goto bad;
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10459
	sz = __externalBytesSize(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10460
	if (__isSmallInteger(sz)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10461
	    objSize = __smallIntegerVal(sz);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10462
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10463
	    objSize = -1; /* unknown */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10464
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10465
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10466
	OBJ oClass;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10467
	int nInstVars;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10468
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10469
	oClass = __Class(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10470
	switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10471
	    case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10472
	    case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10473
	    case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10474
	    case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10475
	    case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10476
	    case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10477
	    case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10478
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10479
	    default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10480
		error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10481
		goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10482
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10483
	extPtr = (char *)0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10484
	nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10485
	nInstBytes = __OBJS2BYTES__(nInstVars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10486
	objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10487
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10488
    if ((offs >= 0)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10489
	&& (cnt >= 0)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10490
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10491
	nWritten = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10492
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10493
	do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10494
	    int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10495
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10496
	    if (extPtr) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10497
		n = write(fd, extPtr+offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10498
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10499
		char *bp;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10500
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10501
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10502
		 * on interrupt, anObject may be moved to another location.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10503
		 * So we recompute the byte-address here.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10504
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10505
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10506
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10507
		n = write(fd, bp + offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10508
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10509
	    if (n > 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10510
		cnt -= n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10511
		offs += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10512
		nWritten += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10513
	    } else if (n == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10514
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10515
	    } else if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10516
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10517
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10518
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10519
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10520
#ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10521
		    || errno == EAGAIN
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10522
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10523
		) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10524
		     RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10525
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10526
		if (errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10527
		     error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10528
		     goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10529
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10530
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10531
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10532
	} while (cnt > 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10533
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10534
	RETURN (__mkSmallInteger(nWritten));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10535
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10536
bad: ;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10537
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10538
    ^ self error:error
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10539
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10540
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10541
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10542
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10543
     h := OperatingSystem createFileForReadWrite:'/tmp/xx'.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10544
     buff := '12345678901234567890'.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10545
     n := h writeBytes:10 from:buff startingAt:1.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10546
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10547
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10548
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10549
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10550
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10551
     h := OperatingSystem createFileForReadWrite:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10552
     buff := '12345678901234567890'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10553
     n := h writeBytes:10 from:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10554
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10555
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10556
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10557
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'misc functions'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10558
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10559
nextError
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10560
    "retrieve the pending error from the current fileDescriptor
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10561
     and raise an error exception.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10562
     This should be only called, when an error is pending.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10563
     Otherwise a byte may be lost"
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10564
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10565
    |dummyByte|
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10566
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10567
    dummyByte := ByteArray new:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10568
    ^ self readBytes:1 into:dummyByte startingAt:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10569
!
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10570
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10571
seekTo:newPosition from:whence
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10572
    "seek to newPosition
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10573
     whence is one of: #begin #current #end.
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10574
     Return the new position."
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10575
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10576
    |error|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10577
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10578
%{
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10579
    INT fd;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10580
    INT __whence;
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10581
    off_t pos, ret;
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10582
    OBJ rslt;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10583
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10584
    if (! __isSmallInteger(__INST(fd))) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10585
	error = @symbol(errorNotOpen);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10586
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10587
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10588
    if (__isSmallInteger(newPosition)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10589
	pos = __smallIntegerVal(newPosition);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10590
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10591
	pos = __signedLongIntVal(newPosition);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10592
	if (pos < 0 && (sizeof(pos) < 8 || __signedLong64IntVal(newPosition, &pos) == 0)) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10593
	    error = @symbol(badArgument1);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10594
	    goto bad;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10595
	}
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10596
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10597
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10598
    fd = __smallIntegerVal(__INST(fd));
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10599
    if (fd < 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10600
	error = @symbol(internalError);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10601
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10602
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10603
    if (whence == @symbol(begin)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10604
	__whence = SEEK_SET;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10605
    } else if (whence == @symbol(current)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10606
	__whence = SEEK_CUR;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10607
    } else if (whence == @symbol(end)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10608
	__whence = SEEK_END;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10609
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10610
	error = @symbol(badArgument2);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10611
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10612
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10613
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10614
again:
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10615
    ret = lseek(fd, pos, __whence);
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10616
    if (ret < 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10617
	if (errno == EINTR) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10618
	    __HANDLE_INTERRUPTS__;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10619
	    goto again;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10620
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10621
	error = __mkSmallInteger(errno);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10622
	goto bad;
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10623
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10624
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10625
    if (sizeof(ret) == 8) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10626
	rslt = __MKINT64 (&ret);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10627
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10628
	rslt = __MKINT(ret);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10629
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10630
    RETURN (rslt);
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10631
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10632
bad: ;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10633
%}.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10634
    ^ self error:error.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10635
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10636
    "
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10637
     |h buff n|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10638
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10639
     h := OperatingSystem openFileForRead:'/etc/hosts'.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10640
     h seekTo:10 from:#begin.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10641
     buff := ByteArray new:1000. buff inspect.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10642
     n := h readBytes:1000 into:buff startingAt:1.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10643
     Transcript show:n; space; showCR:buff asString.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10644
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10645
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10646
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10647
selectWithTimeOut:millis
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10648
    "wait for aFileDesriptor to become ready; timeout after t milliseconds.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10649
     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
 10650
     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
 10651
     of read-data.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10652
     Experimental."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10653
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10654
    ^ OperatingSystem selectOnAnyReadable:(Array with:fd)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10655
		      writable:(Array with:fd)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10656
		     exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10657
		   withTimeOut:millis
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10658
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10659
    "Created: 1.10.1997 / 08:51:11 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10660
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10661
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10662
setBlocking:aBoolean
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10663
    "{ Pragma: +optSpace }"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10664
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10665
    "set/clear the blocking attribute - if set (which is the default)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10666
     a read on the fileDescriptor will block until data is available.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10667
     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
 10668
     nil if no data is available."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10669
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10670
    |err|
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10671
%{
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10672
    int ret, flags;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10673
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10674
#if defined(F_GETFL) && defined(F_SETFL)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10675
# if defined(O_NDELAY)
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10676
#  define DELAY_FLAG O_NDELAY
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10677
# else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10678
#  if defined(FNDELAY)
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10679
#   define DELAY_FLAG FNDELAY
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10680
#  endif
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10681
# endif
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10682
# if defined(DELAY_FLAG)
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10683
    if (__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10684
	int f = __intVal(__INST(fd));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10685
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10686
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10687
	if (aBoolean == true) {
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10688
	    ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10689
	} else {
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10690
	    ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10691
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10692
	if (ret >= 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 10693
	    RETURN(__mkSmallInteger(flags));
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10694
	} else {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 10695
	    err = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10696
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10697
    }
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10698
# undef DELAY_FLAG
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10699
# endif /* DELAY_FLAG */
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10700
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10701
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10702
    err notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10703
	self error:err
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10704
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10705
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10706
     fd argument not integer
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10707
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10708
    ^ self primitiveFailed
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10709
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10710
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10711
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10712
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 10713
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'private-accessing'!
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10714
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10715
fileDescriptor
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10716
    "return the (integer) fileDescriptor"
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10717
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10718
%{
7462
05b5202d988a Fix compiler warning
Stefan Vogel <sv@exept.de>
parents: 7461
diff changeset
 10719
    OBJ handle = __externalAddressVal(self);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10720
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10721
    if (__isSmallInteger(handle)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10722
	RETURN (handle);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10723
    }
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10724
%}.
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10725
    ^ nil
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10726
!
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10727
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10728
setFileDescriptor:anInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10729
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10730
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10731
    if (__isSmallInteger(anInteger)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10732
	__externalAddressVal(self) = (OBJ)(__smallIntegerVal(anInteger));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10733
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10734
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10735
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10736
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10737
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10738
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10739
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'queries'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10740
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10741
canReadWithoutBlocking
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10742
    "return true, if data is available on a filedescriptor
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10743
     (i.e. read is possible without blocking).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10744
     This depends on a working select or FIONREAD to be provided by the OS."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10745
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10746
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10747
    int fd;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10748
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10749
    if (__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10750
	fd = __smallIntegerVal(__INST(fd));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10751
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10752
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10753
	 * if available, try FIONREAD first, which is usually done faster.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10754
	 */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10755
# ifdef FIONREAD
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10756
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10757
	    int result = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10758
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10759
	    if (ioctl(fd, FIONREAD, &result) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10760
		RETURN(result > 0 ? true : false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10761
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10762
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10763
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10764
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10765
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10766
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10767
    OperatingSystem supportsSelect ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10768
	"/ mhmh - what should we do then ?
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10769
	"/ For now, return true as if data was present,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10770
	"/ and let the thread fall into the read.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10771
	"/ It will then (hopefully) be desceduled there and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10772
	"/ effectively polling for input.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10773
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10774
	^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10775
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10776
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10777
    ^ (OperatingSystem selectOnAnyReadable:(Array with:fd)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10778
		       writable:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10779
		       exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10780
		       withTimeOut:0) == fd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10781
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10782
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10783
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10784
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10785
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10786
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10787
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10788
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10789
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10790
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10791
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10792
     h := OperatingSystem openFileForRead:'/dev/ttyS0'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10793
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10794
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10795
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10796
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10797
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10798
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10799
canWriteWithoutBlocking
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10800
    "return true, if filedescriptor can be written without blocking"
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10801
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10802
    OperatingSystem supportsSelect ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10803
	"/ mhmh - what should we do then ?
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10804
	"/ For now, return true as if data was present,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10805
	"/ and let the thread fall into the write.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10806
	"/ It will then (hopefully) be desceduled there and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10807
	"/ effectively polling for output.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10808
	^ true
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10809
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10810
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10811
    ^ (OperatingSystem selectOnAnyReadable:nil
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10812
		       writable:(Array with:fd)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10813
		       exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10814
		       withTimeOut:0) == fd
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10815
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10816
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10817
isValid
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10818
    "answer true, if the handle is valid, i.e. connected to
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10819
     a file or some other OS object"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10820
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10821
    ^ fd notNil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10822
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10823
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10824
numAvailableForRead
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10825
    "return the number of bytes available for reading, without blocking."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10826
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10827
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10828
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10829
     * if available, try FIONREAD first, which is usually done faster.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10830
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10831
# if defined(FIONREAD)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10832
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10833
	int n = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10834
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10835
	if (__isSmallInteger(__INST(fd))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10836
	    if (ioctl(__smallIntegerVal(__INST(fd)), FIONREAD, &n) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10837
		RETURN (__MKINT(n));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10838
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10839
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10840
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10841
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10842
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10843
    ^ self canReadWithoutBlocking ifTrue:[1] ifFalse:[0]
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10844
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10845
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10846
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10847
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10848
     n := h numAvailableForRead.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10849
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10850
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10851
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10852
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10853
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10854
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'registering'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10855
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10856
register
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10857
    "register myself as an open file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10858
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10859
    |sz old|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10860
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10861
    sz := OpenFiles size.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10862
    fd > sz ifTrue:[
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10863
        "grow for more descriptors"
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10864
        old := OpenFiles.
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10865
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10866
        "JV@2013-03-15: It may happen that OS returns a filedescriptor whose value
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10867
         is larger than twice the lenght of the weakarray. Care for this. 
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10868
         Spotted by Martin Kobetic."          
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10869
        OpenFiles := WeakArray new:((sz * 2) max:fd).
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10870
        old removeDependent:(self class).
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10871
        OpenFiles addDependent:(self class).
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10872
        old keysAndValuesDo:[:index :elem|
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10873
            "be careful to not overwrite new entries in OpenFiles"
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10874
            elem notNil ifTrue:[
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10875
                OpenFiles at:index put:elem.
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10876
            ].
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10877
        ].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10878
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10879
    OpenFiles at:fd put:self.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10880
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10881
    "Created: 30.9.1997 / 12:51:48 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10882
    "Modified: 30.9.1997 / 12:58:37 / stefan"
14899
81d128d5fb7d Fixes for UnixOperatingSystem::FileDescriptorHandle. Spotted by Martin Kobetic.
Stefan Vogel <sv@exept.de>
parents: 14839
diff changeset
 10883
    "Modified (comment): / 16-03-2013 / 00:04:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10884
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10885
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10886
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'releasing'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10887
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10888
invalidate
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10889
    "a file handle has become invalid"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10890
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10891
    OpenFiles at:fd put:nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10892
    fd := nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10893
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10894
    "Created: 30.9.1997 / 12:37:26 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10895
    "Modified: 30.9.1997 / 12:42:16 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10896
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10897
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10898
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'waiting'!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10899
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10900
readWaitWithTimeoutMs:timeout
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10901
    "suspend the current process, until the receiver
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10902
     becomes ready for reading or a timeout (in milliseconds) expired.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10903
     If data is already available, return immediate.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10904
     Return true if a timeout occured (i.e. false, if data is available).
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10905
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10906
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10907
    |inputSema hasData wasBlocked|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10908
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10909
    fd isNil ifTrue:[^ self error:#errorNotOpen].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10910
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10911
    wasBlocked := OperatingSystem blockInterrupts.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10912
    hasData := self canReadWithoutBlocking.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10913
    hasData ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10914
	inputSema := Semaphore new name:'readWait'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10915
	[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10916
	    timeout notNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10917
		Processor signal:inputSema afterMilliseconds:timeout
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10918
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10919
	    Processor signal:inputSema onInput:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10920
	    Processor activeProcess state:#ioWait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10921
	    inputSema wait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10922
	    Processor disableSemaphore:inputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10923
	    hasData := self canReadWithoutBlocking.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10924
	] ifCurtailed:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10925
	    Processor disableSemaphore:inputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10926
	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10927
	]
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10928
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10929
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10930
    ^ hasData not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10931
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10932
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10933
writeWaitWithTimeoutMs:timeout
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10934
    "suspend the current process, until the receiver
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10935
     becomes ready for writing or a timeout (in seconds) expired.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10936
     Return true if a timeout occured (i.e. false, if data is available).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10937
     Return immediate if the receiver is already ready.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10938
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10939
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
 10940
    |outputSema canWrite wasBlocked|
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10941
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10942
    fd isNil ifTrue:[^ self error:#errorNotOpen].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10943
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10944
    wasBlocked := OperatingSystem blockInterrupts.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10945
    canWrite := self canWriteWithoutBlocking.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10946
    canWrite ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10947
	outputSema := Semaphore new name:'writeWait'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10948
	[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10949
	    timeout notNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10950
		Processor signal:outputSema afterMilliseconds:timeout
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10951
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10952
	    Processor signal:outputSema onOutput:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10953
	    Processor activeProcess state:#ioWait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10954
	    outputSema wait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10955
	    Processor disableSemaphore:outputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10956
	    canWrite := self canWriteWithoutBlocking.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10957
	] ifCurtailed:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10958
	    Processor disableSemaphore:outputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10959
	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10960
	]
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10961
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10962
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10963
    ^ canWrite not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10964
! !
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10965
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10966
!UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10967
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10968
closeFile
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10969
    "close the underlying file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10970
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10971
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10972
    FILE *f = (FILE *)(__externalAddressVal(self));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10973
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10974
    if (f) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10975
	__externalAddressVal(self) = NULL;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10976
	fclose(f);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10977
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10978
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10979
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10980
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10981
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10982
!UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10983
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10984
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10985
    ^ self basicNew
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10986
	type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10987
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10988
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10989
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10990
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10991
accessTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10992
    "return accessed"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10993
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10994
    accessed isInteger ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10995
	"/ lazy time conversion
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10996
	accessed := Timestamp fromOSTime:(accessed * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10997
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10998
    ^ accessed
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10999
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11000
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11001
alternativeName
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11002
    "return the files other name (DOS name on windows).
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11003
     Nil if there is no other name"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11004
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11005
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11006
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11007
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11008
creationTime
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11009
    ^ nil
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11010
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11011
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11012
fileSize
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11013
    "return size"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11014
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11015
    ^ size
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11016
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11017
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11018
gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11019
    "return gid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11020
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11021
    ^ gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11022
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11023
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11024
id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11025
    "return id"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11026
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11027
    ^ id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11028
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11029
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11030
mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11031
    "return mode"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11032
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11033
    ^ mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11034
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11035
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11036
modificationTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11037
    "return modified"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11038
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 11039
    modified isInteger ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11040
	"/ lazy time conversion
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11041
	modified := Timestamp fromOSTime:(modified * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 11042
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11043
    ^ modified
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11044
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11045
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11046
numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11047
    "return numLinks"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11048
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11049
    ^ numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11050
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11051
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11052
path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11053
    "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
 11054
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11055
    ^ path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11056
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11057
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11058
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11059
statusChangeTime
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11060
    statusChanged isInteger ifTrue:[
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11061
	"/ lazy time conversion
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11062
	statusChanged := Timestamp fromOSTime:(statusChanged * 1000).
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11063
    ].
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11064
    ^ statusChanged
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11065
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11066
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11067
type
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11068
    "return type"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11069
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11070
    ^ type
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11071
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11072
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11073
uid
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11074
    "return uid"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11075
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11076
    ^ uid
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11077
! !
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11078
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11079
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing-vms'!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11080
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11081
fixedHeaderSize
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11082
    "return the fixedHeaderSize (VMS only; nil everywhere else)"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11083
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11084
    ^ nil
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11085
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11086
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11087
recordAttributes
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11088
    "return the recordAttributes (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11089
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11090
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11091
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11092
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11093
recordFormat
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11094
    "return the recordFormat (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11095
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11096
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11097
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11098
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11099
recordFormatNumeric
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11100
    "return the recordFormat as numeric (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11101
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11102
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11103
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11104
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11105
recordSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11106
    "return the recordSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11107
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11108
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11109
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11110
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11111
!UnixOperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11112
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11113
accessed
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 11114
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11115
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11116
    self obsoleteMethodWarning:'use #accessTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 11117
    ^ self accessTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11118
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11119
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11120
at:key
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11121
    "backward compatibility access: in previous releases, IdentityDictionaries
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11122
     were used to hold my information. Allow access via key messages.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11123
     This method will vanish - use the proper access protocol."
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11124
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11125
    ^ self perform:key
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11126
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11127
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11128
modified
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 11129
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11130
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11131
    self obsoleteMethodWarning:'use #modificationTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 11132
    ^ self modificationTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11133
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11134
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11135
statusChanged
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 11136
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11137
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 11138
    self obsoleteMethodWarning:'use #statusChangeTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 11139
    ^ self statusChangeTime
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11140
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11141
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 11142
!UnixOperatingSystem::FileStatusInfo methodsFor:'private-accessing'!
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11143
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11144
type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11145
    type := t.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11146
    mode := m.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11147
    uid := u.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11148
    gid := g.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11149
    size := s.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11150
    id := i.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11151
    accessed := aT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11152
    modified := mT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11153
    statusChanged := sT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11154
    path := lP.
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 11155
    numLinks := nL.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11156
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 11157
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11158
!UnixOperatingSystem::FileStatusInfo methodsFor:'queries-access'!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11159
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11160
isGroupExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11161
    ^ mode bitTest:8r10
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11162
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11163
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11164
      '/etc/passwd' asFilename info isGroupExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11165
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11166
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11167
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11168
isGroupReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11169
    ^ mode bitTest:8r40
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11170
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11171
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11172
      '/etc/passwd' asFilename info isGroupReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11173
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11174
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11175
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11176
isGroupWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11177
    ^ mode bitTest:8r20
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11178
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11179
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11180
      '/etc/passwd' asFilename info isGroupWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11181
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11182
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11183
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11184
isOwnerExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11185
    ^ mode bitTest:8r100
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11186
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11187
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11188
      '/etc/passwd' asFilename info isOwnerExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11189
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11190
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11191
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11192
isOwnerReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11193
    ^ mode bitTest:8r400
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11194
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11195
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11196
      '/etc/passwd' asFilename info isOwnerReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11197
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11198
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11199
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11200
isOwnerWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11201
    ^ mode bitTest:8r200
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11202
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11203
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11204
      '/etc/passwd' asFilename info isOwnerWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11205
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11206
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11207
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11208
isWorldExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11209
    ^ mode bitTest:8r1
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11210
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11211
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11212
      '/etc/passwd' asFilename info isWorldExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11213
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11214
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11215
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11216
isWorldReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11217
    ^ mode bitTest:8r4
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11218
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11219
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11220
      '/etc/passwd' asFilename info isWorldReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11221
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11222
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11223
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11224
isWorldWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11225
    ^ mode bitTest:8r2
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11226
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11227
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11228
      '/etc/passwd' asFilename info isWorldWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11229
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11230
! !
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11231
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 11232
!UnixOperatingSystem::FileStatusInfo methodsFor:'queries-type'!
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11233
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11234
isBlockSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11235
    ^ type == #blockSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11236
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11237
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11238
isCharacterSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11239
    ^ type == #characterSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11240
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11241
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11242
isDirectory
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11243
    ^ type == #directory
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11244
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11245
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11246
isFifo
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11247
    ^ type == #fifo
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11248
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11249
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11250
isRegular
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11251
    ^ type == #regular
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11252
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11253
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11254
isSocket
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11255
    ^ type == #socket
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11256
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11257
15301
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 11258
isSpecialFile
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 11259
    ^ (type ~~ #directory
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 11260
	and:[type ~~ #remoteDirectory
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 11261
	and:[type ~~ #regular
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 11262
	and:[type ~~ #symbolicLink
15301
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 11263
    ]]])
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 11264
!
86c2de0786bd class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15300
diff changeset
 11265
8475
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11266
isSymbolicLink
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11267
    ^ type == #symbolicLink
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11268
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11269
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11270
isUnknown
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11271
    ^ type == #unknown
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11272
! !
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 11273
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11274
!UnixOperatingSystem::MountInfo methodsFor:'accessing'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11275
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11276
mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11277
    "return the value of the instance variable 'mountPointPath' (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11278
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11279
    ^ mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11280
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11281
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11282
mountPointPath:mountPointArg deviceOrRemotePath:deviceOrRemotePathArg fsType:fsTypeArg attributeString:attributeStringArg
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11283
    "set instance variables (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11284
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11285
    mountPointPath := mountPointArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11286
    deviceOrRemotePath := deviceOrRemotePathArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11287
    fsType := fsTypeArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11288
    attributeString := attributeStringArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11289
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11290
7762
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 11291
!UnixOperatingSystem::MountInfo methodsFor:'printing'!
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 11292
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 11293
printOn:aStream
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11294
    aStream
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11295
	nextPutAll:'MountInfo for ';
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11296
	nextPutAll:mountPointPath.
7762
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 11297
! !
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 11298
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11299
!UnixOperatingSystem::MountInfo methodsFor:'queries'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11300
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11301
isRemote
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11302
    ^ fsType = 'nfs'
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11303
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 11304
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11305
!UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11306
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11307
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11308
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11309
    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
 11310
    operating system processes (these are no smalltalk processes!!).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11311
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11312
    [Instance variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11313
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11314
	pid     <Integer>       OS-Process identifier
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11315
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11316
	status  <Symbol>        either #exit #signal #stop #continue
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11317
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11318
	code    <Integer>       either exitcode or signalnumber
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11319
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11320
	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
 11321
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11322
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11323
    [author:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11324
	Stefan Vogel
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11325
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11326
    [see also:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11327
	OperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11328
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11329
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11330
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11331
!UnixOperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11332
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11333
pid:pid status:status code:code core:core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11334
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11335
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11336
    ^ 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
 11337
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11338
    "Created: 28.12.1995 / 14:16:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11339
    "Modified: 30.4.1996 / 18:25:00 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11340
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11341
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11342
processCreationFailure
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11343
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11344
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11345
    ^ 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
 11346
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11347
    "Created: 28.12.1995 / 14:35:29 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11348
    "Modified: 30.4.1996 / 18:25:05 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11349
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11350
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11351
!UnixOperatingSystem::OSProcessStatus methodsFor:'accessing'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11352
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11353
code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11354
    "return the exitcode / signalNumber"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11355
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11356
    ^ code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11357
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11358
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11359
    "Modified: 30.4.1996 / 18:26:23 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11360
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11361
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11362
core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11363
    "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
 11364
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11365
    ^ core == true
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11366
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11367
    "Modified: 28.12.1995 / 14:14:38 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11368
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11369
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11370
pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11371
    "return the pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11372
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11373
    ^ pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11374
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11375
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11376
    "Modified: 30.4.1996 / 18:26:30 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11377
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11378
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11379
status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11380
    "return status as a Symbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11381
     one of #exit #signal #stop #continue"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11382
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11383
    ^ status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11384
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11385
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11386
    "Modified: 30.4.1996 / 18:26:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11387
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11388
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11389
!UnixOperatingSystem::OSProcessStatus methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11390
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11391
pid:newPid status:newStatus code:newCode core:newCore
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11392
    pid := newPid.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11393
    status := newStatus.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11394
    code := newCode.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11395
    core := newCore.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11396
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11397
    "Created: 28.12.1995 / 14:18:22 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11398
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11399
7175
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11400
!UnixOperatingSystem::OSProcessStatus methodsFor:'printing & storing'!
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11401
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11402
printOn:aStream
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11403
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11404
    aStream nextPutAll:'ExitStatus ('.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11405
    status printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11406
    aStream nextPutAll:', code='.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11407
    code printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11408
    aStream nextPut:$).
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11409
! !
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11410
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11411
!UnixOperatingSystem::OSProcessStatus methodsFor:'private-OS interface'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11412
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11413
code:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11414
    "set the exitCode"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11415
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11416
    code := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11417
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11418
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11419
    "Modified: 30.4.1996 / 18:25:18 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11420
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11421
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11422
core:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11423
    "set core"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11424
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11425
    core := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11426
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11427
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11428
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11429
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11430
pid:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11431
    "set pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11432
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11433
    pid := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11434
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11435
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11436
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11437
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11438
status:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11439
    "set status"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11440
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11441
    status := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11442
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11443
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11444
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11445
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11446
!UnixOperatingSystem::OSProcessStatus methodsFor:'queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11447
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11448
couldNotExecute
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11449
    "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
 11450
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11451
    ^ status == #exit and:[code = 127].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11452
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11453
    "Created: 28.12.1995 / 15:43:17 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11454
    "Modified: 30.4.1996 / 18:27:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11455
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11456
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11457
stillAlive
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11458
    "true if process is still alive"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11459
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11460
    ^ status == #stop or:[status == #continue]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11461
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11462
    "Created: 28.12.1995 / 14:27:26 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11463
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11464
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11465
success
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11466
    "true if process terminated successfully"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11467
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11468
    ^ status == #exit and:[code = 0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11469
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11470
    "Created: 28.12.1995 / 14:13:05 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11471
    "Modified: 28.12.1995 / 14:13:41 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11472
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11473
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11474
!UnixOperatingSystem::SocketHandle class methodsFor:'constants'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11475
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11476
protocolCodeOf:aNameOrNumber
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11477
    "convert a symbol to a numeric protocol code"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11478
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11479
    |protocolCode protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11480
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11481
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11482
    if (__isSmallInteger(aNameOrNumber) || aNameOrNumber == nil) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11483
	RETURN(aNameOrNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11484
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11485
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11486
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11487
    ProtocolCache notNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11488
	protocolCode := ProtocolCache at:(aNameOrNumber asSymbol) ifAbsent:[].
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11489
	protocolCode notNil ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11490
	    ^ protocolCode.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11491
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11492
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11493
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11494
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11495
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11496
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11497
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11498
    if (__isStringLike(aNameOrNumber)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11499
	protoent = getprotobyname((char *) __stringVal(aNameOrNumber));
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11500
	if (protoent) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11501
	    protocolCode = __mkSmallInteger(protoent->p_proto);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11502
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11503
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11504
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11505
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11506
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11507
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11508
    protocolSymbol notNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11509
	ProtocolCache isNil ifTrue:[
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11510
	    ProtocolCache := IdentityDictionary new.
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11511
	].
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11512
	"beware of polluting the protocol cache with aliases"
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11513
	ProtocolCache at:protocolSymbol put:protocolCode.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11514
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11515
    ^ protocolCode
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11516
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11517
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11518
     self protocolCodeOf:#tcp
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11519
     self protocolCodeOf:#udp
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11520
     self protocolCodeOf:#raw
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11521
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11522
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11523
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11524
protocolSymbolOf:anInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11525
    "convert a numeric protocol code to a symbol"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11526
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11527
    |protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11528
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11529
    ProtocolCache notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11530
	protocolSymbol := ProtocolCache keyAtIdentityValue:anInteger ifAbsent:[].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11531
	protocolSymbol notNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11532
	    ^ protocolSymbol.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11533
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11534
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11535
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11536
%{
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11537
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11538
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11539
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11540
    if (__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11541
	protoent = getprotobynumber(__intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11542
	if (protoent) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11543
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11544
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11545
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11546
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11547
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11548
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11549
    protocolSymbol notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11550
	ProtocolCache isNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11551
	    ProtocolCache := IdentityDictionary new.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11552
	].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11553
	ProtocolCache at:protocolSymbol put:anInteger.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11554
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11555
    ^ protocolSymbol
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11556
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11557
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11558
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11559
     self protocolSymbolOf:(self protocolCodeOf:#tcp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11560
     self protocolSymbolOf:(self protocolCodeOf:#udp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11561
     self protocolSymbolOf:(self protocolCodeOf:#icmp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11562
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11563
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11564
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11565
!UnixOperatingSystem::SocketHandle class methodsFor:'initialization'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11566
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11567
reinitialize
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11568
    "clear the protocol cache, when the system has been restarted"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11569
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11570
    ProtocolCache := nil.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11571
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11572
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11573
!UnixOperatingSystem::SocketHandle class methodsFor:'queries'!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11574
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11575
getAddressInfo:hostName serviceName:serviceNameArg domain:domainArg type:typeArg protocol:protoArg flags:flags
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11576
    "answer an Array of socket addresses for serviceName on hostName
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11577
     Domain, type, protocol may be nil or specify a hint for the socket
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11578
     addresses to be returned."
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11579
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11580
    |result domain type proto serviceName encodedHostName|
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11581
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11582
    domain := OperatingSystem domainCodeOf:domainArg.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11583
    type := OperatingSystem socketTypeCodeOf:typeArg.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11584
    proto := self protocolCodeOf:protoArg.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11585
    serviceNameArg notNil ifTrue:[
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11586
        serviceName := serviceNameArg printString.      "convert integer port numbers"
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11587
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11588
15795
c6c9844bcd82 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15794
diff changeset
 11589
    hostName isNil ifTrue:[
c6c9844bcd82 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15794
diff changeset
 11590
        encodedHostName := nil.
c6c9844bcd82 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15794
diff changeset
 11591
    ] ifFalse:[
c6c9844bcd82 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15794
diff changeset
 11592
        encodedHostName := hostName utf8Encoded.
c6c9844bcd82 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15794
diff changeset
 11593
    ].
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11594
    (encodedHostName ~~ hostName and:[OperatingSystem getCodeset ~~ #utf8]) ifTrue:[
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11595
        "hostName is not plain ASCII - so this is an IDN domain name. Have to ensure, that the locale is UTF-8.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11596
         Block interrupt to not affect othe ST/X processes while the locale is changed."
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11597
        |interruptsBlocked oldLocale|
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11598
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11599
        interruptsBlocked := OperatingSystem blockInterrupts.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11600
        oldLocale := OperatingSystem setLocale:#'LC_CTYPE' to:nil.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11601
        OperatingSystem setLocale:#'LC_CTYPE' to:'en_US.UTF-8'.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11602
        result := self primGetAddressInfo:encodedHostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11603
        OperatingSystem setLocale:#'LC_CTYPE' to:oldLocale.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11604
        interruptsBlocked ifFalse:[
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11605
            OperatingSystem unblockInterrupts.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11606
        ].
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11607
    ] ifFalse:[
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11608
        result := self primGetAddressInfo:encodedHostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags.
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11609
    ].
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11610
    result isArray ifFalse:[
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11611
        |request|
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11612
        request := SocketAddressInfo new
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11613
            domain:domainArg;
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11614
            type:typeArg;
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11615
            protocol:protoArg;
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11616
            canonicalName:hostName;
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11617
            serviceName:serviceName.
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11618
        ^ (HostNameLookupError new
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11619
                parameter:result;
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11620
                messageText:' - ', (result printString);
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11621
                request:request) raiseRequest.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11622
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11623
    1 to:result size do:[:i |
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11624
        |entry dom info|
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11625
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11626
        entry := result at:i.
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11627
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11628
        info := SocketAddressInfo new.
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11629
        info
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11630
            flags:(entry at:1);
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11631
            domain:(dom := OperatingSystem domainSymbolOf:(entry at:2));
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11632
            type:(OperatingSystem socketTypeSymbolOf:(entry at:3));
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11633
            protocol:(self protocolSymbolOf:(entry at:4));
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11634
            socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5));
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11635
            canonicalName:(entry at:6).
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11636
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11637
        result at:i put:info.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11638
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11639
    ^ result
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11640
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11641
    "
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11642
     self getAddressInfo:'localhost' serviceName:nil
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11643
            domain:nil type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11644
     self getAddressInfo:'localhost' serviceName:nil
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11645
            domain:#inet type:#stream protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11646
     self getAddressInfo:'localhost' serviceName:nil
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11647
            domain:#inet type:#stream protocol:#tcp flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11648
     self getAddressInfo:'blurb.exept.de' serviceName:nil
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11649
            domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11650
     self getAddressInfo:'1.2.3.4' serviceName:'bla'
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11651
            domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11652
     self getAddressInfo:'localhost' serviceName:'echo'
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11653
            domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11654
     self getAddressInfo:nil serviceName:'echo'
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11655
            domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11656
     self getAddressInfo:nil serviceName:nil
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11657
            domain:#inet type:nil protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11658
     self getAddressInfo:'www.google.de' serviceName:nil
15513
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11659
            domain:nil type:nil protocol:nil flags:nil
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11660
     self getAddressInfo:'www.exept.de' serviceName:nil
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11661
            domain:nil type:nil protocol:nil flags:nil
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11662
     self getAddressInfo:'www.exept.de' serviceName:nil
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11663
            domain:#'AF_INET' type:nil protocol:nil flags:nil
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11664
     self getAddressInfo:'www.exept.de' serviceName:nil
17c13e65f96a class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15508
diff changeset
 11665
            domain:#'AF_INET6' type:nil protocol:nil flags:nil
18107
d46c13a0795b Merged 48ba10eeb21c and 3c118b86a6db (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18105 15802
diff changeset
 11666
     self getAddressInfo:'www.baden-wrttemberg.de' serviceName:nil
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11667
            domain:#'AF_INET' type:#stream protocol:nil flags:nil
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11668
    "
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11669
!
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11670
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11671
getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11672
    "answer an Array containing the hostName and serviceName
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11673
     in socketAddress.
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11674
     This is the generic version of getHostByAddr, however, if supported by the OS,
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11675
     this returns multiple hostnames (if appropriate)"
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11676
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11677
    |error errorString hostName serviceName|
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11678
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11679
%{ /* STACK: 100000 */  /* Don't know whether DNS, NIS, LDAP or whatever is consulted */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11680
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11681
#undef xxNI_NUMERICHOST /* remove xx to test gethost...() path */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11682
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11683
#if !defined(NO_SOCKET)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11684
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11685
# ifndef NI_MAXHOST
8788
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 11686
#  define NI_MAXHOST 1025
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11687
#  define NI_MAXSERV 64
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11688
# endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11689
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11690
    char host[NI_MAXHOST];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11691
    char service[NI_MAXSERV];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11692
    char *hp = 0, *sp = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11693
    int hsz = 0, ssz = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11694
    int ret, __flags;
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11695
    char *bp;
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11696
    int nInstBytes, sockAddrSize;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11697
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11698
    if (wantHostName == true) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11699
	hp = host;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11700
	hsz = sizeof(host);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11701
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11702
    if (wantServiceName == true) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11703
	sp = service;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11704
	ssz = sizeof(service);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11705
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11706
    if (hp == 0 && sp == 0) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11707
	error = @symbol(badArgument);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11708
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11709
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11710
    if (!__isBytes(socketAddress)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11711
	error = @symbol(badArgument1);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11712
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11713
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11714
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11715
    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11716
    sockAddrSize = __byteArraySize(socketAddress);
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11717
    sockAddrSize -= nInstBytes;
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11718
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11719
    if (!__isSmallInteger(flags)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11720
	error = @symbol(badArgument5);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11721
	goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11722
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11723
    __flags = __intVal(flags);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11724
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11725
#if defined(NI_NUMERICHOST)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11726
    if (useDatagram == true) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11727
	__flags |= NI_DGRAM;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11728
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11729
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11730
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11731
	bp = (char *)(__byteArrayVal(socketAddress));
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11732
	bp += nInstBytes;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11733
	__BEGIN_INTERRUPTABLE__
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11734
	ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11735
			  hp, hsz, sp, ssz, __flags);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11736
	__END_INTERRUPTABLE__
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11737
    } while (ret == EAI_SYSTEM && errno == EINTR);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11738
    if (ret != 0) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11739
	switch (ret) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11740
	case EAI_FAMILY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11741
	    error = @symbol(badProtocol);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11742
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11743
	case EAI_SOCKTYPE:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11744
	    error = @symbol(badSocketType);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11745
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11746
	case EAI_BADFLAGS:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11747
	    error = @symbol(badFlags);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11748
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11749
	case EAI_NONAME:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11750
	    error = @symbol(unknownHost);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11751
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11752
	case EAI_SERVICE:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11753
	    error = @symbol(unknownService);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11754
	    break;
11626
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 11755
#ifdef EAI_ADDRFAMILY
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11756
	case EAI_ADDRFAMILY :
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11757
	    error = @symbol(unknownHostForProtocol);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11758
	    break;
11626
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 11759
#endif
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 11760
#ifdef EAI_NODATA
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11761
	case EAI_NODATA:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11762
	    error = @symbol(noAddress);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11763
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11764
#endif
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11765
	case EAI_MEMORY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11766
	    error = @symbol(allocationFailure);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11767
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11768
	case EAI_FAIL:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11769
	    error = @symbol(permanentFailure);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11770
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11771
	case EAI_AGAIN:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11772
	    error = @symbol(tryAgain);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11773
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11774
	case EAI_SYSTEM:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11775
	    error = @symbol(systemError);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11776
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11777
	default:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11778
	    error = @symbol(unknownError);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11779
	}
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11780
	errorString = __MKSTRING(gai_strerror(ret));
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11781
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11782
    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11783
# else /* ! NI_NUMERICHOST */
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11784
    {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11785
	/*
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11786
	 * Do it using gethostbyaddr()
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11787
	 */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11788
	struct sockaddr_in *sa;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11789
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11790
	if (sockAddrSize < sizeof(*sa)) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11791
	    error = @symbol(badArgument1);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11792
	    goto err;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11793
	}
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11794
	bp = (char *)(__byteArrayVal(socketAddress));
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11795
	bp += nInstBytes;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11796
	sa = (struct sockaddr_in *)bp;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11797
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11798
	if (sp) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11799
	    struct servent *servp;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11800
	    char *__proto = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11801
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11802
	    __proto = (useDatagram == true ? "udp" : "tcp");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11803
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11804
	    servp = getservbyport(sa->sin_port, __proto);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11805
	    if (servp) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11806
		sp = servp->s_name;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11807
	    }
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11808
	}
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11809
	if (hp) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11810
	    struct hostent *hostp;
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11811
#  ifdef USE_H_ERRNO
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11812
	    do {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11813
		bp = (char *)(__byteArrayVal(socketAddress));
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11814
		bp += nInstBytes;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11815
		sa = (struct sockaddr_in *)bp;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11816
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11817
		/* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11818
		 */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11819
		hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11820
		/* __END_INTERRUPTABLE__ */
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11821
	    } while ((hostp == NULL)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11822
		      && ((h_errno == TRY_AGAIN)
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11823
			  || errno == EINTR
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11824
#   ifdef IRIX5_3
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11825
			  || (errno == ECONNREFUSED)
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11826
#   endif
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11827
			 )
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11828
	    );
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11829
	    if (hostp == 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11830
		switch (h_errno) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11831
		case HOST_NOT_FOUND:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11832
		    errorString = @symbol(unknownHost);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11833
		    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11834
		case NO_ADDRESS:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11835
		    errorString = @symbol(noAddress);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11836
		    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11837
		case NO_RECOVERY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11838
		    errorString = @symbol(permanentFailure);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11839
		    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11840
		case TRY_AGAIN:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11841
		    errorString = @symbol(tryAgain);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11842
		    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11843
		default:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11844
		    errorString = @symbol(unknownError);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11845
		    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11846
		}
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11847
		error = __mkSmallInteger(h_errno);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11848
		goto err;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11849
	    }
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11850
#  else /* !USE_H_ERRNO */
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11851
	    hostp = gethostbyaddr(sa->sin_addr, sockAddrSize, sa->sin_family);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11852
	    if (hostp == 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11853
		errorString = @symbol(unknownHost);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11854
		error = __mkSmallInteger(-1);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11855
		goto err;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11856
	    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11857
#  endif /* !USE_H_ERRNO*/
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11858
	    hp = hostp->h_name;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11859
	}
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11860
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11861
# endif /* ! NI_NUMERICHOST */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11862
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11863
    if (hp)
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11864
	hostName = __MKSTRING(hp);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11865
    if (sp)
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11866
	serviceName = __MKSTRING(sp);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11867
err:;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11868
#else
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11869
    error = @symbol(notImplemented);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11870
#endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11871
%}.
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11872
    error notNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11873
	^ (HostAddressLookupError new
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11874
		parameter:error;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11875
		messageText:' - ', errorString;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11876
		request:thisContext message) raiseRequest.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11877
    ].
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11878
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11879
    ^ Array with:hostName with:serviceName
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11880
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11881
    "
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11882
     self getNameInfo:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11883
	(self getAddressInfo:'localhost' serviceName:'echo'
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11884
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11885
	 wantHostName:true wantServiceName:true datagram:false flags:0
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11886
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11887
     self getNameInfo:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11888
	(self getAddressInfo:'exept.de' serviceName:'echo'
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11889
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11890
	 wantHostName:true wantServiceName:true datagram:false flags:0
8788
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 11891
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 11892
     self getNameInfo:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11893
	(self getAddressInfo:'217.172.183.25' serviceName:'22'
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11894
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11895
	 wantHostName:true wantServiceName:true datagram:false flags:0
8788
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 11896
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 11897
     self getNameInfo:
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11898
	(self getAddressInfo:'1.2.3.4' serviceName:'22'
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11899
		domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 11900
	 wantHostName:true wantServiceName:true datagram:false flags:0
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11901
    "
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11902
!
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11903
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11904
primGetAddressInfo:hostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11905
    "answer an Array of socket addresses for serviceName on hostName
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11906
     Domain, type, protocol may be nil or specify a hint for the socket
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11907
     addresses to be returned."
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11908
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11909
    |error errorString result|
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11910
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11911
%{ /* UNLIMITEDSTACK */  /* Don't know whether DNS, NIS, LDAP or whatever is consulted */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11912
#undef xxAI_NUMERICHOST /* remove xx to test gethost...() path */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11913
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11914
#if !defined(NO_SOCKET)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11915
    char *__hostName, *__serviceName;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11916
    int ret, cnt = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11917
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11918
    if (hostName == nil) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11919
        __hostName = 0;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11920
    } else if (__isStringLike(hostName)) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11921
        __hostName = __stringVal(hostName);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11922
    } else {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11923
        error = @symbol(badArgument1);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11924
        goto out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11925
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11926
    if (serviceName == nil) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11927
        __serviceName = 0;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11928
    } else if (__isStringLike(serviceName)) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11929
        __serviceName = __stringVal(serviceName);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11930
    } else {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11931
        error = @symbol(badArgument2);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11932
        goto out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11933
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11934
    if (__hostName == 0 && __serviceName == 0) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11935
        error = @symbol(badArgument);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11936
        goto out;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11937
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11938
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11939
{
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11940
# if defined(AI_NUMERICHOST)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11941
    /*
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11942
     * Use getaddrinfo()
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11943
     */
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11944
    struct addrinfo hints = {0};
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11945
    struct addrinfo *info = NULL, *infop;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11946
15798
2f79f67ae7b7 has no A_IDN
Claus Gittinger <cg@exept.de>
parents: 15795
diff changeset
 11947
#if defined(AI_IDN)
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11948
    hints.ai_flags = AI_IDN | AI_CANONIDN;      // map non-ascii domain names to IDN format
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11949
#endif
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11950
    if (__isSmallInteger(domain))
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11951
        hints.ai_family = __intVal(domain);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11952
    if (__isSmallInteger(type))
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11953
        hints.ai_socktype = __intVal(type);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11954
    if (__isSmallInteger(proto))
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11955
        hints.ai_protocol = __intVal(proto);
15794
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11956
    if (__isSmallInteger(flags))
543ec1294476 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15792
diff changeset
 11957
        hints.ai_flags |= __intVal(flags);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11958
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11959
    do {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11960
        /* reload */
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11961
        if (__hostName) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11962
            __hostName = __stringVal(hostName);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11963
        }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11964
        if (__serviceName) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11965
            __serviceName = __stringVal(serviceName);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11966
        }
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11967
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11968
//        __BEGIN_INTERRUPTABLE__
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11969
        ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11970
//        __END_INTERRUPTABLE__
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11971
    } while (ret == EAI_SYSTEM && errno == EINTR);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11972
    if (ret != 0) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11973
        switch (ret) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11974
        case EAI_FAMILY:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11975
            error = @symbol(badProtocol);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11976
            break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11977
        case EAI_SOCKTYPE:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11978
            error = @symbol(badSocketType);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11979
            break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11980
        case EAI_BADFLAGS:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11981
            error = @symbol(badFlags);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11982
            break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11983
        case EAI_NONAME:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11984
            error = @symbol(unknownHost);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11985
            break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11986
        case EAI_SERVICE:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11987
            error = @symbol(unknownService);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11988
            break;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11989
#ifdef EAI_ADDRFAMILY
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11990
        case EAI_ADDRFAMILY :
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11991
            error = @symbol(unknownHostForProtocol);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11992
            break;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11993
#endif
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11994
#ifdef EAI_NODATA
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11995
        case EAI_NODATA:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11996
            error = @symbol(noAddress);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11997
            break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11998
#endif
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 11999
        case EAI_MEMORY:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12000
            error = @symbol(allocationFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12001
            break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12002
        case EAI_FAIL:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12003
            error = @symbol(permanentFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12004
            break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12005
        case EAI_AGAIN:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12006
            error = @symbol(tryAgain);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12007
            break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12008
        case EAI_SYSTEM:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12009
            error = @symbol(systemError);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12010
            break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12011
        default:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12012
            error = @symbol(unknownError);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12013
        }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12014
        errorString = __MKSTRING(gai_strerror(ret));
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12015
        goto err;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12016
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12017
    for (cnt=0, infop=info; infop; infop=infop->ai_next)
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12018
        cnt++;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12019
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12020
    result = __ARRAY_NEW_INT(cnt);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12021
    if (result == nil) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12022
        error = @symbol(allocationFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12023
        goto err;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12024
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12025
    for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12026
        OBJ o, resp;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12027
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12028
        resp = __ARRAY_NEW_INT(6);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12029
        if (resp == nil) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12030
            error = @symbol(allocationFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12031
            goto err;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12032
        }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12033
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12034
        __ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12035
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12036
        __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12037
        __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12038
        __ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12039
        __ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12040
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12041
        __PROTECT__(resp);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12042
        o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12043
        __UNPROTECT__(resp);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12044
        if (o == nil) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12045
            error = @symbol(allocationFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12046
            goto err;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12047
        }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12048
        memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12049
       __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12050
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12051
        if (infop->ai_canonname) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12052
            __PROTECT__(resp);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12053
            o = __MKSTRING(infop->ai_canonname);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12054
            __UNPROTECT__(resp);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12055
            if (o == nil) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12056
                error = @symbol(allocationFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12057
                goto err;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12058
            }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12059
            __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12060
        }
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12061
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12062
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12063
err:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12064
    if (info) freeaddrinfo(info);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12065
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12066
# else /* ! AI_NUMERICHOST =============================================================*/
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12067
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12068
    /*
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12069
     * Use getservbyname() / gethostByName()
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12070
     */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12071
    struct hostent *hp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12072
    char **addrpp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12073
    int port = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12074
    int i;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12075
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12076
    if (__serviceName) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12077
        struct servent *sp;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12078
        char *__proto = 0;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12079
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12080
        if (__isStringLike(protoArg))
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12081
            __proto = __stringVal(protoArg);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12082
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12083
        sp = getservbyname(__serviceName, __proto);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12084
        if (sp == NULL) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12085
            errorString = @symbol(unknownService);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12086
            error = __mkSmallInteger(-3);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12087
            goto err;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12088
        }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12089
        port = sp->s_port;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12090
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12091
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12092
    if (__hostName) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12093
#  ifdef USE_H_ERRNO
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12094
        do {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12095
            if (hostName == nil) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12096
                __hostName = 0;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12097
            } else if (__isStringLike(hostName)) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12098
                __hostName = __stringVal(hostName);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12099
            }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12100
            /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12101
             * uses a static data area
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12102
             */
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12103
            __BEGIN_INTERRUPTABLE__
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12104
            hp = gethostbyname(__hostName);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12105
            __END_INTERRUPTABLE__
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12106
        } while ((hp == NULL)
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12107
                  && (
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12108
                        (h_errno == TRY_AGAIN)
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12109
                      || errno == EINTR
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12110
#   ifdef IRIX5_3
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12111
                      || (errno == ECONNREFUSED)
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12112
#   endif
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12113
                     )
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12114
        );
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12115
        if (hp == 0) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12116
            switch (h_errno) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12117
            case HOST_NOT_FOUND:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12118
                errorString = @symbol(unknownHost);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12119
                break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12120
            case NO_ADDRESS:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12121
                errorString = @symbol(noAddress);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12122
                break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12123
            case NO_RECOVERY:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12124
                errorString = @symbol(permanentFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12125
                break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12126
            case TRY_AGAIN:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12127
                errorString = @symbol(tryAgain);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12128
                break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12129
            default:
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12130
                errorString = @symbol(unknownError);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12131
                break;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12132
            }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12133
            error = __mkSmallInteger(h_errno);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12134
            goto err;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12135
        }
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12136
#  else /* !USE_H_ERRNO */
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12137
        hp = gethostbyname(__hostName);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12138
        if (hp == 0) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12139
            errorString = @symbol(unknownHost);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12140
            error = __mkSmallInteger(-1);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12141
            goto err;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12142
        }
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12143
#  endif /* !USE_H_ERRNO*/
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12144
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12145
        if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12146
            errorString = @symbol(unknownHost);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12147
            error = __mkSmallInteger(-2);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12148
            goto err;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12149
        }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12150
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12151
        for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12152
            cnt++;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12153
        addrpp = hp->h_addr_list;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12154
    } else {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12155
        cnt = 1;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12156
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12157
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12158
    result = __ARRAY_NEW_INT(cnt);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12159
    if (result == nil) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12160
        error = @symbol(allocationFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12161
        goto err;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12162
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12163
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12164
    for (i = 0; i < cnt; i++) {
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12165
        OBJ o, resp;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12166
        struct sockaddr_in *sa;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12167
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12168
        resp = __ARRAY_NEW_INT(6);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12169
        if (resp == nil) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12170
            error = @symbol(allocationFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12171
            goto err;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12172
        }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12173
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12174
        __ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12175
        __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12176
        __ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12177
        __ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12178
        __PROTECT__(resp);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12179
        o = __BYTEARRAY_NEW_INT(sizeof(*sa));
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12180
        __UNPROTECT__(resp);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12181
        if (o == nil) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12182
            error = @symbol(allocationFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12183
            goto err;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12184
        }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12185
        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12186
        sa = (struct sockaddr_in *)__byteArrayVal(o);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12187
        sa->sin_port = port;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12188
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12189
        if (__hostName) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12190
            sa->sin_family = hp->h_addrtype;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12191
            memcpy(&sa->sin_addr, *addrpp, hp->h_length);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12192
            __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12193
            if (hp->h_name) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12194
                __PROTECT__(resp);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12195
                o = __MKSTRING(hp->h_name);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12196
                __UNPROTECT__(resp);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12197
                if (o == nil) {
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12198
                    error = @symbol(allocationFailure);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12199
                    goto err;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12200
                }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12201
                __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12202
            }
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12203
            addrpp++;
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12204
        } else{
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12205
            __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12206
        }
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12207
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12208
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12209
err:;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12210
# endif /* ! AI_NUMERICHOST */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12211
}
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12212
#else /* ! HAS_SOCKET */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12213
    error = @symbol(notImplemented);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12214
#endif
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12215
out:;
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12216
%}.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12217
    error notNil ifTrue:[
15792
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12218
        errorString notNil ifTrue:[
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12219
            ^ errorString.
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12220
        ].
b0f9b26a398e class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15513
diff changeset
 12221
        ^ error.
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12222
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12223
    ^ result.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 12224
! !
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 12225
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12226
!UnixOperatingSystem::SocketHandle methodsFor:'accepting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12227
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12228
acceptWithPeerAddressBuffer:peerOrNil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12229
    "accept a connection on a server port.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12230
     Returns a new SocketHandle or nil if the operation
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12231
     would block.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12232
     If peerOrNil is set to a ByteArray, the socket address
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12233
     of the connection peer is stored into it."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12234
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12235
    |error newFd|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12236
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12237
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12238
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12239
    int sock, newSock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12240
    struct sockaddr *sap;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12241
    int alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12242
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12243
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12244
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12245
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12246
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12247
    if (peerOrNil != nil &&
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12248
	(!__isNonNilObject(peerOrNil) ||
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12249
	 (__intVal(__ClassInstPtr(__qClass(peerOrNil))->c_flags) & ARRAYMASK) != BYTEARRAY)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12250
	error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12251
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12252
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12253
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12254
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12255
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12256
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12257
    if (peerOrNil == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12258
	alen = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12259
	sap = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12260
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12261
	alen =  __byteArraySize(peerOrNil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12262
	sap = (struct sockaddr *)__byteArrayVal(peerOrNil);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12263
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12264
    newSock = accept(sock, sap, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12265
    if (newSock < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12266
	switch (errno) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12267
	case EINTR:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12268
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12269
	    goto again;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12270
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12271
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12272
	case EWOULDBLOCK:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12273
# if defined(EAGAIN) && (EAGAIN != EWOULDBLOCK)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12274
	case EAGAIN:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12275
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12276
#else
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12277
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12278
	case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12279
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12280
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12281
	    RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12282
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12283
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12284
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12285
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12286
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12287
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12288
    newFd = __mkSmallInteger(newSock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12289
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12290
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12291
#endif /* not NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12292
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12293
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12294
	^ self error:error.
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12295
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12296
    ^ self class for:newFd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12297
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12298
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12299
!UnixOperatingSystem::SocketHandle methodsFor:'binding'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12300
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12301
bindTo:socketAddress
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12302
    "low level bind -
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12303
     Set the local address of the socket"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12304
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12305
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12306
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12307
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12308
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12309
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12310
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12311
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12312
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12313
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12314
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12315
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12316
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12317
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12318
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12319
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12320
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12321
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12322
    sockaddr_size = __byteArraySize(socketAddress);
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
 12323
    sock = __smallIntegerVal(__INST(fd));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12324
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12325
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12326
    ret = bind(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12327
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12328
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12329
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12330
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12331
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12332
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12333
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12334
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12335
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12336
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12337
    err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12338
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12339
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12340
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12341
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12342
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12343
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12344
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12345
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12346
     (Socket domain:#inet type:#stream)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12347
	 bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12348
	 reuseAddress:false ;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12349
     yourself
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12350
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12351
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12352
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12353
!UnixOperatingSystem::SocketHandle methodsFor:'connecting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12354
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12355
cancelConnect
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12356
    "cancel an asynchronous connect in progress"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12357
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12358
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12359
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12360
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12361
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12362
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12363
    int ret;
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
 12364
    struct sockaddr sockaddr;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12365
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12366
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12367
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12368
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12369
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12370
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12371
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12372
    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12373
     * (dis-) connect by connecting to AF_UNSPEC socket
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12374
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12375
again:
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
 12376
    sockaddr.sa_family = AF_UNSPEC;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12377
    ret = connect(sock, &sockaddr, sizeof(sockaddr));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12378
    if (ret < 0) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12379
       switch(errno) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12380
	   case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12381
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12382
	    case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12383
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12384
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12385
		goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12386
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12387
	    default:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 12388
		error = __mkSmallInteger(errno);
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12389
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12390
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12391
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12392
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12393
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12394
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12395
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12396
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12397
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12398
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12399
    ].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12400
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12401
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12402
connectTo:socketAddress
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12403
    "low level connect; connect to a socket address.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12404
     Return true if connection has been established,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12405
     false, when the connection has been initiated but not yet
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12406
     completed. If an error occured, an OSError is raised"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12407
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12408
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12409
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12410
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12411
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12412
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12413
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12414
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12415
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12416
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12417
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12418
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12419
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12420
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12421
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12422
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12423
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12424
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12425
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12426
    sockaddr_size = __qSize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12427
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12428
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12429
    ret = connect(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12430
    if (ret >= 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12431
	RETURN(true)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12432
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12433
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12434
    switch(errno) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12435
	case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12436
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12437
	case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12438
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12439
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12440
	    goto again;
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12441
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12442
# if defined(EINPROGRESS) || defined(EALREADY)
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12443
#  ifdef EINPROGRESS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12444
	case EINPROGRESS:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12445
#  endif
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12446
#  ifdef EALREADY
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12447
	case EALREADY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12448
#  endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12449
	    RETURN(false);
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12450
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12451
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12452
    default:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 12453
	error = __mkSmallInteger(errno);
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12454
	break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12455
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12456
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12457
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12458
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12459
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12460
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12461
	 ^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12462
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12463
    ^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12464
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12465
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12466
     Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:7)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12467
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12468
     Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:5768)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12469
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12470
     Socket newTCP connectTo:(IPSocketAddress hostAddress:#[1 2 3 4] port:7)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12471
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12472
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12473
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12474
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12475
!UnixOperatingSystem::SocketHandle methodsFor:'datagram transmission'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12476
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12477
receiveFrom:socketAddress buffer:aDataBuffer start:startIndex for:nBytes flags:flags
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12478
    "receive datagramm data - put address of originating host into
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12479
     anAddressBuffer, data into aBuffer. For ST-80 compatibility,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12480
     the addressBuffer may be a non-ByteArray; then, it must understand
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12481
     the addressBytes-message (i.e. be a SocketAddress instance).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12482
     Return the number of bytes received, or a negative number on error.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12483
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12484
     The thread blocks until data arrives - you may want to wait before
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12485
     receiving, using #readWait or #readWaitWithTimeout:."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12486
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12487
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12488
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12489
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12490
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12491
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12492
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12493
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12494
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12495
    int alen0, alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12496
    int n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12497
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12498
    int __flags, __startIndex, __nBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12499
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12500
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12501
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12502
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12503
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12504
    if (!__isSmallInteger(startIndex) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12505
	(__startIndex = __intVal(startIndex)-1) < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12506
	if (startIndex == nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12507
	    __startIndex = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12508
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12509
	    error = @symbol(badArgument3);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12510
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12511
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12512
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12513
    if (__isSmallInteger(nBytes)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12514
	__nBytes = __intVal(nBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12515
    } else if (nBytes == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12516
	__nBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12517
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12518
	error = @symbol(badArgument4);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12519
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12520
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12521
    if (!__isInteger(flags)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12522
	error = @symbol(badArgument5);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12523
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12524
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12525
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12526
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12527
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12528
    oClass = __Class(aDataBuffer);
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 12529
    switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12530
	case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12531
	case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12532
	case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12533
	case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12534
	case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12535
	case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12536
	case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12537
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12538
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12539
	    error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12540
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12541
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12542
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 12543
    nInstVars = __intVal(__ClassInstPtr(oClass)->c_ninstvars);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12544
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12545
    objSize = __qSize(aDataBuffer) - nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12546
    nInstBytes += __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12547
    objSize -= __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12548
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12549
    if (__nBytes >= 0 &&__nBytes < objSize) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12550
	objSize = __nBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12551
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12552
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12553
    if (socketAddress == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12554
	alen0 = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12555
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12556
	if (!__isNonNilObject(socketAddress) ||
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12557
	    (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12558
	    error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12559
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12560
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12561
	alen0 = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12562
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12563
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12564
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12565
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12566
    alen = alen0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12567
    if (alen)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12568
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12569
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12570
    n = recvfrom(sock, cp, objSize, __flags, saPtr, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12571
    if (n < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12572
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12573
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12574
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12575
	} else {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 12576
	    error = __mkSmallInteger(errno);
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12577
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12578
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12579
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12580
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12581
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12582
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12583
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12584
    ^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12585
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12586
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12587
sendTo:socketAddress buffer:aDataBuffer start:startIndex for:maxBytes flags:flags
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12588
    "send datagramm data - fetch address of destination host from
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12589
     anAddressBuffer, data from aDataBuffer starting at startIndex,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12590
     sending count bytes.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12591
     SocketAddress must be an instance of SocketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12592
     Return the number of bytes transmitted, or a negative number on error."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12593
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12594
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12595
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12596
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12597
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12598
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12599
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12600
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12601
    int alen, n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12602
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12603
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12604
    int __flags;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12605
    int offs, __startIndex, __maxBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12606
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12607
    if (!__isSmallInteger(__INST(fd))) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12608
	error = @symbol(badFd);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12609
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12610
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12611
    if (!__isSmallInteger(startIndex) ||
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12612
	(__startIndex = __intVal(startIndex)-1) < 0) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12613
	if (startIndex == nil) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12614
	    __startIndex = 0;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12615
	} else {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12616
	    error = @symbol(badArgument3);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12617
	    goto err;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12618
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12619
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12620
    if (__isSmallInteger(maxBytes)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12621
	__maxBytes = __intVal(maxBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12622
    } else if (maxBytes == nil) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12623
	__maxBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12624
    } else {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12625
	error = @symbol(badArgument4);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12626
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12627
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12628
    if (!__isInteger(flags)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12629
	error = @symbol(badArgument5);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12630
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12631
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12632
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12633
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12634
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12635
    oClass = __Class(aDataBuffer);
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 12636
    switch (__intVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12637
	case BYTEARRAY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12638
	    offs = __startIndex;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12639
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12640
	case WORDARRAY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12641
	case SWORDARRAY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12642
	    offs = __startIndex * 2;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12643
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12644
	case LONGARRAY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12645
	case SLONGARRAY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12646
	    offs = __startIndex * 4;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12647
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12648
	case LONGLONGARRAY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12649
	case SLONGLONGARRAY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12650
	    offs = __startIndex * 8;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12651
# ifdef __NEED_LONGLONG_ALIGN
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12652
	    offs += 4;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12653
# endif
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12654
	case FLOATARRAY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12655
	    offs = __startIndex * sizeof(float);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12656
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12657
	case DOUBLEARRAY:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12658
	    offs = __startIndex * sizeof(double);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12659
# ifdef __NEED_DOUBLE_ALIGN
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12660
	    offs += 4;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12661
# endif
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12662
	    break;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12663
	default:
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12664
	    error = @symbol(badArgument2);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12665
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12666
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12667
15312
2c69166c1fb2 all stx macros begin with double underline (eg. __qClass instead of _qClass)
Claus Gittinger <cg@exept.de>
parents: 15301
diff changeset
 12668
    nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12669
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12670
    objSize = __qSize(aDataBuffer) - nInstBytes - offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12671
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12672
    if (__maxBytes >= 0 && __maxBytes < objSize) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12673
# ifdef DGRAM_DEBUG
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12674
	printf("cut off ...\n");
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12675
# endif
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12676
	objSize = __maxBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12677
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12678
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12679
    if (socketAddress == nil) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12680
	alen = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12681
    } else {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12682
	if (! __isByteArrayLike(socketAddress)) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12683
	    error = @symbol(badArgument1);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12684
	    goto err;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12685
	}
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12686
	alen = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12687
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12688
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12689
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12690
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12691
    if (alen)
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12692
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12693
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes + offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12694
    n = sendto(sock, cp, objSize, __flags, saPtr, alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12695
    if (n < 0) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12696
	if (errno == EINTR) {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12697
	    __HANDLE_INTERRUPTS__;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12698
	    goto again;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12699
	} else {
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12700
	    error = __mkSmallInteger(errno);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12701
	    goto err;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12702
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12703
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12704
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12705
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12706
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12707
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12708
    ^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12709
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12710
6434
f23d12900e18 category rename
Claus Gittinger <cg@exept.de>
parents: 6421
diff changeset
 12711
!UnixOperatingSystem::SocketHandle methodsFor:'initialization'!
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12712
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12713
domain:domainArg type:typeArg protocol:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12714
    "set up socket with domain, type and protocol number.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12715
     This is a low level entry; no binding, listening or connect is done.
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12716
     All arguments must be symbols from one of
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12717
     domainArg: #AF_INET, #AF_UNIX, #AF_APPLETALK (#inet, #unix, #appletalk, #x25) ..
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12718
     type: #SOCK_STREAM, #SOCK_DGRAM (#stream, #datagram, #raw) ..
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12719
     protocol: #tcp, #udp, #raw ..
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12720
    "
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12721
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12722
    |error domainCode typeCode protocolNumber|
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12723
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12724
    domainCode := OperatingSystem domainCodeOf:domainArg.
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12725
    typeCode := OperatingSystem socketTypeCodeOf:typeArg.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12726
    protocolArg notNil ifTrue:[
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12727
	protocolNumber := self class protocolCodeOf:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12728
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12729
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12730
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12731
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12732
    int dom, typ, proto = 0, sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12733
    int on = 1;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12734
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12735
    if (__INST(fd) != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12736
	error = @symbol(internalError);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12737
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12738
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12739
    if (! __isSmallInteger(domainCode)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12740
	error = @symbol(badArgument1);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12741
	goto err;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12742
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12743
    if (! __isSmallInteger(typeArg)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12744
	error = @symbol(badArgument2);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12745
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12746
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12747
    if (protocolNumber != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12748
	if (!__isSmallInteger(protocolNumber)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12749
	    error = @symbol(badArgument3);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12750
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12751
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12752
	proto = __smallIntegerVal(protocolNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12753
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12754
    dom = __smallIntegerVal(domainCode);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12755
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12756
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12757
     * get socket-type and protocol-type
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12758
     */
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12759
    typ = __intVal(typeArg);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12760
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12761
againSocket:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12762
    sock = socket(dom, typ, proto);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12763
    if (sock < 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12764
	if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12765
	    __HANDLE_INTERRUPTS__;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12766
	    goto againSocket;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12767
	} else
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12768
# if defined(EPROTONOSUPPORT) /* for SGI */
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12769
	if (errno == EPROTONOSUPPORT && proto != 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12770
	    proto = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12771
	    goto againSocket;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12772
	} else
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12773
# endif
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12774
	{
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12775
	    error = __mkSmallInteger(errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12776
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12777
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12778
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12779
    __INST(fd) = __mkSmallInteger(sock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12780
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12781
err:;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12782
# else /* NOSOCKET */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12783
    error := @symbol(notImplemented);
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12784
# endif /* NOSOCKET */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12785
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12786
    error notNil ifTrue:[
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12787
	^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12788
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12789
    self register.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12790
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12791
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12792
     self new domain:#inet type:#stream protocol:nil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12793
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12794
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12795
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12796
!UnixOperatingSystem::SocketHandle methodsFor:'misc'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12797
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12798
getOptionsLevel:level name:name
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12799
    "answer a ByteArray containing the socket option value
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12800
     named name at level"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12801
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12802
    |error bytes size|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12803
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12804
    bytes := ByteArray new:256.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12805
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12806
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12807
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12808
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12809
    int intval, sz;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12810
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12811
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12812
    if (!__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12813
	error = @symbol(badFd);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12814
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12815
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12816
    if (!__bothSmallInteger(level, name)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12817
	error = @symbol(badArgument);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12818
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12819
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12820
    if (!__isByteArray(bytes)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12821
	error = @symbol(internalError);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12822
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12823
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12824
    p = __byteArrayVal(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12825
    sz = __byteArraySize(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12826
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12827
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12828
    if (getsockopt(sock, __smallIntegerVal(level), __smallIntegerVal(name), p, &sz) < 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12829
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12830
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12831
    size = __mkSmallInteger(sz);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12832
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12833
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12834
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12835
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12836
    error notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12837
	^ self error:error
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12838
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12839
    ^ bytes copyTo:size
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12840
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12841
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12842
listenFor:aNumber
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12843
    "start listening.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12844
     aNumber is the number of connect indications queues
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12845
     by the operating system"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12846
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12847
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12848
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12849
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12850
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12851
    int sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12852
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12853
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12854
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12855
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12856
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12857
    if (!__isSmallInteger(aNumber)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12858
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12859
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12860
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12861
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12862
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12863
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12864
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12865
    ret = listen(sock, __smallIntegerVal(aNumber));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12866
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12867
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12868
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12869
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12870
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12871
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12872
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12873
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12874
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12875
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12876
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12877
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12878
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12879
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12880
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12881
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12882
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12883
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12884
setOptionsLevel:level name:name value:value
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12885
    "set the socket option name at level to value.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12886
     Value may be one of SmallInteger, ByteArray or nil"
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12887
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12888
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12889
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12890
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12891
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12892
    int sock;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12893
    int __level, __name, intval, sz;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12894
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12895
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12896
    if (!__isSmallInteger(__INST(fd))) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12897
	error = @symbol(badFd);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12898
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12899
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12900
    if (__isSmallInteger(level)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12901
	__level = __smallIntegerVal(level);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12902
    } else if (level == @symbol(SOL_SOCKET)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12903
	__level = SOL_SOCKET;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12904
    } else {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12905
	error = @symbol(badArgument1);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12906
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12907
    }
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12908
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12909
    if (__isSmallInteger(name)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12910
	__name = __smallIntegerVal(name);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12911
    } else if (name == @symbol(SO_REUSEADDR)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12912
	__name = SO_REUSEADDR;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12913
    } else {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12914
	error = @symbol(badArgument2);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12915
	goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12916
    }
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12917
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12918
    if (__isSmallInteger(value)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12919
	intval = __intVal(value);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12920
	p = (char *) &intval;
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12921
	sz = sizeof(intval);
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12922
    } else if (__isByteArrayLike(value)) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12923
	p = __byteArrayVal(value);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12924
	sz = __byteArraySize(value);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12925
    } else {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12926
	error = @symbol(badArgument3);
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12927
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12928
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12929
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12930
    sock = __smallIntegerVal(__INST(fd));
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12931
    if (setsockopt(sock, __level, __name, p, sz) < 0) {
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12932
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12933
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12934
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12935
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12936
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12937
    error notNil ifTrue:[
13778
8e34483d10dd MAXPATHLEN cleanup;
Claus Gittinger <cg@exept.de>
parents: 13726
diff changeset
 12938
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12939
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12940
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12941
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12942
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12943
shutdown:anInteger
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12944
    "inform the socket that no more I/O will happen.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12945
     anInteger == 0   no reads will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12946
     anInteger == 1   no writes will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12947
     anInteger == 2   neither reads nor writes will be performed.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12948
		      Pending data is discarded. This is faster tha
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12949
		      close, which may wait until pending (written)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12950
		      data has been read by the other side"
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12951
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12952
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12953
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12954
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12955
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12956
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12957
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12958
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12959
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12960
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12961
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12962
    if (!__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12963
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12964
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12965
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12966
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12967
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12968
    ret = shutdown(__smallIntegerVal(__INST(fd)), __smallIntegerVal(anInteger));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12969
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12970
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12971
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12972
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12973
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12974
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12975
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12976
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12977
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12978
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12979
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12980
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12981
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12982
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12983
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12984
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12985
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12986
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12987
!UnixOperatingSystem::SocketHandle methodsFor:'queries'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12988
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12989
getNameInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12990
    "answer the my own address (I am bound to this address).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12991
     Note that this address may change after connect or accept."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12992
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12993
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12994
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12995
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12996
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12997
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12998
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12999
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13000
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13001
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13002
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13003
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13004
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13005
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13006
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13007
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13008
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13009
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13010
    sockaddr_size = __byteArraySize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13011
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13012
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13013
    ret = getsockname(sock, (struct sockaddr *)__byteArrayVal(socketAddress), &sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13014
    if (ret < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 13015
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13016
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13017
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13018
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13019
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13020
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13021
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13022
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13023
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13024
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13025
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13026
getPeerInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13027
    "answer the my own address (I am bound to this address).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13028
     Note that this address may change after connect or accept."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13029
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13030
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13031
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13032
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13033
#ifndef NO_SOCKET
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13034
    int __sock;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13035
    int __sockaddr_size;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13036
    int __ret;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13037
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13038
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13039
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13040
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13041
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13042
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13043
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13044
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13045
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13046
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13047
    __sockaddr_size = __byteArraySize(socketAddress);
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13048
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13049
    __sock = __smallIntegerVal(__INST(fd));
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13050
    __ret = getpeername(__sock, (struct sockaddr *)__byteArrayVal(socketAddress),
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13051
				&__sockaddr_size);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13052
    if (__ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13053
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13054
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13055
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13056
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13057
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13058
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13059
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13060
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13061
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13062
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13063
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13064
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13065
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13066
version
15802
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 13067
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.336 2013-11-12 11:17:51 stefan Exp $'
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 13068
!
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 13069
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 13070
version_CVS
15802
f2a9e65c3f8c class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 15798
diff changeset
 13071
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.336 2013-11-12 11:17:51 stefan Exp $'
18015
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
 13072
!
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
 13073
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
 13074
version_HG
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
 13075
7766f4524d50 Improvements in UnixOperatingSystem>>encodePath:/decodePath:.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18011
diff changeset
 13076
    ^ '$Changeset: <not expanded> $'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13077
! !
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 13078
14598
94f635641b30 class: UnixOperatingSystem
Stefan Vogel <sv@exept.de>
parents: 14591
diff changeset
 13079
18105
3a3a3e0ac47f Merged 619b61aee9e4 and 09837dc5030d (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 18104 15792
diff changeset
 13080
UnixOperatingSystem::FileDescriptorHandle initialize!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13081
UnixOperatingSystem initialize!