UnixOperatingSystem.st
author Stefan Vogel <sv@exept.de>
Fri, 29 Oct 2010 17:25:37 +0200
changeset 13110 7872ec1f7c6f
parent 13052 18217382f23d
child 13365 352699e52383
permissions -rw-r--r--
getCurrentDirectory
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
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
    18
		LastTimeInfoIsLocal CachedMountPoints CacheMountPointsTimeStamp'
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    19
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    20
	category:'OS-Unix'
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    21
!
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
    22
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    23
Object subclass:#FileDescriptorHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    24
	instanceVariableNames:'fd'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    25
	classVariableNames:'OpenFiles'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    26
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    27
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    28
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    29
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    30
OSFileHandle subclass:#FilePointerHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    31
	instanceVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    32
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    33
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    34
	privateIn:UnixOperatingSystem
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    35
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
    36
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    37
Object subclass:#FileStatusInfo
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    38
	instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    39
		numLinks'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    40
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    41
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    42
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    45
Object subclass:#MountInfo
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    46
	instanceVariableNames:'mountPointPath deviceOrRemotePath fsType attributeString'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    47
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    48
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    49
	privateIn:UnixOperatingSystem
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    50
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
    51
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
    52
Object subclass:#OSProcessStatus
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    53
	instanceVariableNames:'pid status code core'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    54
	classVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    55
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    56
	privateIn:UnixOperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    59
UnixOperatingSystem::FileDescriptorHandle subclass:#SocketHandle
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    60
	instanceVariableNames:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    61
	classVariableNames:'ProtocolCache'
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    62
	poolDictionaries:''
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
    63
	privateIn:UnixOperatingSystem
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    64
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
    65
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
!UnixOperatingSystem primitiveDefinitions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
#if defined(_AIX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
# ifndef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
#  define WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
# endif
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
#ifdef LINUX
8618
b78c623be1f7 disabled clock_gettime for now - temporary !
Claus Gittinger <cg@exept.de>
parents: 8601
diff changeset
    78
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    79
# define __xxUSE_GNU      /* new */
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    80
# undef HAS_UTS_DOMAINNAME
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
    81
# define NET_IF_SUPPORT
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    82
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    83
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    84
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    85
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
    86
# endif
3956
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    87
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    88
# ifndef _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    89
#  include <sys/types.h>
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    90
#  define _SYS_TYPES_H_INCLUDED_
51f1a9a4d63f changes for egcs (stdio uses __new / utsname)
Claus Gittinger <cg@exept.de>
parents: 3943
diff changeset
    91
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
  /* use inline string macros */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
# define __STRINGDEFS__
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
    94
# include "linuxIntern.h"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
# ifndef WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
#  define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
# endif
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
    99
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
# define WANT_SHM
3544
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
   101
# define HAS_SETENV
a654f7ac3a6e solaris has no setenv / unsetenv
Claus Gittinger <cg@exept.de>
parents: 3543
diff changeset
   102
# define HAS_UNSETENV
5886
78c6f9c5fe8e *** empty log message ***
penk
parents: 5855
diff changeset
   103
# include <time.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
12832
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   106
#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
   107
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
8901
824a89d0b5c7 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 8883
diff changeset
   110
#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
   111
# define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
 * notice: although many systems' include files
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
 * already block against multiple inclusion, some
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
 * do not. Therefore, this is done here again.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
 * (it does not hurt)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   119
 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
#ifdef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
# ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
#  include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
#  define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
# include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
# define _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
# include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
# define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
#endif /* WANT_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
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
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
# include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
# define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
# include <sys/ipc.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
# define _SYS_IPC_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
# include <sys/shm.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
# define _SYS_SHM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
#endif /* WANT_SHM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
#ifdef IRIX5
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
# include <sys/syssgi.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
#ifdef transputer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
# define unlink(f)      ((remove(f) == 0) ? 0 : -1)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
#else /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   156
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   157
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   158
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
# ifdef SYSV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
#  ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
#   include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
#   define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   168
#  ifndef _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   169
#   ifndef NO_SYS_PARAM_H
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
#    include <sys/param.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
#    define _SYS_PARAM_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   172
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   173
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   174
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
#  ifndef _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
#   include <sys/times.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
#   define _SYS_TIMES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
#  ifndef _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
#   include <sys/file.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
#   define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
12832
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   185
#  ifndef _UNISTD_H_INCLUDED_
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   186
#   include <unistd.h>
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   187
#   define _UNISTD_H_INCLUDED_
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   188
#  endif
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   189
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   190
#  ifndef _TIME_H_INCLUDED_
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   191
#   include <time.h>
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   192
#   define _TIME_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
# else /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   197
#  ifndef _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   198
#   include <sys/time.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   199
#   define _SYS_TIME_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   200
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   201
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   202
#  ifndef _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   203
#   include <sys/types.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   204
#   define _SYS_TYPES_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   205
#  endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   206
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
# endif /* not SYSV */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
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
# ifdef aix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
#  ifndef _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
#   include <time.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
#   define _TIME_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
#  ifndef _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
#   include <sys/select.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
#   define _SYS_SELECT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
# endif /* aix */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   221
# ifdef __osx__
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   222
#  include <time.h>
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   223
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   224
struct tm {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   225
	int     tm_sec;         /* seconds after the minute [0-60] */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   226
	int     tm_min;         /* minutes after the hour [0-59] */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   227
	int     tm_hour;        /* hours since midnight [0-23] */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   228
	int     tm_mday;        /* day of the month [1-31] */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   229
	int     tm_mon;         /* months since January [0-11] */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   230
	int     tm_year;        /* years since 1900 */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   231
	int     tm_wday;        /* days since Sunday [0-6] */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   232
	int     tm_yday;        /* days since January 1 [0-365] */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   233
	int     tm_isdst;       /* Daylight Savings Time flag */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   234
	long    tm_gmtoff;      /* offset from CUT in seconds */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
   235
	char    *tm_zone;       /* timezone abbreviation */
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   236
};
12832
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
   237
# endif /* __osx__ */
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
   238
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   239
# ifndef _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   240
#  include <stdio.h>
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   241
#  define _STDIO_H_INCLUDED_
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   242
# endif
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   243
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   244
# ifndef _PWD_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   245
#  include <pwd.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   246
#  define _PWD_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   247
# endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   248
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   249
# ifndef NO_GRP_H
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   250
#  ifndef _GRP_H_INCLUDED_
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   251
#   include <grp.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   252
#   define _GRP_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
#  endif
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   254
# endif
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   255
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
# ifndef _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
#  include <sys/stat.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
#  define _SYS_STAT_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
# ifndef _SYS_FILE_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   263
#  include <sys/file.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
#  define _SYS_FILE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   265
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   266
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   267
# ifndef _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   268
#  include <errno.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   269
#  define _ERRNO_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   270
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   271
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   272
# ifndef _FCNTL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   273
#  include <fcntl.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   274
#  define _FCNTL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   275
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   276
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   277
# ifndef _SYS_IOCTL_H_INCLUDED_
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   278
#  include <sys/ioctl.h>
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   279
#  define _SYS_IOCTL_H_INCLUDED_
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
# if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
#  define HAS_LOCALECONV
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 (HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
#  ifndef _LOCALE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
#   include <locale.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
#   define _LOCALE_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
6050
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   293
# if defined (HAS_FTIME)
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   294
#  include <sys/timeb.h>
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   295
# endif
af9ae36d6fdb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5886
diff changeset
   296
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   297
/*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   298
 * posix systems should define these ...
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
 * but on some (older) systems, they are not.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   300
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   301
# ifndef S_IXUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   302
#  ifdef S_IEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   303
#   define S_IXUSR S_IEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   304
#   define S_IXGRP (S_IEXEC>>3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   305
#   define S_IXOTH (S_IEXEC>>6)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   306
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   307
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   309
# ifndef S_IXUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
#  define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
#  define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
#  define S_IXOTH 0001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   314
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
# ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
#  define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
#  define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
#  define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
# ifndef S_IWUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
#  define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
#  define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
#  define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   327
# ifndef MAXPATHLEN
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   328
#  ifndef NO_SYS_PARAM_H
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   329
#   include <sys/param.h>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   330
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   331
#  ifndef MAXPATHLEN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   332
#   ifdef FILENAME_MAX  /* i.e. MSDOS_LIKE */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   333
#    define MAXPATHLEN FILENAME_MAX
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   334
#   else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   335
#    ifdef MAX_PATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
#     define MAXPATHLEN MAX_PATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   337
#    else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
#     define MAXPATHLEN 1024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
#    endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   340
#   endif
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
# if defined(HAS_UNAME)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
#  include <sys/utsname.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
# if defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
#  include <stropts.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
4285
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   352
# ifndef aix
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   353
#  include <sys/termios.h>
342a32e855b4 aix has no sys/termios.h
Claus Gittinger <cg@exept.de>
parents: 4262
diff changeset
   354
# endif
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   355
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
 * NeXT has no pid_t
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
 * and no sigemptyset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   360
# ifdef NEXT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
   typedef int pid_t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
#  define sigemptyset(set)      ((*(set) = 0L), 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
#  define HAS_GETDOMAINNAME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
#  define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
# ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   368
#  undef NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
#  undef HAS_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
#  define HAS_WAIT3
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
#  define HAS_SIGACTION
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
 * some (BSD ?) have no timezone global,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
 * but provide the info in struct timezone.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   377
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
# if defined(ultrix) || defined(sunos) || defined(NEXT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
#  define HAS_NO_TIMEZONE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
# endif
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
   381
# if defined(OSX)
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
   382
#  define HAS_NO_TIMEZONE
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
   383
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
 * 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
   387
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
# ifndef SA_RESTART
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
#  define SA_RESTART    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
# ifndef SA_SIGINFO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
#  define SA_SIGINFO    0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
# if defined(HAS_WAITPID) || defined(HAS_WAIT3)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
#  include <sys/wait.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
# if defined(HAS_SYSINFO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
#  include <sys/systeminfo.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   403
# ifdef LINUX
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   404
#  include <linux/kernel.h>
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   405
# endif
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
   406
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   407
# if defined(HAS_GETSYSINFO)
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   408
#  include <sys/sysinfo.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   409
#  include <machine/hal_sysinfo.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   410
#  include <machine/hal/cpuconf.h>
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   411
# endif
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   412
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   413
# if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   414
#  ifndef _UNISTD_H_INCLUDED_
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   415
#   include <unistd.h>
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   416
#   define _UNISTD_H_INCLUDED_
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   417
#  endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   418
# endif
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
   419
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
#endif /* not transputer */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
7709
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   422
#ifndef NO_SOCKET
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   423
# include <netdb.h>
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   424
#endif
c647b1de38ff *** empty log message ***
penk
parents: 7699
diff changeset
   425
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
 * 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
   428
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
#ifndef errno
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
 extern errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
 * some (old ?) systems do not define this ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
#if !defined(R_OK) && !defined(_AIX)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   437
# 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
   438
# define W_OK    2       /* Test for Write permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
# define X_OK    1       /* Test for eXecute permission */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
# 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
   441
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
   443
#define SIGHANDLER_ARG
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
#ifdef sunos
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   447
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
#ifdef NEXT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
# define NO_WAITPID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
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
 * where is the timezone info ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
 */
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   455
#ifdef HAS_TM_GMTOFF
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   456
# define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   457
#else
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   458
# if defined(HAS_NO_TIMEZONE)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   459
#  if defined(HAS_NO_TM_GMTOFF)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   460
#   define TIMEZONE(tmPtr)       0
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   461
#  else
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   462
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_gmtoff)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   463
#  endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
# else
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   465
#  if defined(HAS_ALTZONE)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   466
#   define TIMEZONE(tmPtr)       ((tmPtr)->tm_isdst == 0 ? timezone : altzone)
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   467
#  else  /*!HAS_ALTZONE*/
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   468
#   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
   469
#  endif /*!HAS_ALTZONE*/
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
   470
# endif
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   471
#endif
3595
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   472
#ifndef CONST
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   473
# ifdef __GNUC__
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   474
#  define CONST const
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   475
# else
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   476
#  define CONST /* nothing */
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   477
# endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   478
#endif
5fbfb33cd373 oops - not all compilers support const
Claus Gittinger <cg@exept.de>
parents: 3575
diff changeset
   479
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   480
#ifndef        FORK
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   481
# if defined(HAS_VFORK)
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   482
#  define     FORK            vfork
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   483
# else
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   484
#  define     FORK            fork
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   485
# endif
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   486
#endif
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   487
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
   488
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   489
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   490
/*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   491
 * Socket defines
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   492
 */
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
   493
#include "stxOSDefs.h"
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
   494
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   495
#ifdef NET_IF_SUPPORT  /* for mac address of interfaces */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   496
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   497
# ifndef _NET_IF_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   498
#  include <net/if.h>
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   499
#  define _NET_IF_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   500
# endif
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   501
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   502
# ifndef _SYS_IOCTL_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   503
#  include <sys/ioctl.h>
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   504
#  define _SYS_IOCTL_H_INCLUDED_
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   505
# endif
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   506
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   507
#endif /* NET_IF_SUPPORT */
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
   508
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   509
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   510
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   511
#if defined(TRY_AGAIN) || defined(HOST_NOT_FOUND)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   512
# define USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   513
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   514
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   515
#ifdef USE_H_ERRNO
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   516
# ifndef h_errno
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   517
 extern h_errno;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   518
# endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   519
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
   520
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   522
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
!UnixOperatingSystem primitiveFunctions!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   526
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
/*
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   528
 * some systems' system() is broken in that it does not correctly
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   529
 * handle EINTR and returns failure even though it actually succeeded.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
 * (LINUX is one of them)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
 * Here is a fixed version. If you encounter EINTR returns from
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
 * UnixOperatingSystem>>executeCommand, you ought to define WANT_SYSTEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
 * in the xxxIntern.h file to get this fixed version.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
 *
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
 * As an added BONUS, this system() enables interrupts while waiting
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
 * for the child which enables other threads to continue.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
 * (i.e. it is RT safe)
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
#if defined(WANT_SYSTEM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
/* # define DPRINTF(x)     printf x */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
# define DPRINTF(x)     /* nothing */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
# ifndef _STDDEF_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
#  include <stddef.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
#  define _STDDEF_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
# endif
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
# ifndef _STDLIB_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
#  include <stdlib.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
#  define _STDLIB_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
# endif
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
# ifndef _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
#  include <unistd.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   557
#  define _UNISTD_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
# endif
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
# ifndef _SYS_WAIT_H_INCLUDED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
#  include <sys/wait.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
#  define _SYS_WAIT_H_INCLUDED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   563
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
# ifndef _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
#  include <signal.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
#  define _SIGNAL_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   568
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   569
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   570
# ifndef _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
#  include <sys/types.h>
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
#  define _SYS_TYPES_H_INCLUDED_
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   573
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   574
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   575
# if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
#  define       __environ       environ
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   577
#  if 1 /* !defined(LINUX) */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
#   define      __sigemptyset   sigemptyset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
#   define      __sigaction     sigaction
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
#   define      __sigaddset     sigaddset
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
#   define      __sigprocmask   sigprocmask
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
#   define      __execve        execve
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
#   define      __wait          wait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
#   define      __waitpid       waitpid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
#  endif /* ! LINUX */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
   extern char **environ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
4882
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   589
# define      __sigprocmask   sigprocmask
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   590
# define      __execve        execve
fb4dafb482fb make it compilable under suse6.2
Claus Gittinger <cg@exept.de>
parents: 4853
diff changeset
   591
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
# define        SHELL_PATH      "/bin/sh"       /* Path of the shell.  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
# define        SHELL_NAME      "sh"            /* Name to give it.  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
static int
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
mySystem(line)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
    register CONST char *line;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
    int status, save;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
    pid_t pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
    struct sigaction sa, intr, quit;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
    sigset_t block, omask;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
    if (line == NULL)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   606
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
    sa.sa_handler = SIG_IGN;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
    sa.sa_flags = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
    __sigemptyset (&sa.sa_mask);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
    if (__sigaction (SIGINT, &sa, &intr) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   613
	DPRINTF(("1: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   614
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   615
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   616
    if (__sigaction (SIGQUIT, &sa, &quit) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   617
	save = errno;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   618
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   619
	errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   620
	DPRINTF(("2: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   621
	return -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
    __sigemptyset (&block);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
    __sigaddset (&block, SIGCHLD);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
    save = errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
    if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   628
	if (errno == ENOSYS)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   629
	    errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   630
	else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   631
	    save = errno;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   632
	    (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   633
	    (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   634
	    errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   635
	    DPRINTF(("3: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   636
	    return -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   637
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   638
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   639
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   640
    pid = FORK ();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
    if (pid == (pid_t) 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   642
	/* Child side.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   643
	CONST char *new_argv[4];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   644
	new_argv[0] = SHELL_NAME;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   645
	new_argv[1] = "-c";
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   646
	new_argv[2] = line;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   647
	new_argv[3] = NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   648
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   649
	/* Restore the signals.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   650
	(void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   651
	(void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   652
	(void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   653
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   654
	/* Exec the shell.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   655
	(void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   656
	_exit (127);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   658
	if (pid < (pid_t) 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   659
	    /* The fork failed.  */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   660
	    DPRINTF(("4: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   661
	    status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   662
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   663
	    /* Parent side.  */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
#ifdef  NO_WAITPID
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   665
	    pid_t child;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   666
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   667
	    do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   668
		__BEGIN_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   669
		child = __wait (&status);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   670
		__END_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   671
		if (child < 0 && errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   672
		    DPRINTF(("5: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   673
		    status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   674
		    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   675
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   676
	    } while (child != pid);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
#else
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   678
	    pid_t child;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   679
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   680
	    /* claus: the original did not care for EINTR here ... */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   681
	    do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   682
		__BEGIN_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   683
		child = __waitpid (pid, &status, 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   684
		__END_INTERRUPTABLE__
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   685
	    } while ((child != pid) && (errno == EINTR));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   686
	    if (child != pid) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   687
		DPRINTF(("6: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   688
		status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   689
	    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
#endif /* NO_WAITPID */
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   691
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   692
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
    save = errno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
    if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
     | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
     | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   697
	if (errno == ENOSYS) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   698
	    errno = save;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   699
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   700
	    status = -1;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   701
	    DPRINTF(("7: errno=%d\n", errno));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
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
    return status;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   707
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   708
# define __wait wait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   709
#endif /* WANT_SYSTEM */
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
/*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
 * some systems do not have realpath();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
 * the alternative of reading from a 'pwp'-pipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
 * is way too slow. Here is a realpath for the rest of us.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
 * define WANT_REALPATH in the xxxIntern-file to get it.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
 */
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
#if defined(HAS_REALPATH)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
# undef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
#if !defined(HAS_GETWD) && !defined(HAS_GETCWD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
# undef WANT_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
#if defined(WANT_REALPATH)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   728
# ifndef NULL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   729
#  define NULL (char *)0
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   730
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
# define MAX_READLINKS 32
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
# ifndef MAXPATHLEN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
#  define MAXPATHLEN     1024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   736
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   737
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   738
static
6357
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   739
char *
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   740
realpath(path, resolved_path)
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   741
    char *path;
09ad2032f900 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6352
diff changeset
   742
    char resolved_path [];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
{
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   744
	char copy_path[MAXPATHLEN];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   745
	char link_path[MAXPATHLEN];
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   746
	char *new_path = resolved_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   747
	char *max_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   748
	int readlinks = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   749
	int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   750
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   751
	/* Make a copy of the source path since we may need to modify it. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   752
	strcpy(copy_path, path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   753
	path = copy_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   754
	max_path = copy_path + MAXPATHLEN - 2;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   755
	/* If it's a relative pathname use getwd for starters. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   756
	if (*path != '/') {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
#ifdef HAS_GETCWD
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   758
		new_path = getcwd(new_path, MAXPATHLEN - 1);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
#else
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   760
		new_path = getwd(new_path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   761
#endif
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   762
		if (new_path == NULL)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   763
		    return(NULL);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   764
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   765
		new_path += strlen(new_path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   766
		if (new_path[-1] != '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   767
			*new_path++ = '/';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   768
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   769
	else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   770
		*new_path++ = '/';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   771
		path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   772
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   773
	/* Expand each slash-separated pathname component. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   774
	while (*path != '\0') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   775
		/* Ignore stray "/". */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   776
		if (*path == '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   777
			path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   778
			continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   779
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   780
		if (*path == '.') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   781
			/* Ignore ".". */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   782
			if (path[1] == '\0' || path[1] == '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   783
				path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   784
				continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   785
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   786
			if (path[1] == '.') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   787
				if (path[2] == '\0' || path[2] == '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   788
					path += 2;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   789
					/* Ignore ".." at root. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   790
					if (new_path == resolved_path + 1)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   791
						continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   792
					/* Handle ".." by backing up. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   793
					while ((--new_path)[-1] != '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   794
						;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   795
					continue;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   796
				}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   797
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   798
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   799
		/* Safely copy the next pathname component. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   800
		while (*path != '\0' && *path != '/') {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   801
			if (path > max_path) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   802
				errno = ENAMETOOLONG;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   803
				return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   804
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   805
			*new_path++ = *path++;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   806
		}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
#ifdef S_IFLNK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   808
		/* Protect against infinite loops. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   809
		if (readlinks++ > MAX_READLINKS) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   810
			errno = ELOOP;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   811
			return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   812
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   813
		/* See if latest pathname component is a symlink. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   814
		*new_path = '\0';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   815
		n = readlink(resolved_path, link_path, MAXPATHLEN - 1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   816
		if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   817
			/* EINVAL means the file exists but isn't a symlink. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   818
			if (errno != EINVAL)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   819
				return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   820
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   821
		else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   822
			/* Note: readlink doesn't add the null byte. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   823
			link_path[n] = '\0';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   824
			if (*link_path == '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   825
				/* Start over for an absolute symlink. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   826
				new_path = resolved_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   827
			else
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   828
				/* Otherwise back up over this component. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   829
				while (*(--new_path) != '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   830
					;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   831
			/* Safe sex check. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   832
			if (strlen(path) + n >= MAXPATHLEN) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   833
				errno = ENAMETOOLONG;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   834
				return NULL;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   835
			}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   836
			/* Insert symlink contents into path. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   837
			strcat(link_path, path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   838
			strcpy(copy_path, link_path);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   839
			path = copy_path;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   840
		}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
#endif /* S_IFLNK */
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   842
		*new_path++ = '/';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   843
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   844
	/* Delete trailing slash but don't whomp a lone slash. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   845
	if (new_path != resolved_path + 1 && new_path[-1] == '/')
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   846
		new_path--;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   847
	/* Make sure it's null terminated. */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   848
	*new_path = '\0';
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
   849
	return resolved_path;
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
# define HAS_REALPATH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
#endif /* WANT_REALPATH && not HAS_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
copyright
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
 COPYRIGHT (c) 1988 by Claus Gittinger
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   862
	      All Rights Reserved
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
 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
   865
 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
   866
 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
   867
 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
   868
 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
   869
 hereby transferred.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   871
!
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
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
    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
   876
    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
   877
    things available here in your applications
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
    - 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
   879
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
    (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
   881
     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
   882
     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
   883
     You decide - portability vs. functionality)
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
    [Class variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   887
	HostName        <String>        remembered hostname
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   888
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   889
	DomainName      <String>        remembered domainname
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   890
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   891
	SlowFork        <Boolean>       if set, fork and popen are avoided;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   892
					(more or less obsolete now)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   893
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   894
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   895
	CurrentDirectory <String>       remembered currentDirectories path
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
    [author:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   898
	Claus Gittinger
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
    [see also:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   901
	OSProcessStatus
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   902
	Filename Date Time
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   903
	ExternalStream FileStream PipeStream Socket
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   904
"
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
examples
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   908
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   909
  various queries
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   910
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   911
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   912
	showCR:'hello ' , (OperatingSystem getLoginName)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   913
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   914
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   915
								[exBegin]
3793
aff27e755ffd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   916
    OperatingSystem isUNIXlike ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   917
	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
   918
    ] ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   919
	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
   920
    ]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   921
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   922
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   923
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   924
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   925
	showCR:'this machine is called ' , OperatingSystem getHostName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   926
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   927
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   928
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   929
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   930
	showCR:('this machine is in the '
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   931
	       , OperatingSystem getDomainName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   932
	       , ' domain')
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   933
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   934
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   935
								[exBegin]
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   936
    Transcript
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   937
	showCR:('this machine''s CPU is a '
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   938
	       , OperatingSystem getCPUType
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   939
	       )
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   940
								[exEnd]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   941
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   942
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   943
    Transcript showCR:'executing ls command ...'.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
   944
    OperatingSystem executeCommand:'ls'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   945
    Transcript showCR:'... done.'.
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   946
								[exEnd]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   947
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   948
  locking a file
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   949
  (should be executed on two running smalltalks - not in two threads):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   950
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
    |f|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
    f := 'testFile' asFilename readWriteStream.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   954
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
    10 timesRepeat:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   956
	'about to lock ...' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   957
	[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   958
	  OperatingSystem
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   959
	    lockFD:(f fileDescriptor)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   960
	    shared:false
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   961
	    blocking:false
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   962
	] whileFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   963
	    'process ' print. OperatingSystem getProcessId print. ' is waiting' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   964
	    Delay waitForSeconds:1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   965
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   966
	'LOCKED ...' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   967
	Delay waitForSeconds:10.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   968
	'unlock ...' printCR.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
   969
	(OperatingSystem
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   970
	    unlockFD:(f fileDescriptor)) printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   971
	Delay waitForSeconds:3.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
    ]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   973
								[exBegin]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
!UnixOperatingSystem class methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   979
initialize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
    "initialize the class"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   981
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
    ObjectMemory addDependent:self.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
    HostName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
    DomainName := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
    LastErrorNumber := nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
    PipeFailed := false.
4395
53122eb3ce70 clear ForkFailed flag; made it a classVar
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
   987
    ForkFailed := false.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
    SlowFork := false.
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   989
    CurrentDirectory := nil.
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   990
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
   991
    "Modified: / 11.12.1998 / 16:35:39 / cg"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
update:something with:aParameter from:changedObject
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
    "catch image restart and flush some cached data"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
    something == #earlyRestart ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   998
	"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
   999
	 flush cached data/info
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1000
	"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1001
	HostName := nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1002
	DomainName := nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1003
	LastErrorNumber := nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1004
	PipeFailed := false.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1005
	SlowFork := false.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1006
	ForkFailed := false.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  1007
	CurrentDirectory := nil.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
    ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
3943
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1010
    "Created: / 15.6.1996 / 15:22:37 / cg"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1011
    "Modified: / 7.1.1997 / 19:36:11 / stefan"
318e1c4c609a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3930
diff changeset
  1012
    "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
  1013
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1014
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1015
!UnixOperatingSystem class methodsFor:'OS signal constants'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
sigABRT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
    "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
  1019
     (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
  1020
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1021
    ^ self signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1022
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1023
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1024
     OperatingSystem sigABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1025
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
sigALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
    "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
  1030
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1032
    ^ self signalNamed:#SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1033
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1034
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1035
     OperatingSystem sigALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1036
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
sigBREAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
    "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
  1041
     This is an MSDOS specific signal"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1043
    ^ self signalNamed:#SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1044
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1045
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1046
     OperatingSystem sigBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1047
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1048
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
sigBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
    "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
  1052
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1054
    ^ self signalNamed:#SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1055
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1056
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1057
     OperatingSystem sigBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1058
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1061
sigCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
    "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
  1063
     (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
  1064
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1065
    ^ self signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1066
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1067
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1068
     OperatingSystem sigCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1069
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1072
sigCONT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1073
    "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
  1074
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1075
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1076
    ^ self signalNamed:#SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1077
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1078
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1079
     OperatingSystem sigCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1080
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1081
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1082
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
sigDANGER
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
    "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
  1085
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1087
    ^ self signalNamed:#SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1088
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1089
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1090
     OperatingSystem sigDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1091
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1094
sigEMT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
    "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
  1096
     (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
  1097
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1098
    ^ self signalNamed:#SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1099
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1100
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1101
     OperatingSystem sigEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1102
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
sigFP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
    "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
  1107
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1109
    ^ self signalNamed:#SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1110
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1111
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1112
     OperatingSystem sigFP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1113
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
sigGRANT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
    "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
  1118
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1120
    ^ self signalNamed:#SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1121
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1122
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1123
     OperatingSystem sigGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1124
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
sigHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
    "return the signal number for SIGHUP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
     (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
  1130
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1131
    ^ self signalNamed:#SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1132
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1133
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1134
     OperatingSystem sigHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1135
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1136
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
sigILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
    "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
  1141
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1142
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1143
    ^ self signalNamed:#SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1144
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1145
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1146
     OperatingSystem sigILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1147
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
sigINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
    "return the signal number for SIGINT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1154
    ^ self signalNamed:#SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1155
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1156
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1157
     OperatingSystem sigINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1158
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1159
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1161
sigIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1162
    "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
  1163
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1164
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1165
    ^ self signalNamed:#SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1166
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1167
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1168
     OperatingSystem sigIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1169
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1170
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1171
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
sigIOT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
    "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
  1174
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1176
    ^ self signalNamed:#SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1177
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1178
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1179
     OperatingSystem sigIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1180
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1181
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1182
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1183
sigKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1184
    "return the signal number for SIGKILL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1185
     (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
  1186
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1187
    ^ self signalNamed:#SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1188
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1189
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1190
     OperatingSystem sigKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1191
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1193
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1194
sigLOST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1195
    "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
  1196
     (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
  1197
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1198
    ^ self signalNamed:#SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1199
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1200
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1201
     OperatingSystem sigLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1202
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1203
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1204
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
sigMIGRATE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1206
    "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
  1207
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1208
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1209
    ^ self signalNamed:#SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1210
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1211
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1212
     OperatingSystem sigMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1213
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1214
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1215
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1216
sigMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1217
    "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
  1218
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1219
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1220
    ^ self signalNamed:#SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1221
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
     OperatingSystem sigMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1224
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
sigPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
    "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
  1229
     (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
  1230
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1231
    ^ self signalNamed:#SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1232
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1233
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1234
     OperatingSystem sigPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1235
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1236
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1237
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1238
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
sigPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
    "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
  1241
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1243
    ^ self signalNamed:#SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1244
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1245
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1246
     OperatingSystem sigPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1247
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1248
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1249
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1250
sigPRE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1251
    "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
  1252
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1253
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1254
    ^ self signalNamed:#SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1255
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1256
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1257
     OperatingSystem sigPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1258
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1259
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1260
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1261
sigPROF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
    "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
  1263
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1264
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1265
    ^ self signalNamed:#SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1266
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1267
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1268
     OperatingSystem sigPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1269
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1270
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1271
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
sigPWR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1273
    "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
  1274
     (not available on all systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1275
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1276
    ^ self signalNamed:#SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1277
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1278
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1279
     OperatingSystem sigPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1280
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1281
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1282
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
sigQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1284
    "return the signal number for SIGQUIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1285
     (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
  1286
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1287
    ^ self signalNamed:#SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1288
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1289
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1290
     OperatingSystem sigQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1291
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1292
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1293
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1294
sigRETRACT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1295
    "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
  1296
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1297
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1298
    ^ self signalNamed:#SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1299
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
     OperatingSystem sigRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1302
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1303
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1304
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1305
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
sigSAK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1307
    "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
  1308
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1309
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1310
    ^ self signalNamed:#SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1311
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1312
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1313
     OperatingSystem sigSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1314
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1315
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1316
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1317
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1318
sigSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1319
    "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
  1320
     (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
  1321
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1322
    ^ self signalNamed:#SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1323
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1324
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1325
     OperatingSystem sigSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1326
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1327
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1328
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1329
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1330
sigSOUND
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1331
    "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
  1332
     (seems to be an AIX special)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1333
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1334
    ^ self signalNamed:#SIGSOUND
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
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1337
     OperatingSystem sigSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1338
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1339
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1340
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
sigSTOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1343
    "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
  1344
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1345
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1346
    ^ self signalNamed:#SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1347
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1348
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1349
     OperatingSystem sigSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1350
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1351
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1352
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1353
sigSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1354
    "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
  1355
     (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
  1356
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1357
    ^ self signalNamed:#SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1358
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1359
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1360
     OperatingSystem sigSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1361
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1363
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1364
sigTERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1365
    "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
  1366
     (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
  1367
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1368
    ^ self signalNamed:#SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1369
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
     OperatingSystem sigTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1372
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1373
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1374
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1375
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1376
sigTRAP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1377
    "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
  1378
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1379
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1380
    ^ self signalNamed:#SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1381
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1382
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1383
     OperatingSystem sigTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1384
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
sigTSTP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
    "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
  1389
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1391
    ^ self signalNamed:#SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1392
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1393
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1394
     OperatingSystem sigTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1395
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1397
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1398
sigTTIN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
    "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
  1400
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1401
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1402
    ^ self signalNamed:#SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1403
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1404
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1405
     OperatingSystem sigTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1406
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1407
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1408
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1409
sigTTOU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1410
    "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
  1411
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1412
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1413
    ^ self signalNamed:#SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1414
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1415
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1416
     OperatingSystem sigTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1417
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1418
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1419
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
sigURG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1421
    "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
  1422
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1423
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1424
    ^ self signalNamed:#SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1425
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1426
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1427
     OperatingSystem sigURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1428
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1429
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1431
sigUSR1
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1432
    "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
  1433
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1434
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1435
    ^ self signalNamed:#SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1436
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1437
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1438
     OperatingSystem sigUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1439
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1440
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1441
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1442
sigUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1443
    "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
  1444
     (the numeric value is not the same across unix-systems)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1445
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1446
    ^ self signalNamed:#SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1447
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1448
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1449
     OperatingSystem sigUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1450
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1452
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1453
sigVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1454
    "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
  1455
     (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
  1456
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1457
    ^ self signalNamed:#SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1458
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1459
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1460
     OperatingSystem sigVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1461
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1462
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1463
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1464
sigWINCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1465
    "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
  1466
     (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
  1467
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1468
    ^ self signalNamed:#SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1469
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1470
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1471
     OperatingSystem sigWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1472
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1473
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1474
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1475
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
sigXCPU
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1477
    "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
  1478
     (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
  1479
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1480
    ^ self signalNamed:#SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1481
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1482
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1483
     OperatingSystem sigXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1484
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1485
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1486
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1487
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1488
sigXFSZ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1489
    "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
  1490
     (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
  1491
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1492
    ^ self signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1493
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1494
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1495
     OperatingSystem sigXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1496
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1497
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1498
!
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1499
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1500
signalNamed:signalName
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1501
    "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
  1502
     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
  1503
     (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
  1504
      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
  1505
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
%{  /* NOCONTEXT */
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1507
#ifdef SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1508
    if (signalName == @symbol(SIGABRT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1509
	RETURN ( __mkSmallInteger(SIGABRT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1510
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1511
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1512
#ifdef SIGALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1513
    if (signalName == @symbol(SIGALRM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1514
	RETURN ( __mkSmallInteger(SIGALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1515
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1516
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1517
#ifdef SIGBREAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1518
    if (signalName == @symbol(SIGBREAK)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1519
	RETURN ( __mkSmallInteger(SIGBREAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1520
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1521
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1522
#ifdef SIGBUS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1523
    if (signalName == @symbol(SIGBUS)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1524
	RETURN ( __mkSmallInteger(SIGBUS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1525
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1526
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1527
#ifdef SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1528
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1529
     || (signalName == @symbol(SIGCLD)) ) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1530
	RETURN ( __mkSmallInteger(SIGCHLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1531
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1532
#else
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1533
# if defined(SIGCLD)
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1534
    if ((signalName == @symbol(SIGCHLD))
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1535
     || (signalName == @symbol(SIGCLD)) ) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1536
	RETURN ( __mkSmallInteger(SIGCLD) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1537
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1538
# endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1539
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1540
#ifdef SIGCONT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1541
    if (signalName == @symbol(SIGCONT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1542
	RETURN ( __mkSmallInteger(SIGCONT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1543
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1544
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1545
#ifdef SIGDANGER
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1546
    if (signalName == @symbol(SIGDANGER)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1547
	RETURN ( __mkSmallInteger(SIGDANGER) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1548
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1549
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1550
#ifdef SIGEMT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1551
    if (signalName == @symbol(SIGEMT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1552
	RETURN ( __mkSmallInteger(SIGEMT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1553
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1554
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1555
#ifdef SIGFPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1556
    if (signalName == @symbol(SIGFPE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1557
	RETURN ( __mkSmallInteger(SIGFPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1558
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1559
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1560
#ifdef SIGGRANT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1561
    if (signalName == @symbol(SIGGRANT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1562
	RETURN ( __mkSmallInteger(SIGGRANT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1563
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1564
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1565
#ifdef SIGHUP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1566
    if (signalName == @symbol(SIGHUP)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1567
	RETURN ( __mkSmallInteger(SIGHUP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1568
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1569
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1570
#ifdef SIGILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1571
    if (signalName == @symbol(SIGILL)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1572
	RETURN ( __mkSmallInteger(SIGILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1573
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1574
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1575
#ifdef SIGINT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1576
    if (signalName == @symbol(SIGINT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1577
	RETURN ( __mkSmallInteger(SIGINT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1578
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1579
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1580
#ifdef SIGIO
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1581
    if (signalName == @symbol(SIGIO)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1582
	RETURN ( __mkSmallInteger(SIGIO) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1583
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1584
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1585
#ifdef SIGIOT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1586
    if (signalName == @symbol(SIGIOT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1587
	RETURN ( __mkSmallInteger(SIGIOT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1588
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1589
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1590
#ifdef SIGKILL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1591
    if (signalName == @symbol(SIGKILL)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1592
	RETURN ( __mkSmallInteger(SIGKILL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1593
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1594
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1595
#ifdef SIGLOST
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1596
    if (signalName == @symbol(SIGLOST)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1597
	RETURN ( __mkSmallInteger(SIGLOST) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1598
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1599
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1600
#ifdef SIGMIGRATE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1601
    if (signalName == @symbol(SIGMIGRATE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1602
	RETURN ( __mkSmallInteger(SIGMIGRATE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1603
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1604
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1605
#ifdef SIGMSG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1606
    if (signalName == @symbol(SIGMSG)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1607
	RETURN ( __mkSmallInteger(SIGMSG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1608
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1609
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1610
#ifdef SIGPIPE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1611
    if (signalName == @symbol(SIGPIPE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1612
	RETURN ( __mkSmallInteger(SIGPIPE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1613
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1614
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1615
#ifdef SIGPOLL
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1616
    if (signalName == @symbol(SIGPOLL)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1617
	RETURN ( __mkSmallInteger(SIGPOLL) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1618
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1619
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1620
#ifdef SIGPRE
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1621
    if (signalName == @symbol(SIGPRE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1622
	RETURN ( __mkSmallInteger(SIGPRE) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1623
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1624
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1625
#ifdef SIGPROF
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1626
    if (signalName == @symbol(SIGPROF)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1627
	RETURN ( __mkSmallInteger(SIGPROF) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1628
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1629
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1630
#ifdef SIGPWR
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1631
    if (signalName == @symbol(SIGPWR)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1632
	RETURN ( __mkSmallInteger(SIGPWR) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1633
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1634
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1635
#ifdef SIGQUIT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1636
    if (signalName == @symbol(SIGQUIT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1637
	RETURN ( __mkSmallInteger(SIGQUIT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1638
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1639
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1640
#ifdef SIGRETRACT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1641
    if (signalName == @symbol(SIGRETRACT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1642
	RETURN ( __mkSmallInteger(SIGRETRACT) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1643
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1644
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1645
#ifdef SIGSAK
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1646
    if (signalName == @symbol(SIGSAK)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1647
	RETURN ( __mkSmallInteger(SIGSAK) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1648
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1649
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1650
#ifdef SIGSEGV
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1651
    if (signalName == @symbol(SIGSEGV)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1652
	RETURN ( __mkSmallInteger(SIGSEGV) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1653
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1654
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1655
#ifdef SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1656
    if (signalName == @symbol(SIGSOUND)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1657
	RETURN ( __mkSmallInteger(SIGSOUND) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1658
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1659
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1660
#ifdef SIGSTOP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1661
    if (signalName == @symbol(SIGSTOP)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1662
	RETURN ( __mkSmallInteger(SIGSTOP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1663
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1664
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1665
#ifdef SIGSYS
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1666
    if (signalName == @symbol(SIGSYS)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1667
	RETURN ( __mkSmallInteger(SIGSYS) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1668
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1669
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1670
#ifdef SIGTERM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1671
    if (signalName == @symbol(SIGTERM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1672
	RETURN ( __mkSmallInteger(SIGTERM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1673
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1674
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1675
#ifdef SIGTRAP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1676
    if (signalName == @symbol(SIGTRAP)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1677
	RETURN ( __mkSmallInteger(SIGTRAP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1678
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1679
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1680
#ifdef SIGTSTP
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1681
    if (signalName == @symbol(SIGTSTP)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1682
	RETURN ( __mkSmallInteger(SIGTSTP) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1683
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1684
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1685
#ifdef SIGTTIN
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1686
    if (signalName == @symbol(SIGTTIN)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1687
	RETURN ( __mkSmallInteger(SIGTTIN) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1688
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1689
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1690
#ifdef SIGTTOU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1691
    if (signalName == @symbol(SIGTTOU)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1692
	RETURN ( __mkSmallInteger(SIGTTOU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1693
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1694
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1695
#ifdef SIGURG
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1696
    if (signalName == @symbol(SIGURG)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1697
	RETURN ( __mkSmallInteger(SIGURG) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1698
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1699
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1700
#ifdef SIGUSR1
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1701
    if (signalName == @symbol(SIGUSR1)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1702
	RETURN ( __mkSmallInteger(SIGUSR1) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1703
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1704
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1705
#ifdef SIGUSR2
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1706
    if (signalName == @symbol(SIGUSR2)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1707
	RETURN ( __mkSmallInteger(SIGUSR2) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1708
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1709
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1710
#ifdef SIGVTALRM
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1711
    if (signalName == @symbol(SIGVTALRM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1712
	RETURN ( __mkSmallInteger(SIGVTALRM) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1713
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1714
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1715
#ifdef SIGWINCH
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1716
    if (signalName == @symbol(SIGWINCH)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1717
	RETURN ( __mkSmallInteger(SIGWINCH) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1718
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1719
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1720
#ifdef SIGXCPU
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1721
    if (signalName == @symbol(SIGXCPU)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1722
	RETURN ( __mkSmallInteger(SIGXCPU) );
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1723
    }
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1724
#endif
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1725
#ifdef SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1726
    if (signalName == @symbol(SIGXFSZ)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1727
	RETURN ( __mkSmallInteger(SIGXFSZ) );
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1728
    }
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1729
#endif
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1730
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1731
    RETURN ( __mkSmallInteger(0) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1732
%}
5404
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1733
    "
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1734
     OperatingSystem signalNamed:#SIGABRT
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1735
     OperatingSystem signalNamed:#SIGCHLD
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1736
     OperatingSystem signalNamed:#SIGXFSZ
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1737
     OperatingSystem signalNamed:#SIGSOUND
633f3ccac244 reduced the number of primitives
Claus Gittinger <cg@exept.de>
parents: 5233
diff changeset
  1738
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1739
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1740
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1741
!UnixOperatingSystem class methodsFor:'error messages'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1742
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1743
currentErrorNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1744
    "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
  1745
     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
  1746
     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
  1747
     request to the OS.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1748
     Use lastErrorNumber - currentErrorNumber is invalidated by
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1749
     many, many internal calls."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1750
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1752
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  1753
     RETURN ( __mkSmallInteger(errno) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1755
     "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  1756
      OperatingSystem currentErrorNumber
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1757
     "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1758
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1759
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1760
errorHolderForNumber:errNr
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1761
    "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
  1762
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1763
    |sym typ holder|
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1764
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1765
%{
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1766
    /* claus:
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1767
     * I made this primitive code, since errnos are not
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1768
     * standard across unixes
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1769
     */
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1770
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1771
    typ = @symbol(defaultOsErrorSignal);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1772
    sym = @symbol(ERROR_OTHER);
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1773
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1774
    if (__isSmallInteger(errNr)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1775
	switch ( __intVal(errNr)) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1776
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1777
	     * POSIX errnos - these should be defined
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1778
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1779
#ifdef EPERM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1780
	    case EPERM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1781
		sym = @symbol(EPERM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1782
		typ = @symbol(noPermissionsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1783
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1784
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1785
#ifdef ENOENT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1786
	    case ENOENT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1787
		sym = @symbol(ENOENT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1788
		typ = @symbol(nonexistentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1789
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1790
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1791
#ifdef ESRCH
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1792
	    case ESRCH:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1793
		sym = @symbol(ESRCH);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1794
		typ = @symbol(unavailableReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1795
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1796
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1797
#ifdef EINTR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1798
	    case EINTR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1799
		sym = @symbol(EINTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1800
		typ = @symbol(transientErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1801
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1802
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1803
#ifdef EIO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1804
	    case EIO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1805
		sym = @symbol(EIO);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1806
		typ = @symbol(transferFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1807
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1808
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1809
#ifdef ENXIO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1810
	    case ENXIO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1811
		sym = @symbol(ENXIO);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1812
		typ = @symbol(unavailableReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1813
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1814
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1815
#ifdef E2BIG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1816
	    case E2BIG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1817
		sym = @symbol(E2BIG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1818
		typ = @symbol(invalidArgumentsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1819
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1820
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1821
#ifdef ENOEXEC
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1822
	    case ENOEXEC:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1823
		sym = @symbol(ENOEXEC);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1824
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1825
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1826
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1827
#ifdef EBADF
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1828
	    case EBADF:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1829
		sym = @symbol(EBADF);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1830
		typ = @symbol(badAccessorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1831
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1832
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1833
#ifdef ECHILD
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1834
	    case ECHILD:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1835
		sym = @symbol(ECHILD);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1836
		typ = @symbol(informationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1837
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1838
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1839
#if !defined(EWOULDBLOCK) && defined(EAGAIN) && (EWOULDBLOCK != EAGAIN)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1840
	    case EAGAIN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1841
		sym = @symbol(EAGAIN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1842
		typ = @symbol(notReadySignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1843
		break;
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  1844
#endif
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  1845
#ifdef EOVERFLOW
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1846
	    case EOVERFLOW:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1847
		sym = @symbol(EOVERFLOW);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1848
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1849
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1850
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1851
#ifdef ENOMEM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1852
	    case ENOMEM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1853
		sym = @symbol(ENOMEM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1854
		typ = @symbol(noMemorySignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1855
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1856
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1857
#ifdef EACCES
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1858
	    case EACCES:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1859
		sym = @symbol(EACCES);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1860
		typ = @symbol(noPermissionsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1861
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1862
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1863
#ifdef EFAULT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1864
	    case EFAULT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1865
		sym = @symbol(EFAULT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1866
		typ = @symbol(invalidArgumentsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1867
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1868
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1869
#ifdef EBUSY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1870
	    case EBUSY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1871
		sym = @symbol(EBUSY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1872
		typ = @symbol(unavailableReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1873
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1874
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1875
#ifdef EEXIST
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1876
	    case EEXIST:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1877
		sym = @symbol(EEXIST);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1878
		typ = @symbol(existingReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1879
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1880
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1881
#ifdef EXDEV
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1882
	    case EXDEV:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1883
		sym = @symbol(EXDEV);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1884
		typ = @symbol(inappropriateReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1885
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1886
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1887
#ifdef ENODEV
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1888
	    case ENODEV:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1889
		sym = @symbol(ENODEV);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1890
		typ = @symbol(inaccessibleSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1891
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1892
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1893
#ifdef ENOTDIR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1894
	    case ENOTDIR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1895
		sym = @symbol(ENOTDIR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1896
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1897
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1898
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1899
#ifdef EISDIR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1900
	    case EISDIR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1901
		sym = @symbol(EISDIR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1902
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1903
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1904
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1905
#ifdef EINVAL
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1906
	    case EINVAL:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1907
		sym = @symbol(EINVAL);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1908
		typ = @symbol(invalidArgumentsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1909
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1910
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1911
#ifdef ENFILE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1912
	    case ENFILE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1913
		sym = @symbol(ENFILE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1914
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1915
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1916
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1917
#ifdef EMFILE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1918
	    case EMFILE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1919
		sym = @symbol(EMFILE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1920
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1921
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1922
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1923
#ifdef ENOTTY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1924
	    case ENOTTY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1925
		sym = @symbol(ENOTTY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1926
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1927
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1928
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1929
#ifdef EFBIG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1930
	    case EFBIG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1931
		sym = @symbol(EFBIG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1932
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1933
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1934
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1935
#ifdef ENOSPC
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1936
	    case ENOSPC:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1937
		sym = @symbol(ENOSPC);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1938
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1939
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1940
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1941
#ifdef ESPIPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1942
	    case ESPIPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1943
		sym = @symbol(ESPIPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1944
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1945
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1946
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1947
#ifdef EROFS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1948
	    case EROFS:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1949
		sym = @symbol(EROFS);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1950
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1951
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1952
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1953
#ifdef EMLINK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1954
	    case EMLINK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1955
		sym = @symbol(EMLINK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1956
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1957
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1958
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1959
#ifdef EPIPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1960
	    case EPIPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1961
		sym = @symbol(EPIPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1962
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1963
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1964
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1965
#ifdef EDOM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1966
	    case EDOM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1967
		sym = @symbol(EDOM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1968
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1969
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1970
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1971
#ifdef ERANGE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1972
	    case ERANGE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1973
		sym = @symbol(ERANGE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1974
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1975
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1976
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1977
#ifdef EDEADLK
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1978
# if EDEADLK != EWOULDBLOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1979
	    case EDEADLK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1980
		sym = @symbol(EDEADLK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1981
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1982
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1983
# endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1984
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1985
#ifdef ENAMETOOLONG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1986
	    case ENAMETOOLONG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1987
		sym = @symbol(ENAMETOOLONG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1988
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1989
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1990
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1991
#ifdef ENOLCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1992
	    case ENOLCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1993
		sym = @symbol(ENOLCK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1994
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1995
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1996
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  1997
#ifdef ENOSYS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1998
	    case ENOSYS:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  1999
		sym = @symbol(ENOSYS);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2000
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2001
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2002
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2003
#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2004
	    case ENOTEMPTY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2005
		sym = @symbol(ENOTEMPTY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2006
		typ = @symbol(inappropriateReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2007
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2008
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2009
#ifdef EILSEQ
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2010
	    case EILSEQ:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2011
		sym = @symbol(EILSEQ);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2012
		typ = @symbol(transferFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2013
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2014
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2015
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2016
	     * XPG3 errnos - defined on most systems
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2017
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2018
#ifdef ENOTBLK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2019
	    case ENOTBLK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2020
		sym = @symbol(ENOTBLK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2021
		typ = @symbol(inappropriateReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2022
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2023
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2024
#ifdef ETXTBSY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2025
	    case ETXTBSY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2026
		sym = @symbol(ETXTBSY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2027
		typ = @symbol(inaccessibleSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2028
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2029
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2030
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2031
	     * some others
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2032
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2033
#ifdef EWOULDBLOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2034
	    case EWOULDBLOCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2035
		sym = @symbol(EWOULDBLOCK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2036
		typ = @symbol(notReadySignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2037
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2038
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2039
#ifdef ENOMSG
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2040
	    case ENOMSG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2041
		sym = @symbol(ENOMSG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2042
		typ = @symbol(noDataSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2043
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2044
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2045
#ifdef ELOOP
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2046
	    case ELOOP:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2047
		sym = @symbol(ELOOP);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2048
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2049
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2050
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2051
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2052
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2053
	     * some stream errors
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2054
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2055
#ifdef ETIME
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2056
	    case ETIME:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2057
		sym = @symbol(ETIME);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2058
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2059
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2060
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2061
#ifdef ENOSR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2062
	    case ENOSR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2063
		sym = @symbol(ENOSR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2064
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2065
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2066
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2067
#ifdef ENOSTR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2068
	    case ENOSTR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2069
		sym = @symbol(ENOSTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2070
		typ = @symbol(inappropriateReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2071
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2072
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2073
#ifdef ECOMM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2074
	    case ECOMM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2075
		sym = @symbol(ECOMM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2076
		typ = @symbol(transferFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2077
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2078
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2079
#ifdef EPROTO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2080
	    case EPROTO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2081
		sym = @symbol(EPROTO);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2082
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2083
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2084
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2085
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2086
	     * nfs errors
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2087
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2088
#ifdef ESTALE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2089
	    case ESTALE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2090
		sym = @symbol(ESTALE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2091
		typ = @symbol(unavailableReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2092
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2093
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2094
#ifdef EREMOTE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2095
	    case EREMOTE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2096
		sym = @symbol(EREMOTE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2097
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2098
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2099
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2100
	    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2101
	     * some networking errors
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2102
	     */
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2103
#ifdef EINPROGRESS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2104
	    case EINPROGRESS:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2105
		sym = @symbol(EINPROGRESS);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2106
		typ = @symbol(operationStartedSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2107
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2108
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2109
#ifdef EALREADY
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2110
	    case EALREADY:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2111
		sym = @symbol(EALREADY);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2112
		typ = @symbol(operationStartedSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2113
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2114
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2115
#ifdef ENOTSOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2116
	    case ENOTSOCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2117
		sym = @symbol(ENOTSOCK);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2118
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2119
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2120
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2121
#ifdef EDESTADDRREQ
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2122
	    case EDESTADDRREQ:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2123
		sym = @symbol(EDESTADDRREQ);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2124
		typ = @symbol(underspecifiedSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2125
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2126
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2127
#ifdef EMSGSIZE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2128
	    case EMSGSIZE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2129
		sym = @symbol(EMSGSIZE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2130
		typ = @symbol(rangeErrorSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2131
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2132
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2133
#ifdef EPROTOTYPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2134
	    case EPROTOTYPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2135
		sym = @symbol(EPROTOTYPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2136
		typ = @symbol(wrongSubtypeForOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2137
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2138
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2139
#ifdef ENOPROTOOPT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2140
	    case ENOPROTOOPT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2141
		sym = @symbol(ENOPROTOOPT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2142
		typ = @symbol(unsupportedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2143
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2144
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2145
#ifdef EPROTONOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2146
	    case EPROTONOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2147
		sym = @symbol(EPROTONOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2148
		typ = @symbol(unsupportedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2149
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2150
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2151
#ifdef ESOCKTNOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2152
	    case ESOCKTNOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2153
		sym = @symbol(ESOCKTNOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2154
		typ = @symbol(unsupportedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2155
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2156
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2157
#ifdef EOPNOTSUPP
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2158
	    case EOPNOTSUPP:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2159
		sym = @symbol(EOPNOTSUPP);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2160
		typ = @symbol(inappropriateOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2161
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2162
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2163
#ifdef EPFNOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2164
	    case EPFNOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2165
		sym = @symbol(EPFNOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2166
		typ = @symbol(unsupportedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2167
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2168
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2169
#ifdef EAFNOSUPPORT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2170
	    case EAFNOSUPPORT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2171
		sym = @symbol(EAFNOSUPPORT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2172
		typ = @symbol(unsupportedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2173
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2174
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2175
#ifdef EADDRINUSE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2176
	    case EADDRINUSE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2177
		sym = @symbol(EADDRINUSE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2178
		typ = @symbol(existingReferentSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2179
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2180
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2181
#ifdef EADDRNOTAVAIL
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2182
	    case EADDRNOTAVAIL:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2183
		sym = @symbol(EADDRNOTAVAIL);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2184
		typ = @symbol(noPermissionsSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2185
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2186
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2187
#ifdef ETIMEDOUT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2188
	    case ETIMEDOUT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2189
		sym = @symbol(ETIMEDOUT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2190
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2191
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2192
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2193
#ifdef ECONNREFUSED
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2194
	    case ECONNREFUSED:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2195
		sym = @symbol(ECONNREFUSED);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2196
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2197
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2198
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2199
#ifdef ENETDOWN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2200
	    case ENETDOWN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2201
		sym = @symbol(ENETDOWN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2202
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2203
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2204
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2205
#ifdef ENETUNREACH
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2206
	    case ENETUNREACH:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2207
		sym = @symbol(ENETUNREACH);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2208
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2209
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2210
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2211
#ifdef ENETRESET
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2212
	    case ENETRESET:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2213
		sym = @symbol(ENETRESET);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2214
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2215
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2216
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2217
#ifdef ECONNABORTED
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2218
	    case ECONNABORTED:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2219
		sym = @symbol(ECONNABORTED);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2220
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2221
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2222
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2223
#ifdef ECONNRESET
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2224
	    case ECONNRESET:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2225
		sym = @symbol(ECONNRESET);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2226
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2227
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2228
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2229
#ifdef EISCONN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2230
	    case EISCONN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2231
		sym = @symbol(EISCONN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2232
		typ = @symbol(unpreparedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2233
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2234
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2235
#ifdef ENOTCONN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2236
	    case ENOTCONN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2237
		sym = @symbol(ENOTCONN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2238
		typ = @symbol(unpreparedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2239
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2240
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2241
#ifdef ESHUTDOWN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2242
	    case ESHUTDOWN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2243
		sym = @symbol(ESHUTDOWN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2244
		typ = @symbol(unpreparedOperationSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2245
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2246
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2247
#ifdef EHOSTDOWN
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2248
	    case EHOSTDOWN:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2249
		sym = @symbol(EHOSTDOWN);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2250
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2251
		break;
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2252
#endif
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2253
#ifdef EHOSTUNREACH
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2254
	    case EHOSTUNREACH:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2255
		sym = @symbol(EHOSTUNREACH);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2256
		typ = @symbol(peerFaultSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2257
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2258
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2259
#ifdef EDQUOT
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2260
	    case EDQUOT:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2261
		sym = @symbol(EDQUOT);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2262
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2263
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2264
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2265
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2266
#ifdef ENOMEDIUM
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2267
	    case ENOMEDIUM:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2268
		sym = @symbol(ENOMEDIUM);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2269
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2270
		break;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2271
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2272
#ifdef EMEDIUMTYPE
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2273
	    case EMEDIUMTYPE:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2274
		sym = @symbol(EMEDIUMTYPE);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2275
		typ = @symbol(noResourcesSignal);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2276
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2277
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2278
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2279
	    default:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2280
		break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2281
	}
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2282
    }
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2283
%}.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2284
    holder := OSErrorHolder new.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2285
    holder errorSymbol:sym errorCategory:typ.
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2286
    ^ holder
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2288
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2289
     OperatingSystem errorHolderForNumber:4
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  2290
     self errorHolderForNumber:(self errorNumberFor:#EPERM)
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2291
     self errorHolderForNumber:(self errorNumberFor:#EIO)
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2292
     self errorHolderForNumber:(self errorNumberFor:#ENXIO)
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2293
     self errorHolderForNumber:(self errorNumberFor:#EOVERFLOW)
6287
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2294
    "
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2295
!
f1a8f0ac8048 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6050
diff changeset
  2296
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2297
errorNumberFor:aSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2298
    "given a symbolic error, return the numeric;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2299
     (i.e. errorNumberFor:#EBADF returns EBADF's value).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2300
     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
  2301
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2302
%{   /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2303
    OBJ sym = aSymbol;
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
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2306
     * POSIX errnos - these should be defined
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2307
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2308
#ifdef EPERM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2309
    if (sym == @symbol(EPERM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2310
	RETURN ( __mkSmallInteger(EPERM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2311
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2312
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2313
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2314
#ifdef ENOENT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2315
    if (sym == @symbol(ENOENT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2316
	RETURN ( __mkSmallInteger(ENOENT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2317
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2318
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2319
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2320
#ifdef ESRCH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2321
    if (sym == @symbol(ESRCH)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2322
	RETURN ( __mkSmallInteger(ESRCH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2323
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2324
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2325
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2326
#ifdef EINTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2327
    if (sym == @symbol(EINTR)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2328
	RETURN ( __mkSmallInteger(EINTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2329
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2330
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2331
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2332
#ifdef EIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2333
    if (sym == @symbol(EIO)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2334
	RETURN ( __mkSmallInteger(EIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2335
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2336
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2337
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2338
#ifdef ENXIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2339
    if (sym == @symbol(ENXIO)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2340
	RETURN ( __mkSmallInteger(ENXIO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2341
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2342
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2343
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2344
#ifdef E2BIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2345
    if (sym == @symbol(E2BIG)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2346
	RETURN ( __mkSmallInteger(E2BIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2347
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2348
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2349
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2350
#ifdef ENOEXEC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2351
    if (sym == @symbol(ENOEXEC)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2352
	RETURN ( __mkSmallInteger(ENOEXEC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2353
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2354
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2355
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2356
#ifdef EBADF
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2357
    if (sym == @symbol(EBADF)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2358
	RETURN ( __mkSmallInteger(EBADF) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2359
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2360
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2361
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2362
#ifdef ECHILD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2363
    if (sym == @symbol(ECHILD)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2364
	RETURN ( __mkSmallInteger(ECHILD) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2365
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2366
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2367
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2368
#if defined(EAGAIN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2369
    if (sym == @symbol(EAGAIN)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2370
	RETURN ( __mkSmallInteger(EAGAIN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2371
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2372
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2373
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2374
#ifdef ENOMEM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2375
    if (sym == @symbol(ENOMEM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2376
	RETURN ( __mkSmallInteger(ENOMEM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2377
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2378
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2379
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2380
#ifdef EACCES
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2381
    if (sym == @symbol(EACCES)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2382
	RETURN ( __mkSmallInteger(EACCES) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2383
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2384
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2386
#ifdef EFAULT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2387
    if (sym == @symbol(EFAULT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2388
	RETURN ( __mkSmallInteger(EFAULT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2389
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2390
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2391
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2392
#ifdef EBUSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2393
    if (sym == @symbol(EBUSY)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2394
	RETURN ( __mkSmallInteger(EBUSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2395
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2396
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2397
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2398
#ifdef EXDEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2399
    if (sym == @symbol(EXDEV)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2400
	RETURN ( __mkSmallInteger(EXDEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2401
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2402
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2403
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2404
#ifdef ENODEV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2405
    if (sym == @symbol(ENODEV)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2406
	RETURN ( __mkSmallInteger(ENODEV) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2407
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2408
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2409
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2410
#ifdef ENOTDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2411
    if (sym == @symbol(ENOTDIR)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2412
	RETURN ( __mkSmallInteger(ENOTDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2413
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2414
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2415
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2416
#ifdef EISDIR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2417
    if (sym == @symbol(EISDIR)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2418
	RETURN ( __mkSmallInteger(EISDIR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2419
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2420
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2421
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2422
#ifdef EINVAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2423
    if (sym == @symbol(EINVAL)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2424
	RETURN ( __mkSmallInteger(EINVAL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2425
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2426
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2427
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2428
#ifdef ENFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2429
    if (sym == @symbol(ENFILE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2430
	RETURN ( __mkSmallInteger(ENFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2431
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2432
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2433
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2434
#ifdef EMFILE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2435
    if (sym == @symbol(EMFILE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2436
	RETURN ( __mkSmallInteger(EMFILE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2437
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2438
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2439
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2440
#ifdef ENOTTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2441
    if (sym == @symbol(ENOTTY)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2442
	RETURN ( __mkSmallInteger(ENOTTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2443
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2444
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2445
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2446
#ifdef EFBIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2447
    if (sym == @symbol(EFBIG)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2448
	RETURN ( __mkSmallInteger(EFBIG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2449
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2450
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2451
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2452
#ifdef ENOSPC
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2453
    if (sym == @symbol(ENOSPC)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2454
	RETURN ( __mkSmallInteger(ENOSPC) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2455
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2456
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2457
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2458
#ifdef ESPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2459
    if (sym == @symbol(ESPIPE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2460
	RETURN ( __mkSmallInteger(ESPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2461
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2462
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2463
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2464
#ifdef EROFS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2465
    if (sym == @symbol(EROFS)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2466
	RETURN ( __mkSmallInteger(EROFS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2467
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2468
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2469
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2470
#ifdef EMLINK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2471
    if (sym == @symbol(EMLINK)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2472
	RETURN ( __mkSmallInteger(EMLINK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2473
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2474
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2475
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2476
#ifdef EPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2477
    if (sym == @symbol(EPIPE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2478
	RETURN ( __mkSmallInteger(EPIPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2479
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2480
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2481
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2482
#ifdef EDOM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2483
    if (sym == @symbol(EDOM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2484
	RETURN ( __mkSmallInteger(EDOM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2485
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2486
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2487
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2488
#ifdef ERANGE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2489
    if (sym == @symbol(ERANGE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2490
	RETURN ( __mkSmallInteger(ERANGE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2491
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2492
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2493
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2494
#ifdef EDEADLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2495
    if (sym == @symbol(EDEADLK)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2496
	RETURN ( __mkSmallInteger(EDEADLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2497
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2498
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2499
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2500
#ifdef ENAMETOOLONG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2501
    if (sym == @symbol(ENAMETOOLONG)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2502
	RETURN ( __mkSmallInteger(ENAMETOOLONG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2503
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2504
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2505
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2506
#ifdef ENOLCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2507
    if (sym == @symbol(ENOLCK)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2508
	RETURN ( __mkSmallInteger(ENOLCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2509
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2510
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2511
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2512
#ifdef ENOSYS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2513
    if (sym == @symbol(ENOSYS)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2514
	RETURN ( __mkSmallInteger(ENOSYS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2515
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2516
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2517
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2518
#ifdef ENOTEMPTY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2519
    if (sym == @symbol(ENOTEMPTY)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2520
	RETURN ( __mkSmallInteger(ENOTEMPTY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2521
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2522
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2523
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2524
#ifdef EEXIST
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2525
    if (sym == @symbol(EEXIST)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2526
	RETURN ( __mkSmallInteger(EEXIST) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2527
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2528
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2529
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2530
#ifdef EILSEQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2531
    if (sym == @symbol(EILSEQ)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2532
	RETURN ( __mkSmallInteger(EILSEQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2533
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2534
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2535
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2536
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2537
     * XPG3 errnos - defined on most systems
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2538
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2539
#ifdef ENOTBLK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2540
    if (sym == @symbol(ENOTBLK)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2541
	RETURN ( __mkSmallInteger(ENOTBLK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2542
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2543
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2544
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2545
#ifdef ETXTBSY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2546
    if (sym == @symbol(ETXTBSY)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2547
	RETURN ( __mkSmallInteger(ETXTBSY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2548
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2549
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2550
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2551
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2552
     * some others
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2553
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2554
#ifdef EWOULDBLOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2555
    if (sym == @symbol(EWOULDBLOCK)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2556
	RETURN ( __mkSmallInteger(EWOULDBLOCK) );
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2557
    }
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2558
#endif
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2559
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2560
#ifdef EOVERFLOW
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2561
    if (sym == @symbol(EOVERFLOW)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2562
	RETURN ( __mkSmallInteger(EOVERFLOW) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2563
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2564
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2565
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2566
#ifdef ENOMSG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2567
    if (sym == @symbol(ENOMSG)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2568
	RETURN ( __mkSmallInteger(ENOMSG) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2569
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2570
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2571
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2572
#ifdef ELOOP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2573
    if (sym == @symbol(ELOOP)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2574
	RETURN ( __mkSmallInteger(ELOOP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2575
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2576
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2577
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2578
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2579
     * some stream errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2580
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2581
#ifdef ETIME
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2582
    if (sym == @symbol(ETIME)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2583
	RETURN ( __mkSmallInteger(ETIME) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2584
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2585
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2587
#ifdef ENOSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2588
    if (sym == @symbol(ENOSR)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2589
	RETURN ( __mkSmallInteger(ENOSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2590
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2591
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2592
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2593
#ifdef ENOSTR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2594
    if (sym == @symbol(ENOSTR)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2595
	RETURN ( __mkSmallInteger(ENOSTR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2596
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2597
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2598
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2599
#ifdef ECOMM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2600
    if (sym == @symbol(ECOMM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2601
	RETURN ( __mkSmallInteger(ECOMM) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2602
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2603
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2604
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2605
#ifdef EPROTO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2606
    if (sym == @symbol(EPROTO)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2607
	RETURN ( __mkSmallInteger(EPROTO) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2608
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2609
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2610
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2611
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2612
     * nfs errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2613
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2614
#ifdef ESTALE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2615
    if (sym == @symbol(ESTALE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2616
	RETURN ( __mkSmallInteger(ESTALE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2617
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2618
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2619
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2620
#ifdef EREMOTE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2621
    if (sym == @symbol(EREMOTE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2622
	RETURN ( __mkSmallInteger(EREMOTE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2623
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2624
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2625
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2626
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2627
     * some networking errors
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2628
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2629
#ifdef EINPROGRESS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2630
    if (sym == @symbol(EINPROGRESS)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2631
	RETURN ( __mkSmallInteger(EINPROGRESS) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2632
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2633
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2634
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2635
#ifdef EALREADY
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2636
    if (sym == @symbol(EALREADY)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2637
	RETURN ( __mkSmallInteger(EALREADY) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2638
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2639
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2640
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2641
#ifdef ENOTSOCK
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2642
    if (sym == @symbol(ENOTSOCK)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2643
	RETURN ( __mkSmallInteger(ENOTSOCK) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2644
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2645
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2646
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2647
#ifdef EDESTADDRREQ
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2648
    if (sym == @symbol(EDESTADDRREQ)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2649
	RETURN ( __mkSmallInteger(EDESTADDRREQ) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2650
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2651
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2652
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2653
#ifdef EMSGSIZE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2654
    if (sym == @symbol(EMSGSIZE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2655
	RETURN ( __mkSmallInteger(EMSGSIZE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2656
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2657
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2658
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2659
#ifdef EPROTOTYPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2660
    if (sym == @symbol(EPROTOTYPE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2661
	RETURN ( __mkSmallInteger(EPROTOTYPE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2662
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2663
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2664
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2665
#ifdef ENOPROTOOPT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2666
    if (sym == @symbol(ENOPROTOOPT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2667
	RETURN ( __mkSmallInteger(ENOPROTOOPT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2668
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2669
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2670
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2671
#ifdef EPROTONOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2672
    if (sym == @symbol(EPROTONOSUPPORT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2673
	RETURN ( __mkSmallInteger(EPROTONOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2674
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2675
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2676
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2677
#ifdef ESOCKTNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2678
    if (sym == @symbol(ESOCKTNOSUPPORT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2679
	RETURN ( __mkSmallInteger(ESOCKTNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2680
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2681
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2682
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2683
#ifdef EOPNOTSUPP
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2684
    if (sym == @symbol(EOPNOTSUPP)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2685
	RETURN ( __mkSmallInteger(EOPNOTSUPP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2686
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2687
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2688
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2689
#ifdef EPFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2690
    if (sym == @symbol(EPFNOSUPPORT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2691
	RETURN ( __mkSmallInteger(EPFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2692
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2693
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2694
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2695
#ifdef EAFNOSUPPORT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2696
    if (sym == @symbol(EAFNOSUPPORT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2697
	RETURN ( __mkSmallInteger(EAFNOSUPPORT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2698
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2699
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2700
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2701
#ifdef EADDRINUSE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2702
    if (sym == @symbol(EADDRINUSE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2703
	RETURN ( __mkSmallInteger(EADDRINUSE) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2704
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2705
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2706
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2707
#ifdef EADDRNOTAVAIL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2708
    if (sym == @symbol(EADDRNOTAVAIL)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2709
	RETURN ( __mkSmallInteger(EADDRNOTAVAIL) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2710
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2711
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2712
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2713
#ifdef ETIMEDOUT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2714
    if (sym == @symbol(ETIMEDOUT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2715
	RETURN ( __mkSmallInteger(ETIMEDOUT) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2716
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2717
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2718
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2719
#ifdef ECONNREFUSED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2720
    if (sym == @symbol(ECONNREFUSED)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2721
	RETURN ( __mkSmallInteger(ECONNREFUSED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2722
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2723
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2725
#ifdef ENETDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2726
    if (sym == @symbol(ENETDOWN)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2727
	RETURN ( __mkSmallInteger(ENETDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2728
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2729
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2730
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2731
#ifdef ENETUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2732
    if (sym == @symbol(ENETUNREACH)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2733
	RETURN ( __mkSmallInteger(ENETUNREACH) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2734
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2735
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2736
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2737
#ifdef ENETRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2738
    if (sym == @symbol(ENETRESET)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2739
	RETURN ( __mkSmallInteger(ENETRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2740
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2741
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2742
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2743
#ifdef ECONNABORTED
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2744
    if (sym == @symbol(ECONNABORTED)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2745
	RETURN ( __mkSmallInteger(ECONNABORTED) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2746
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2747
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2748
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2749
#ifdef ECONNRESET
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2750
    if (sym == @symbol(ECONNRESET)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2751
	RETURN ( __mkSmallInteger(ECONNRESET) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2752
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2753
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2754
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2755
#ifdef EISCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2756
    if (sym == @symbol(EISCONN)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2757
	RETURN ( __mkSmallInteger(EISCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2758
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2759
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2760
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2761
#ifdef ENOTCONN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2762
    if (sym == @symbol(ENOTCONN)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2763
	RETURN ( __mkSmallInteger(ENOTCONN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2764
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2765
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2766
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2767
#ifdef ESHUTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2768
    if (sym == @symbol(ESHUTDOWN)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2769
	RETURN ( __mkSmallInteger(ESHUTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2770
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2771
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2772
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2773
#ifdef EHOSTDOWN
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2774
    if (sym == @symbol(EHOSTDOWN)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2775
	RETURN ( __mkSmallInteger(EHOSTDOWN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2776
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2777
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2778
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2779
#ifdef EHOSTUNREACH
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2780
    if (sym == @symbol(EHOSTUNREACH)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2781
	RETURN ( __mkSmallInteger(EHOSTUNREACH) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2782
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2783
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2784
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2785
#ifdef EREMOTEIO
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2786
    if (sym == @symbol(EREMOTEIO)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2787
	RETURN ( __mkSmallInteger(EREMOTEIO) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2788
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2789
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2790
#ifdef EDQUOT
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2791
    if (sym == @symbol(EDQUOT)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2792
	RETURN ( __mkSmallInteger(EDQUOT) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2793
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2794
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2795
#ifdef ENOMEDIUM
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2796
    if (sym == @symbol(ENOMEDIUM)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2797
	RETURN ( __mkSmallInteger(ENOMEDIUM) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2798
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2799
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2800
#ifdef EMEDIUMTYPE
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2801
    if (sym == @symbol(EMEDIUMTYPE)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  2802
	RETURN ( __mkSmallInteger(EMEDIUMTYPE) );
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2803
    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2804
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  2805
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2806
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2807
    ^ -1
7873
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2808
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2809
    "
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2810
     self errorNumberFor:#EOVERFLOW
a126f0995800 EOVERFLOW added
Claus Gittinger <cg@exept.de>
parents: 7803
diff changeset
  2811
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2812
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2813
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  2814
!UnixOperatingSystem class methodsFor:'executing OS commands-implementation'!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2815
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2816
exec:aCommandPath withArguments:argColl environment:environmentDictionary
7170
19558aa463e0 Environment in #executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 7152
diff changeset
  2817
    fileDescriptors:fdColl fork:doFork newPgrp:newPgrp inDirectory:aDirectory
19558aa463e0 Environment in #executeCommand:...
Stefan Vogel <sv@exept.de>
parents: 7152
diff changeset
  2818
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2819
    "Internal lowLevel entry for combined fork & exec;
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2820
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2821
     If fork is false (chain a command):
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2822
         execute the OS command specified by the argument, aCommandPath, with
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2823
         arguments in argArray (no arguments, if nil).
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2824
         If successful, this method does not return and smalltalk is gone.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2825
         If not successful, it does return.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2826
         Normal use is with forkForCommand.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2827
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2828
     If fork is true (subprocess command execution):
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2829
        fork a child to do the above.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2830
        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
  2831
7079
07625dfffcbf Cleanup filedescriptor closing on #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7072
diff changeset
  2832
     fdColl contains the filedescriptors, to be used for the child (if fork is true).
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2833
        fdArray[1] = 15 -> use fd 15 as stdin.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2834
        If an element of the array is set to nil, the corresponding filedescriptor
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2835
        will be closed for the child.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2836
        fdArray[1] == StdIn for child
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2837
        fdArray[2] == StdOut for child
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2838
        fdArray[3] == StdErr for child
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2839
        on VMS, these must be channels as returned by createMailBox.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2840
        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
  2841
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2842
     If newPgrp is true, the subprocess will be established in a new process group.
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2843
        The processgroup will be equal to id.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2844
        newPgrp is not used on WIN32 and VMS systems.
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2845
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2846
     environmentDictionary specifies environment variables which are passed differently from
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2847
     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
  2848
     key-value pairs for changed/added environment variables.
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2849
     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
  2850
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2851
     Notice: this used to be two separate ST-methods; however, in order to use
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2852
            vfork on some machines, it had to be merged into one, to avoid write
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2853
            accesses to ST/X memory from the vforked-child.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2854
            The code below only does read accesses."
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2855
7256
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2856
    |envArray argArray fdArray dirName cnt|
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2857
208e68f187ca #exec:withArguments:....
Stefan Vogel <sv@exept.de>
parents: 7244
diff changeset
  2858
    environmentDictionary size ~~ 0 ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2859
        envArray := Array new:environmentDictionary size.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2860
        cnt := 1.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2861
        environmentDictionary keysAndValuesDo:[:key :val |
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2862
            val isNil ifTrue:[
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2863
                envArray at:cnt put:(key, '=')
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2864
            ] ifFalse:[
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2865
                envArray at:cnt put:(key, '=', val)
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2866
            ].
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2867
            cnt := cnt + 1.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2868
        ].
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  2869
    ].
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2870
    argColl notNil ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2871
        argArray := argColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2872
    ].
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2873
    fdColl notNil ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2874
        fdArray := fdColl asArray
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2875
    ].
3663
b5d8643a7ed1 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3625
diff changeset
  2876
    aDirectory notNil ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2877
        dirName := aDirectory asFilename name
3625
c74e6fa0647e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3595
diff changeset
  2878
    ].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2879
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2880
%{  /* STACK: 16000 */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2881
    char **argv;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2882
    int nargs, i, id;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2883
    OBJ arg;
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  2884
    extern char **environ;
3571
9090dc66a427 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3564
diff changeset
  2885
    char **_env, **_nEnv;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2886
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2887
    if (__isStringLike(aCommandPath) &&
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2888
        ((argArray == nil) || __isArrayLike(argArray)) &&
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2889
        ((fdArray == nil) || __isArrayLike(fdArray))
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  2890
    ) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2891
        nargs = argArray == nil ? 0 : __arraySize(argArray);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2892
        argv = (char **) malloc(sizeof(char *) * (nargs + 1));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2893
        if (argv) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2894
            int nOldEnv, nNewEnv;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2895
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2896
            for (i=0; i < nargs; i++) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2897
                arg = __ArrayInstPtr(argArray)->a_element[i];
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2898
                if (__isStringLike(arg)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2899
                    argv[i] = (char *) __stringVal(arg);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2900
                } else {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2901
                    argv[i] = "";
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2902
                }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2903
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2904
            argv[i] = NULL;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2905
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2906
            /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2907
             * number of new items in environment ..
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2908
             */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2909
            nNewEnv = 0;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2910
            if ((envArray != nil) && __isArrayLike(envArray)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2911
                nNewEnv = __arraySize(envArray);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2912
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2913
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2914
            if (nNewEnv == 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2915
                _nEnv = environ;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2916
            } else {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2917
                _env = environ;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2918
                /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2919
                 * get size of environment
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2920
                 */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2921
                nOldEnv = 0;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2922
                if (_env) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2923
                    while (*_env) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2924
                        nOldEnv++;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2925
                        _env++;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2926
                    }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2927
                }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2928
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2929
                /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2930
                 * generate a new environment
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2931
                 * I have not found a spec which defines if
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2932
                 * items at the end overwrite previous definitions,
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2933
                 * or if the first encountered definition is valid.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2934
                 * To be prepared for any case, simply add the new definitions
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2935
                 * at both ends - that should do it in any case.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2936
                 * Someone with more know-how may want to fix this.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2937
                 * getenv() searches for the first entry.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2938
                 * But maybe someone creates a Dictionary from the environment.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2939
                 * In this case the last entry would overwrite previous entries.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2940
                 */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2941
                _nEnv = (char **)malloc(sizeof(char *) * (nNewEnv + nOldEnv + nNewEnv + 1));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2942
                if (_nEnv) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2943
                    char **eO, **eN;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2944
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2945
                    eN = _nEnv;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2946
                    if (nNewEnv) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2947
                        /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2948
                         * add new items at the front ...
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2949
                         */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2950
                        int i;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2951
                        OBJ *t;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2952
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2953
                        for (i=0, t = __arrayVal(envArray);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2954
                             i < __arraySize(envArray);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2955
                             i++, t++) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2956
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2957
                            if (__isStringLike(*t)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2958
                                *eN++ = (char *)__stringVal(*t);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2959
                            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2960
                        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2961
                    }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2962
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2963
                    if (nOldEnv) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2964
                        /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2965
                         * append old environment
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2966
                         */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2967
                        for (eO = environ; *eO; *eN++ = *eO++)
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2968
                            continue;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2969
                    }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2970
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2971
                    if (nNewEnv) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2972
                        /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2973
                         * append new items again at the end
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2974
                         */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2975
                        for (eO = _nEnv, i=0; i<nNewEnv; i++) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2976
                            *eN++ = *eO++;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2977
                        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2978
                    }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2979
                    *eN = NULL;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2980
                }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2981
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2982
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2983
            if (doFork == true) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2984
                /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2985
                 * fork a subprocess.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2986
                 */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2987
                int nfd;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2988
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2989
                nfd = fdArray == nil ? 0 : __arraySize(fdArray);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2990
                id = FORK ();
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2991
                if (id == 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2992
                    /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2993
                    ** In child.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2994
                    ** first: dup filedescriptors.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2995
                    */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2996
                    for (i = 0; i < nfd; i++) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2997
                        OBJ fd;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2998
                        int rslt;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  2999
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3000
                        fd = __arrayVal(fdArray)[i];
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3001
                        if (__isSmallInteger(fd) && (__intVal(fd) != i)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3002
                            do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3003
                                rslt = dup2(__intVal(fd), i);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3004
                            } while ((rslt < 0) && (errno == EINTR));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3005
                        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3006
                    }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3007
                    /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3008
                    ** Second: close descriptors
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3009
                    **         marked as unwanted
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3010
                    ** (extra loop to allow duping of low filedescriptor numbers to
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3011
                    **  higher fd numbers)
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3012
                    */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3013
                    for (i = 0; i < nfd; i++) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3014
                        if (__arrayVal(fdArray)[i] == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3015
                            close(i);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3016
                        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3017
                    }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3018
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3019
                    /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3020
                    ** third: close all filedescriptors larger
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3021
                    ** then the explicitely closed or duped
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3022
                    ** filedescriptors
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3023
                    */
7072
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3024
#ifndef OPEN_MAX
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3025
# define OPEN_MAX       256
c0a7510b6ab9 added #all arg for closeDescriptor,
ca
parents: 7063
diff changeset
  3026
#endif
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3027
                    for ( ;i < OPEN_MAX; i++) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3028
                        close(i);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3029
                    }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3030
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3031
                    if (newPgrp == true) {
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3032
#ifndef NEXT
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3033
                        setsid();
3564
eefdb0c79055 made environment code independent of setenv/putenv
Claus Gittinger <cg@exept.de>
parents: 3563
diff changeset
  3034
#endif
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3035
#if defined(TIOCSCTTY)
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3036
                        ioctl(0, TIOCSCTTY, 0) ;
3561
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  3037
#endif
9a117ea69e2f *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3558
diff changeset
  3038
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3039
#if defined(TIOCSPGRP)
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3040
                        {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3041
                            int pgrp = getpid();
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3042
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3043
                            ioctl(0, TIOCSPGRP, (char *)&pgrp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3044
                        }
3555
211885c31b61 correctly setup pgrocess group (for terminalView)
Claus Gittinger <cg@exept.de>
parents: 3550
diff changeset
  3045
#endif
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3046
#if defined(_POSIX_JOB_CONTROL)
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3047
                        (void) setpgid(0, 0);
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3048
#else
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3049
# if defined(BSD) || defined(LINUX)
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3050
                        (void) setpgrp(0);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3051
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3052
#endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3053
                    }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3054
12834
cad1c35e6458 Check return value of chdir()
Stefan Vogel <sv@exept.de>
parents: 12833
diff changeset
  3055
                    if (dirName == nil || chdir((char *)__stringVal(dirName)) == 0) {
cad1c35e6458 Check return value of chdir()
Stefan Vogel <sv@exept.de>
parents: 12833
diff changeset
  3056
                    	execve((char *)__stringVal(aCommandPath), argv, _nEnv);
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3057
                    }
12834
cad1c35e6458 Check return value of chdir()
Stefan Vogel <sv@exept.de>
parents: 12833
diff changeset
  3058
                    /* reached if chdir failed or aCommandPathh cannot be executed */
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3059
                    _exit(127);                 /* POSIX 2 compatible exit value */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3060
                }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3061
            } else {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3062
                /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3063
                 * no subprocess (i.e. transfer to another program)
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3064
                 */
12834
cad1c35e6458 Check return value of chdir()
Stefan Vogel <sv@exept.de>
parents: 12833
diff changeset
  3065
                if (dirName == nil || chdir((char *)__stringVal(dirName)) == 0) {
cad1c35e6458 Check return value of chdir()
Stefan Vogel <sv@exept.de>
parents: 12833
diff changeset
  3066
                    execve((char *)__stringVal(aCommandPath), argv, _nEnv);
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3067
                }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3068
                /*
12834
cad1c35e6458 Check return value of chdir()
Stefan Vogel <sv@exept.de>
parents: 12833
diff changeset
  3069
                 * reached if chdir failed or command-path cannot be executed
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3070
                 */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3071
                id = -1;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3072
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3073
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3074
            if (nNewEnv && (_nEnv != NULL)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3075
                /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3076
                 * free new environment stuff
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3077
                 */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3078
                free(_nEnv);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3079
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3080
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3081
            free(argv);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3082
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3083
            /*
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3084
             * In parent: succes or failure
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3085
             */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3086
            if (id == -1) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3087
                RETURN (nil);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3088
            } else {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3089
                RETURN (__mkSmallInteger(id));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3090
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3091
        }
3543
acd4a449d96b allow passing environment variables with the exec.
Claus Gittinger <cg@exept.de>
parents: 3542
diff changeset
  3092
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3093
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3094
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3095
     path-argument not string
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3096
     or argArray not an array/nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3097
     or malloc failed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3098
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3099
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3100
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3101
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3102
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3103
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3104
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3105
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3106
     id == 0 ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3107
        'I am the child'.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3108
        OperatingSystem exec:'/bin/ls' withArguments:#('ls' '/tmp').
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3109
        'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3110
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3111
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3112
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3113
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3114
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3115
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3116
     id == 0 ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3117
        'I am the child'.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3118
        OperatingSystem
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3119
           exec:'/bin/sh'
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3120
           withArguments:#('sh' '-c' 'sleep 2;echo 1;sleep 2;echo 2').
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3121
        'not reached'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3122
     ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3123
     id printNL.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3124
     (Delay forSeconds:3.5) wait.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3125
     'killing ...' printNL.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3126
     OperatingSystem sendSignal:(OperatingSystem sigTERM) to:id.
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3127
     OperatingSystem sendSignal:(OperatingSystem sigKILL) to:id
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3128
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3129
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3130
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3131
fork
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3132
    "fork a new (HEAVY-weight) unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3133
     Not supported with MSDOS & VMS systems.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3134
     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
  3135
     lightweight smalltalk processes. This method will return
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3136
     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
  3137
     unix-process-id) to the parent (original) process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3138
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3139
     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
  3140
     #startProcess: and #executCommand: for higher level interfaces."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3141
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3142
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3143
    int pid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3144
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3145
    pid = fork();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3146
    RETURN ( __MKUINT(pid) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3147
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3148
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3149
    "/ not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3150
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3151
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3152
    ^ UnsupportedOperationSignal raise
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3153
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3154
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3155
     |id|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3156
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3157
     id := OperatingSystem fork.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3158
     id == 0 ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3159
	'I am the child process' printCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  3160
	OperatingSystem exit
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3161
     ]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3162
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3163
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3164
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3165
startProcess:aCommandString inputFrom:anExternalInStream outputTo:anExternalOutStream
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3166
    errorTo:anExternalErrStream auxFrom:anAuxiliaryStream
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3167
    environment:anEvironmentDictionary inDirectory:dir
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3168
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3169
    "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
  3170
     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
  3171
     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
  3172
     '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
  3173
     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
  3174
     each may be nil.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3175
     Return the processId if successful, nil otherwise.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3176
     Use #monitorPid:action: for synchronization and exec status return,
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3177
     or #killProcess: to stop it."
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3178
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3179
    |nullStream in out err shellAndArgs rslt auxFd|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3180
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3181
    aCommandString isNil ifTrue:[^ nil].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3182
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3183
    (in := anExternalInStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3184
	nullStream := Filename nullDevice readWriteStream.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3185
	in := nullStream.
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3186
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3187
    (out := anExternalOutStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3188
	nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3189
	out := nullStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3190
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3191
    (err := anExternalErrStream) isNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3192
	err := out
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3193
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3194
    anAuxiliaryStream notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3195
	auxFd := anAuxiliaryStream fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3196
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3197
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3198
    shellAndArgs := self commandAndArgsForOSCommand:aCommandString.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3199
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3200
    rslt := self
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3201
	exec:(shellAndArgs at:1)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3202
	withArguments:(shellAndArgs at:2)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3203
	environment:anEvironmentDictionary
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3204
	fileDescriptors:(Array with:in fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3205
			       with:out fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3206
			       with:err fileDescriptor
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3207
			       with:auxFd)
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3208
	fork:true
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3209
	newPgrp:true "/ false
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3210
	inDirectory:dir.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3211
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3212
    nullStream notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3213
	nullStream close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3214
    ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3215
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3216
    ^ rslt
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3217
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3218
    "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
  3219
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3220
     OperatingSystem executeCommand:'ls -l > out'.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3221
    "
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3222
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3223
    "non-blocking (lower prio threads continue):
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3224
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3225
     |in out err pid sema|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3226
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3227
     in := 'out' asFilename readStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3228
     out := 'out2' asFilename writeStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3229
     err := 'err' asFilename writeStream.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3230
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3231
     sema := Semaphore new.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3232
     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
  3233
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3234
     The following will no longer work. monitorPid has disappeared
7656
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3235
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3236
     pid notNil ifTrue:[
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3237
	 Processor monitorPid:pid action:[:OSstatus | sema signal ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3238
     ].
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3239
     in close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3240
     out close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3241
     err close.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3242
     sema wait.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3243
     Transcript showCR:'finished'
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3244
    "
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3245
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3246
    "Modified: / 21.3.1997 / 10:04:35 / dq"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3247
    "Modified: / 15.7.1997 / 16:03:51 / stefan"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3248
    "Modified: / 5.6.1998 / 19:03:51 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3249
    "Created: / 12.11.1998 / 14:39:20 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3250
! !
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3251
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3252
!UnixOperatingSystem class methodsFor:'executing OS commands-queries'!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3253
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3254
commandAndArgsForOSCommand:aCommandString
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3255
    "get a shell and shell arguments for command execution"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3256
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3257
    |shell args|
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3258
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3259
    "/
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3260
    "/ '/bin/sh -c <command>'
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3261
    "/
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3262
    shell := '/bin/sh'.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3263
    args := Array with:'sh' with:'-c' with:aCommandString.
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3264
    ^ Array with:shell with:args
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3265
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3266
    "Modified: / 20.1.1998 / 16:57:19 / md"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3267
    "Modified: / 5.6.1998 / 17:40:48 / cg"
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3268
!
298c12201aa3 refactored OS command stuff
Claus Gittinger <cg@exept.de>
parents: 7640
diff changeset
  3269
11046
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3270
nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3271
    "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
  3272
     Usually, 'stx' is returned -
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3273
     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
  3274
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3275
    |info path|
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3276
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3277
    self getOSType == #linux ifTrue:[
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3278
	"shortcut - use the /proc filesystem.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3279
	 Here we get an absolute path to the running executable."
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3280
	info := '/proc/self/exe' asFilename linkInfo.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3281
	info notNil ifTrue:[
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3282
	    path := info path.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3283
	    path notEmptyOrNil ifTrue:[
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3284
		^ path
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3285
	    ].
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3286
	 ].
11046
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3287
    ].
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3288
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3289
    "Fall back - do it the hard way"
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3290
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3291
    ^ super nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3292
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3293
    "
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3294
     OperatingSystem nameOfSTXExecutable
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3295
    "
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3296
!
3df8eb754bc0 #nameOfSTXExecutable - use /proc filesystem in linux
Stefan Vogel <sv@exept.de>
parents: 11011
diff changeset
  3297
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3298
pathOfCommand:aCommand
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3299
    "find where aCommand's executable file is;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3300
     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
  3301
     return nil."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3302
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
  3303
    |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
  3304
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3305
    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
  3306
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
  3307
    commandFilename isAbsolute ifTrue:[
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3308
	^ aCommand
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
  3309
    ].
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
  3310
    commandFilename isExplicitRelative ifTrue:[
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3311
	^ commandFilename pathName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3312
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3313
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3314
    path := self getEnvironment:'PATH'.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3315
    path notNil ifTrue:[
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3316
	(path asCollectionOfSubstringsSeparatedBy:(self pathSeparator)) do:[:path |
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3317
	    path isEmpty ifTrue:[
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3318
		f := aCommand asFilename
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3319
	    ] ifFalse:[
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3320
		f := path asFilename construct:aCommand.
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3321
	    ].
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3322
	    self executableFileExtensions do:[:ext |
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3323
		ext notEmpty ifTrue:[
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3324
		    fExt := (f pathName , ext) asFilename.
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3325
		] ifFalse:[
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3326
		    fExt := f.
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3327
		].
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3328
		fExt isExecutable ifTrue:[
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3329
		    ^ fExt pathName
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3330
		].
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3331
	    ].
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  3332
	].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3333
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3334
    ^ nil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3335
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3336
    "unix:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3337
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3338
     OperatingSystem pathOfCommand:'fooBar'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3339
     OperatingSystem pathOfCommand:'ls'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3340
     OperatingSystem pathOfCommand:'cvs'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3341
     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
  3342
     OperatingSystem pathOfCommand:'./stx'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3343
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3344
    "windows:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3345
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3346
     OperatingSystem pathOfCommand:'windbg'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3347
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3348
3515
e7ff23b98a83 removed more win32 / vms stuff
Claus Gittinger <cg@exept.de>
parents: 3512
diff changeset
  3349
    "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
  3350
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3351
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3352
!UnixOperatingSystem class methodsFor:'file access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3353
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3354
closeFd:anInteger
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3355
    "low level close of a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3356
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3357
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3358
     if (__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3359
	if (@global(ExternalStream:FileOpenTrace) == true) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3360
	    fprintf(stderr, "close [UnixOp] fd=%d\n", __intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3361
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3362
	close(__intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  3363
	RETURN(self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3364
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3365
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3366
     ^ self primitiveFailed.
7133
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3367
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3368
    "
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3369
     10 to:400 do:[:fd | OperatingSystem closeFd:fd]
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  3370
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3371
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3372
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3373
copyFromFd:inFd toFd:outFd startIndex:startIdx count:count
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3374
    "directly copy from one Fd to another (if supported by the OS)"
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3375
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3376
%{
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3377
#if defined(HAS_SENDFILE)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3378
     if (__isSmallInteger(inFd)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3379
      && __isSmallInteger(outFd)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3380
      && __isSmallInteger(startIdx)
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3381
      && __isSmallInteger(count)) {
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  3382
	int nWritten;
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  3383
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  3384
	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
  3385
	if (nWritten < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  3386
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  3387
	}
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  3388
	RETURN (__mkSmallInteger(nWritten));
7699
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3389
     }
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3390
#endif
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3391
%}.
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3392
    ^ 0 "/ not supported
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3393
!
9bf7adc6116d sendfile support
Claus Gittinger <cg@exept.de>
parents: 7698
diff changeset
  3394
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3395
createDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3396
    "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
  3397
     path, or relative to the current directory.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3398
     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
  3399
     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
  3400
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3401
    ^ self createDirectory:aPathName withAccess:((self getEnvironment:'UMASK') ? 8r0755)
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3402
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3403
    "
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3404
     OperatingSystem createDirectory:'foo'
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3405
    "
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3406
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3407
    "Modified: 20.12.1995 / 11:24:13 / stefan"
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3408
    "Modified: 29.6.1996 / 14:06:54 / cg"
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3409
!
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3410
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3411
createDirectory:aPathName withAccess:umask
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3412
    "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
  3413
     path, or relative to the current directory.
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3414
     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
  3415
     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
  3416
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3417
%{
13052
18217382f23d changed: #createDirectory:withAccess:
Stefan Vogel <sv@exept.de>
parents: 13025
diff changeset
  3418
    if (__isStringLike(aPathName) && __isSmallInteger(umask)) {
18217382f23d changed: #createDirectory:withAccess:
Stefan Vogel <sv@exept.de>
parents: 13025
diff changeset
  3419
        if (mkdir(__stringVal(aPathName), __smallIntegerVal(umask)) >= 0) {
18217382f23d changed: #createDirectory:withAccess:
Stefan Vogel <sv@exept.de>
parents: 13025
diff changeset
  3420
            RETURN(true);
18217382f23d changed: #createDirectory:withAccess:
Stefan Vogel <sv@exept.de>
parents: 13025
diff changeset
  3421
        }
18217382f23d changed: #createDirectory:withAccess:
Stefan Vogel <sv@exept.de>
parents: 13025
diff changeset
  3422
        @global(LastErrorNumber) = __mkSmallInteger(errno);
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3423
    }
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3424
%}.
11547
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3425
    "/ could not create - if it already existed this is ok
11535
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3426
3a3ef7112002 UMASK in createDirectory
Claus Gittinger <cg@exept.de>
parents: 11368
diff changeset
  3427
    (self isDirectory:aPathName) ifTrue:[^ true].
11547
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3428
    ^ false.
97a0c55d3116 #createDirectory: answer false on error instead of #primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 11546
diff changeset
  3429
3496
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
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3432
     OperatingSystem createDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3433
    "
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
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3436
createFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3437
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3438
    ^ 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
  3439
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3440
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3441
createFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3442
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3443
    ^ 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
  3444
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3445
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3446
createFileForWrite:pathName
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3447
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3448
    ^ self open:pathName attributes:#(O_WRONLY O_CREAT O_TRUNC) mode:nil
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3449
!
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  3450
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3451
createHardLinkFrom:oldPath to:newPath
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3452
    "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
  3453
     Return true if successful, false if not."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3454
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3455
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3456
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3457
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3458
    if (__isStringLike(oldPath) && __isStringLike(newPath)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3459
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3460
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3461
            ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3462
        } while (ret < 0 && errno == EINTR);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3463
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3464
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3465
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3466
            RETURN ( false );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3467
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3468
        RETURN (true);
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3469
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3470
%}.
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3471
    "/
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3472
    "/ bad argument(s) given
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3473
    "/
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3474
    ^ self primitiveFailed
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3475
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3476
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3477
     OperatingSystem linkFile:'foo' to:'bar'
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3478
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3479
!
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3480
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3481
createSymbolicLinkFrom:oldPath to:newPath
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3482
    "make a symbolic link for 'newPath' to the file 'oldPath'.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3483
     The link will be a soft (symbolic) link.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3484
     Return true if successful, false if not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3485
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3486
%{
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3487
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3488
    int ret;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3489
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3490
    if (__isStringLike(oldPath) && __isStringLike(newPath)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3491
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3492
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3493
            ret = symlink((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3494
        } while (ret < 0 && errno == EINTR);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3495
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3496
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3497
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3498
            RETURN ( false );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3499
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3500
        RETURN (true);
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3501
    }
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3502
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3503
%}.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3504
    (oldPath isString not or:[newPath isString not]) ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3505
        "/
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3506
        "/ bad argument(s) given
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3507
        "/
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3508
        ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3509
    ].
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
    "/
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  3512
    "/ 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
  3513
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3514
    ^ UnsupportedOperationSignal raise
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3517
     OperatingSystem symbolicLinkFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3518
    "
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
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3521
open:path attributes:attributes mode:modeInteger
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3522
    "open a file, return an os specific fileHandle.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3523
     openmode is a symbol defining the way to open
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3524
     valid modes are:
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3525
        #O_RDONLY
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3526
        #O_RDWR
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3527
        #O_WRONLY
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3528
        #O_CREAT
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3529
        #O_APPEND
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3530
        #O_SYNC
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3531
        #O_LARGEFILE
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3532
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3533
     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
  3534
     which is proprietrary to the operatingSystem."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3535
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3536
    |error fileDescriptor|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3537
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3538
%{
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3539
    OBJ *ap;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3540
    int nAttributes;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3541
    int fd;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3542
    int mode, openFlags = 0;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3543
    int n;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3544
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3545
    if (!__isStringLike(path)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3546
        error = @symbol(badArgument1);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3547
        goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3548
    }
8934
32a063645991 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8913
diff changeset
  3549
    if (!__isArrayLike(attributes)) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3550
        error = @symbol(badArgument2);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3551
        goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3552
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3553
    if (modeInteger == nil) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3554
        mode = 0644;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3555
    } else if (__isSmallInteger(modeInteger)) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3556
        mode = __intVal(modeInteger);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3557
    } else {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3558
        error = @symbol(badArgument3);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3559
        goto err;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3560
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3561
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3562
    nAttributes = __arraySize(attributes);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  3563
    for (n = 0, ap = __arrayVal(attributes); n < nAttributes; n++) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3564
        OBJ attribute = ap[n];
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3565
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3566
        if (attribute == @symbol(O_RDONLY)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3567
            openFlags |= O_RDONLY;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3568
        } else if (attribute == @symbol(O_RDWR)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3569
            openFlags |= O_RDWR;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3570
        } else if (attribute == @symbol(O_WRONLY)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3571
            openFlags |= O_WRONLY;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3572
        } else if (attribute == @symbol(O_CREAT)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3573
            openFlags |= O_CREAT;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3574
        } else if (attribute == @symbol(O_APPEND)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3575
            openFlags |= O_APPEND;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3576
        } else if (attribute == @symbol(O_EXCL)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3577
            openFlags |= O_EXCL;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3578
        } else if (attribute == @symbol(O_TRUNC)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3579
            openFlags |= O_TRUNC;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3580
        } else if (attribute == @symbol(O_LARGEFILE)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3581
#ifdef O_LARGEFILE
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3582
            openFlags |= O_LARGEFILE;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3583
#else
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3584
            error = @symbol(badArgument2);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3585
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3586
#endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3587
        } else if (attribute == @symbol(O_SYNC)) {
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3588
#ifdef O_SYNC
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3589
            openFlags |= O_SYNC;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3590
#else
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3591
            error = @symbol(badArgument2);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3592
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3593
#endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3594
        }
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3595
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3596
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3597
#if defined(O_NONBLOCK)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3598
    openFlags |= O_NONBLOCK;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  3599
#elif defined(O_NDELAY)
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3600
    openFlags |= O_NDELAY;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3601
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3602
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3603
again:
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3604
    fd = open((char *) __stringVal(path), openFlags, mode);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3605
    if (fd < 0) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3606
        if (errno == EINTR) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3607
            __HANDLE_INTERRUPTS__;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3608
            goto again;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3609
        } else {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3610
            error = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3611
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3612
        }
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3613
    }
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
  3614
    fileDescriptor = __mkSmallInteger(fd);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3615
err:;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3616
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3617
    ^ fileDescriptor notNil ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3618
        FileDescriptorHandle for:fileDescriptor.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3619
    ] ifFalse:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3620
        (self errorHolderForNumber:error) reportError
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3621
    ].
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3622
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3623
    "
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3624
        self open:'/etc/hosts' attributes:#(O_RDONLY) mode:nil
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3625
        self open:'/tmp/xxzz' attributes:#(O_RDWR O_CREAT) mode:8r611
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3626
        self open:'/etc/passwd' attributes:#(O_RDWR) mode:nil
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3627
        self open:'/no one knows this file' attributes:#(O_RDONLY) mode:nil
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3628
        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
  3629
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3630
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3631
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3632
openFileForAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3633
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3634
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3635
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3636
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3637
openFileForRead:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3638
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3639
    ^ self open:pathName attributes:#(O_RDONLY) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3640
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3641
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3642
openFileForReadAppend:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3643
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3644
    ^ self open:pathName attributes:#(O_RDWR O_APPEND) mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3645
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3646
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3647
openFileForReadWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3648
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3649
    ^ self open:pathName attributes:#(O_RDWR)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3650
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3651
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3652
openFileForWrite:pathName
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3653
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  3654
    ^ self open:pathName attributes:#(O_WRONLY)  mode:nil
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3655
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  3656
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3657
recursiveCopyDirectory:sourcePathName to:destination
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3658
    "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
  3659
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3660
12530
96a8b0ef61f5 changed: #recursiveCopyDirectory:to:
Stefan Vogel <sv@exept.de>
parents: 12458
diff changeset
  3661
    ^ 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
  3662
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3663
    "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
  3664
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3665
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3666
recursiveRemoveDirectory:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3667
    "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
  3668
     Return true if successful."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3669
10930
95015f0d599e Use full pathname and quoting when executing commands
Stefan Vogel <sv@exept.de>
parents: 10800
diff changeset
  3670
    ^ self executeCommand:('/bin/rm -rf ''' , fullPathName , '''')
3496
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3673
     OperatingSystem recursiveCreateDirectory:'foo/bar/baz'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3674
     OperatingSystem recursiveRemoveDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3675
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3676
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  3677
    "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
  3678
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3679
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3680
removeDirectory:fullPathName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3681
    "remove the directory named 'fullPathName'.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3682
     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
  3683
     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
  3684
     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
  3685
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3686
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3687
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3688
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3689
    if (__isStringLike(fullPathName)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3690
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3691
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3692
            ret = rmdir((char *) __stringVal(fullPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3693
        } while (ret < 0 && errno == EINTR);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3694
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3695
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3696
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3697
            RETURN ( false );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3698
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3699
        RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3700
    }
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
    "/ either not a string argument,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3704
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3705
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3706
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3707
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3708
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3709
     OperatingSystem createDirectory:'foo'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3710
     OperatingSystem removeDirectory:'foo'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3711
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3712
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3713
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3714
removeFile:fullPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3715
    "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
  3716
     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
  3717
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3718
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3719
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3720
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3721
    if (__isStringLike(fullPathName)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3722
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3723
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3724
            ret = unlink((char *) __stringVal(fullPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3725
        } while (ret < 0 && errno == EINTR);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3726
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3727
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3728
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3729
            RETURN ( false );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3730
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3731
        RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3732
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3733
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3734
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3735
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3736
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3737
renameFile:oldPath to:newPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3738
    "rename the file 'oldPath' to 'newPath'.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3739
     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
  3740
     correct for the OS used - therefore, this should not be called
11798
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3741
     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
  3742
     any invalid names.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3743
     Returns true if successful, false if not"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3744
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3745
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3746
    int ret, eno;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3747
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3748
    if (__isStringLike(oldPath) && __isStringLike(newPath)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3749
#if defined(HAS_RENAME)
11798
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3750
        __BEGIN_INTERRUPTABLE__
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3751
        do {
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3752
            ret = rename((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3753
        } while (ret < 0 && errno == EINTR);
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3754
        __END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3755
#else
11798
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3756
        ret = link((char *) __stringVal(oldPath), (char *) __stringVal(newPath));
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3757
        if (ret >= 0) {
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3758
            ret = unlink((char *) __stringVal(oldPath));
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3759
            if (ret < 0) {
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3760
                eno = errno;
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3761
                unlink((char *) __stringVal(newPath));
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3762
                errno = eno;
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3763
            }
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3764
        }
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3765
#endif
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3766
        if (ret < 0) {
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3767
            @global(LastErrorNumber) = __mkSmallInteger(errno);
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3768
            RETURN ( false );
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3769
        }
7ca269cbec09 comment
Stefan Vogel <sv@exept.de>
parents: 11762
diff changeset
  3770
        RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3771
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3772
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3773
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3774
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3775
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3776
     OperatingSystem renameFile:'foo' to:'bar'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3777
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3778
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3779
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3780
truncateFile:aPathName to:newSize
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3781
    "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
  3782
     This may not be supported on all architectures.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3783
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3784
     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
  3785
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3786
%{
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3787
#if defined(HAS_TRUNCATE) || defined(HAS_FTRUNCATE)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3788
    int ret;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3789
    off_t truncateSize;
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3790
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3791
    if (!__isStringLike(aPathName))
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3792
	goto getOutOfHere;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3793
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3794
    if (__isSmallInteger(newSize)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3795
	truncateSize = __intVal(newSize);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3796
	if (truncateSize < 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3797
	    goto getOutOfHere;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3798
	}
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3799
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3800
	truncateSize = __signedLongIntVal(newSize);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3801
	if (truncateSize < 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3802
	    goto getOutOfHere;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3803
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3804
	if (truncateSize == 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3805
	    if (sizeof(truncateSize) == 8) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3806
		if (__signedLong64IntVal(newSize, &truncateSize) == 0 || truncateSize < 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3807
		    goto getOutOfHere;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3808
		}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3809
	    } else {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3810
		goto getOutOfHere;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3811
	    }
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3812
	}
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3813
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3814
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3815
#if defined(HAS_TRUNCATE)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3816
	__BEGIN_INTERRUPTABLE__
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3817
	do {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3818
	    ret = truncate((char *) __stringVal(aPathName), truncateSize);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3819
	} while (ret < 0 && errno == EINTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3820
	__END_INTERRUPTABLE__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3821
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3822
# ifdef HAS_FTRUNCATE
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3823
    {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3824
	int fd;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3825
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3826
	do {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3827
	    fd = open((char *) __stringVal(aPathName), 2);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3828
	} while (fd < 0 && errno == EINTR);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3829
	if (fd < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  3830
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3831
	    RETURN ( false );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3832
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3833
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3834
	ret = ftruncate(fd, truncateSize);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3835
	close(fd);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3836
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3837
# endif /* HAS_FTRUNCATE */
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3838
#endif
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3839
    if (ret < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  3840
	@global(LastErrorNumber) = __mkSmallInteger(errno);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3841
	RETURN ( false );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3842
    }
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3843
    RETURN (true);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  3844
getOutOfHere:;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3845
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3846
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3847
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3848
! !
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
!UnixOperatingSystem class methodsFor:'file access rights'!
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
accessMaskFor:aSymbol
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  3853
    "return the access bits mask for numbers as returned by
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3854
     OperatingSystem>>accessModeOf:
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3855
     and expected by OperatingSystem>>changeAccessModeOf:to:.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3856
     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
  3857
     (never hardcode 8rxxx into your code)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3858
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3859
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3860
#   ifndef S_IRUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3861
    /* posix systems should define these ... */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3862
#    define S_IRUSR 0400
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3863
#    define S_IWUSR 0200
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3864
#    define S_IXUSR 0100
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3865
#    define S_IRGRP 0040
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3866
#    define S_IWGRP 0020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3867
#    define S_IXGRP 0010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3868
#    define S_IROTH 0004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3869
#    define S_IWOTH 0002
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3870
#    define S_IXOTH 0001
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3871
#    define S_ISUID 04000
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3872
#    define S_ISGID 02000
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3873
#    define S_ISVTX 01000
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3874
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3875
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3876
    if (aSymbol == @symbol(readUser)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3877
	RETURN ( __mkSmallInteger(S_IRUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3878
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3879
    if (aSymbol == @symbol(writeUser)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3880
	RETURN ( __mkSmallInteger(S_IWUSR) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3881
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3882
    if (aSymbol == @symbol(executeUser)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3883
	RETURN ( __mkSmallInteger(S_IXUSR) );
3496
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
    if (aSymbol == @symbol(readGroup)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3886
	RETURN ( __mkSmallInteger(S_IRGRP) );
3496
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
    if (aSymbol == @symbol(writeGroup)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3889
	RETURN ( __mkSmallInteger(S_IWGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3890
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3891
    if (aSymbol == @symbol(executeGroup)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3892
	RETURN ( __mkSmallInteger(S_IXGRP) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3893
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3894
    if (aSymbol == @symbol(readOthers)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3895
	RETURN ( __mkSmallInteger(S_IROTH) );
3496
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
    if (aSymbol == @symbol(writeOthers)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3898
	RETURN ( __mkSmallInteger(S_IWOTH) );
3496
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
    if (aSymbol == @symbol(executeOthers)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3901
	RETURN ( __mkSmallInteger(S_IXOTH) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3902
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3903
    if (aSymbol == @symbol(setUid)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3904
	RETURN ( __mkSmallInteger(S_ISUID) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3905
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3906
    if (aSymbol == @symbol(setGid)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3907
	RETURN ( __mkSmallInteger(S_ISGID) );
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3908
    }
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3909
    if (aSymbol == @symbol(removeOnlyByOwner)) {
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
  3910
	RETURN ( __mkSmallInteger(S_ISVTX) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3911
    }
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
    ^ self primitiveFailed
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 accessMaskFor:#readUser
10662
865a5649d8d6 More file mode bit definitions
Stefan Vogel <sv@exept.de>
parents: 10586
diff changeset
  3917
     OperatingSystem accessMaskFor:#removeOnlyByOwner
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3921
accessModeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3922
    "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
  3923
     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
  3924
     Notice that the returned number is OS dependent - use the
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3925
     modeMasks as returned by OperatingSystem>>accessMaskFor:"
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3926
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3927
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3928
     this could have been implemented as:
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3929
        (self infoOf:aPathName) at:#mode
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3930
     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
  3931
    "
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
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3934
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3935
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3936
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3937
    if (__isStringLike(aPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3938
# ifdef TRACE_STAT_CALLS
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3939
        printf("stat on '%s' for accessMode\n", __stringVal(aPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3940
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3941
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3942
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3943
            ret = stat((char *) __stringVal(aPathName), &buf);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3944
        } while ((ret < 0) && (errno == EINTR));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3945
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3946
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3947
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3948
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3949
            RETURN ( nil );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3950
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3951
        RETURN ( __mkSmallInteger(buf.st_mode & 0777) );
3496
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
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3954
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3955
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3956
   "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  3957
    (OperatingSystem accessModeOf:'/') printStringRadix:8
3496
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3961
changeAccessModeOf:aPathName to:modeBits
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3962
    "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
  3963
     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
  3964
     independent. Return true if changed,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3965
     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
  3966
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3967
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3968
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3969
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3970
    if (__isStringLike(aPathName) && __isSmallInteger(modeBits)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3971
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3972
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3973
            ret = chmod((char *)__stringVal(aPathName), __intVal(modeBits));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3974
        } while (ret < 0 && errno == EINTR);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3975
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3976
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3977
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3978
            RETURN ( false );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3979
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  3980
        RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3981
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3982
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3983
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3984
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3985
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3986
!UnixOperatingSystem class methodsFor:'file locking'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3987
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3988
lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3989
   "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
  3990
    (such as returned by ExternalStream>>fileDescriptor).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3991
    On some systems, only advisory locks are available -
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3992
    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
  3993
    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
  3994
    (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
  3995
    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
  3996
    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
  3997
    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
  3998
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  3999
    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
  4000
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4001
    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
  4002
    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
  4003
    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
  4004
    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
  4005
    argument."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4006
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4007
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4008
    if (__isSmallInteger(aFileDescriptor)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4009
	int fd = __intVal(aFileDescriptor);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4010
	int lockArg;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4011
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4012
	/*
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4013
	 * claus: sigh - each one has a different interface ...
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4014
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4015
#if defined(F_SETLK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4016
	{
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4017
	    /*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4018
	     * new fcntl(SETLK) interface;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4019
	     * available on SYSV4 and Linux
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4020
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4021
	    struct flock flock;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4022
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4023
	    if (isSharedReadLock == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4024
		flock.l_type = F_RDLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4025
	    } else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4026
		flock.l_type = F_WRLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4027
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4028
	    flock.l_whence = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4029
	    flock.l_start = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4030
	    flock.l_len = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4031
	    lockArg = F_SETLK;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4032
# if defined(F_SETLKW)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4033
	    if (blockIfLocked == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4034
		lockArg = F_SETLKW;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4035
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4036
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4037
	    if (fcntl(fd, lockArg, &flock) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4038
		RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4039
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4040
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4041
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4042
#else /* no F_SETLK available */
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
# if defined(LOCK_EX) && defined(LOCK_UN)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4045
	/*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4046
	 * BSD 4.3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4047
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4048
	lockArg = LOCK_EX;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4049
#  if defined(LOCK_SH)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4050
	if (isSharedReadLock == true) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4051
	    lockArg = LOCK_SH
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4052
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4053
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4054
#  if defined(LOCK_NB)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4055
	if (blockIfLocked == false) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4056
	    lockArg |= LOCK_NB;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4057
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4058
#  endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4059
	if (flock(fd, lockArg) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4060
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4061
	}
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
# else /* no flock available */
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
#  if defined(F_LOCK) && defined(F_UNLOCK)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4066
	/*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4067
	 * SYSV3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4068
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4069
	if (lockf(fd, F_LOCK, 0) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4070
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4071
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4072
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4073
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4074
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4075
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4076
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4077
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4078
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4079
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4080
supportsFileLinks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4081
    "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
  4082
     Typically, only unix returns true here."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4083
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4084
    ^ true
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4085
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4086
    "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
  4087
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4088
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4089
supportsFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4090
    "return true, if the OS supports file locking"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4091
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4092
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4093
#if defined(F_SETLK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4094
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4095
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4096
# if defined(LOCK_EX) && defined(LOCK_UN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4097
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4098
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4099
#  if defined(F_LOCK) && defined(F_UNLOCK)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4100
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4101
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4102
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4103
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4104
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4105
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4106
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4107
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4108
     OperatingSystem supportsFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4109
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4110
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4111
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4112
supportsNonBlockingFileLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4113
    "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
  4114
     (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
  4115
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4116
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4117
#if defined(F_SETLK) && defined(F_SETLKW)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4118
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4119
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4120
# 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
  4121
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4122
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4123
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4124
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4125
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4126
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4127
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4128
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4129
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4130
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4131
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4132
supportsSharedLocks
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4133
    "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
  4134
     file locking."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4135
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4136
%{ /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4137
#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
  4138
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4139
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4140
# 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
  4141
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4142
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4143
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4144
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4145
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4146
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4147
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4148
     OperatingSystem supportsNonBlockingFileLocks
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4149
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4150
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4151
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4152
unlockFD:aFileDescriptor
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4153
    "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
  4154
     which was previously aquired by #lockFD:.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4155
     Return false, if the unlock failed
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4156
     (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
  4157
      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
  4158
     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
  4159
     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
  4160
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4161
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4162
    if (__isSmallInteger(aFileDescriptor)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4163
	int fd = __intVal(aFileDescriptor);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4164
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4165
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4166
	 * claus: sigh - each one has a different interface ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4167
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4168
#if defined(F_SETLK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4169
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4170
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4171
	     * new fcntl(SETLK) interface;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4172
	     * available on SYSV4 and Linux
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4173
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4174
	    struct flock flock;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4175
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4176
	    flock.l_type = F_UNLCK;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4177
	    flock.l_whence = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4178
	    flock.l_start = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4179
	    flock.l_len = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4180
	    if (fcntl(fd, F_SETLK, &flock) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4181
		RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4182
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4183
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4184
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4185
#else /* no F_SETLK available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4186
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4187
# if defined(LOCK_EX) && defined(LOCK_UN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4188
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4189
	 * BSD 4.3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4190
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4191
	if (flock(fd, LOCK_UN) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4192
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4193
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4194
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4195
# else /* no flock available */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4196
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4197
#  if defined(F_LOCK) && defined(F_UNLOCK)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4198
	/*
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4199
	 * SYSV3 advisory locks
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4200
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4201
	if (lockf(fd, F_UNLOCK, 0) != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4202
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4203
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4204
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4205
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4206
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4207
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4208
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4209
    ^ false
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4212
!UnixOperatingSystem class methodsFor:'file queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4213
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4214
caseSensitiveFilenames
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4215
    "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
  4216
     On MSDOS, this will return false;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4217
     on a real OS, we return true."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4218
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4219
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4220
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4221
    "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
  4222
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4223
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4224
compressPath:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4225
    "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
  4226
     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
  4227
     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
  4228
     if realPath and popen failed."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4229
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4230
    |names n "{ Class: SmallInteger }" |
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4231
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4232
    names := pathName
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4233
		asCollectionOfSubstringsSeparatedBy:self fileSeparator.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4234
    names := names asOrderedCollection.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4235
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4236
     cut off initial double-slashes
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4237
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4238
    [names startsWith:#('' '')] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4239
	names removeFirst.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4240
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4241
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4242
     cut off double-slashes at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4243
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4244
    [names endsWith:#('')] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4245
	names removeLast.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4246
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4247
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4248
     cut off current-dir at beginning
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4249
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4250
    n := names size.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4251
    [(n >= 2) and:[names startsWith:#('.')]] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4252
	names removeFirst.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4253
	n := n - 1.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4254
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4255
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4256
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4257
     cut off parent-dirs at end
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4258
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4259
    [(n > 2)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4260
     and:[(names endsWith:#('..'))
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4261
     and:[((names at:(n - 1)) startsWith:'.') not ]]] whileTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4262
	names removeLast; removeLast.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4263
	n := n - 2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4264
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4265
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4266
    ^ names asStringWith:self fileSeparator
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4267
		    from:1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4268
		    to:n
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4269
		    compressTabs:false final:nil
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4270
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4271
    "
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4272
     OperatingSystem compressPath:'./..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4273
     OperatingSystem compressPath:'/foo/bar/baz/..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4274
     OperatingSystem compressPath:'foo/bar/baz/..'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4275
     OperatingSystem compressPath:'foo/bar/baz/../'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4276
     OperatingSystem compressPath:'foo/bar/baz/..///'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4277
     OperatingSystem compressPath:'///foo/bar/baz/..///'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4278
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4279
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4280
    "Modified: 1.11.1996 / 20:13:48 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4281
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4282
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4283
fileSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4284
    "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
  4285
     This character differs for MSDOS and other systems,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4286
     (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
  4287
      preparation for the future)"
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
    ^ $/
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4290
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4291
    "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
  4292
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4293
13110
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4294
getCurrentDirectory
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4295
    "return the name of the current directory"
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4296
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4297
    |path|
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4298
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4299
%{  /* UNLIMITEDSTACK */
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4300
        char nameBuffer[MAXPATHLEN + 1];
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4301
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4302
        if (getcwd(nameBuffer, MAXPATHLEN)) {
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4303
            OBJ d;
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4304
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4305
            @global(CurrentDirectory) = d = __MKSTRING(nameBuffer);
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4306
            __GSTORE(d);
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4307
            RETURN (d);
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4308
        }
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4309
%}.
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4310
    ^ self primitiveFailed
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4311
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4312
    "
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4313
        self getCurrentDirectory
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4314
    "
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4315
!
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
  4316
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4317
getDiskInfoOf:aDirectoryPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4318
    "return some disk info.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4319
     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
  4320
     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
  4321
     On unix, the information returned is (at least):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4322
	freeBytes
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4323
	totalBytes
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4324
    "
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4325
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  4326
    |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
  4327
     fileSystemIdx sizeIdx usedIdx availIdx capacityIdx mountIdx|
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4328
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4329
    p := PipeStream readingFrom:('df -k ' , aDirectoryPath).
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4330
    p isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4331
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4332
    [
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4333
	outputText := p contentsOfEntireFile.
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6375
diff changeset
  4334
    ] ensure:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4335
	p close.
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4336
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4337
"/ Transcript showCR:outputText asString.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4338
    outputText isNil ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4339
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4340
    outputText := outputText asCollectionOfLines.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4341
    outputText size < 2 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4342
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4343
    keys := (outputText at:1) asLowercase asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4344
    values := (outputText at:2) asCollectionOfWords.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4345
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4346
    "/ 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
  4347
    "/ on some rude Unix versions ...
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4348
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4349
    fileSystemIdx := 1.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4350
    sizeIdx := 2.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4351
    usedIdx := 3.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4352
    availIdx := 4.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4353
    capacityIdx := 5.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4354
    mountIdx := 6.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4355
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4356
    values size < 6 ifTrue:[^ nil].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4357
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4358
    info := IdentityDictionary new.
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4359
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4360
    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
  4361
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4362
	info at:#percentUsed put:n
4223
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4363
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4364
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4365
    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
  4366
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4367
	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
  4368
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4369
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4370
    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
  4371
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4372
	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
  4373
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4374
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4375
    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
  4376
    n notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4377
	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
  4378
    ].
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4379
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4380
    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
  4381
    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
  4382
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4383
    ^ info
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4384
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4385
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4386
     OperatingSystem getDiskInfoOf:'/'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4387
     OperatingSystem getDiskInfoOf:'.'
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4388
    "
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4389
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4390
    "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
  4391
!
46fd62477cb2 added a portable interface to the df-command
Claus Gittinger <cg@exept.de>
parents: 4201
diff changeset
  4392
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4393
getDriveList
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4394
    "return a list of volumes in the system.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4395
     On unix, no such thing like a volume exists
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4396
     - 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
  4397
     On MSDOS, a list of drive letters is returned.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4398
     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
  4399
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4400
    "/
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4401
    "/ default: return array filled with
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4402
    "/ root, home and current directories.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4403
    "/
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4404
    ^ Array
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4405
	with:'/'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4406
	with:(self getHomeDirectory)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4407
	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
  4408
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  4409
    "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
  4410
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4411
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4412
getMountedVolumes
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4413
    "return info about mounted volumes.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4414
     The amount of information returned depends upon the OS, and is
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4415
     not guaranteed to be consistent across architectures.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4416
     On unix, the information returned is (at least):
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4417
	mountPoint - mount point
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4418
	fileSystem - device or NFS-remotePath
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4419
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4420
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4421
    |p outputText keys values info infoEntry|
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4422
4933
bfa38904104e use df -k
Claus Gittinger <cg@exept.de>
parents: 4923
diff changeset
  4423
    p := PipeStream readingFrom:('df -k').
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4424
    p isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4425
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4426
    [
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4427
	outputText := p contentsOfEntireFile.
6421
58dca33cf0fc #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 6375
diff changeset
  4428
    ] ensure:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4429
	p close.
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4430
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4431
"/ Transcript showCR:outputText asString.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4432
    outputText isNil ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4433
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4434
    outputText := outputText asCollectionOfLines.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4435
    outputText size < 2 ifTrue:[^ nil].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4436
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4437
    keys := (outputText at:1) asLowercase asCollectionOfWords.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4438
    "/ we may have to validate the following column indices
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4439
    "/ on some rude Unix versions ...
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4440
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4441
    info := OrderedCollection new.
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4442
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4443
    outputText from:2 do:[:line |
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4444
	values := line asCollectionOfWords.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4445
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4446
	values size >= 2 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4447
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4448
	    infoEntry := IdentityDictionary new.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4449
	    infoEntry at:#mountPoint put:(values last).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4450
	    infoEntry at:#fileSystem put:(values first).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4451
	    info add:infoEntry.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4452
	]
4853
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4453
    ].
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4454
    ^ info
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4455
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4456
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4457
     OperatingSystem getMountedVolumes
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4458
    "
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4459
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4460
    "Modified: / 22.5.1999 / 00:32:13 / cg"
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4461
!
3f5ed291c362 added getMountedVolumes
ca
parents: 4753
diff changeset
  4462
4201
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4463
getNullDevice
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4464
    "return the name of the OS's null device"
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4465
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4466
    ^ '/dev/null'
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4467
!
591bf7d022d8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4115
diff changeset
  4468
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4469
infoOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4470
    "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
  4471
     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
  4472
     the returned object) is:
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4473
	 type            - a symbol giving the files type
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4474
	 mode            - numeric access mode
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4475
	 uid             - owners user id
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4476
	 gid             - owners group id
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4477
	 size            - files size
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4478
	 id              - files number (i.e. inode number)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4479
	 accessed        - last access time (as Timestamp)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4480
	 modified        - last modification time (as Timestamp)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4481
	 statusChanged   - last status change time (as Timestamp)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4482
	 alternativeName     - (windows only:) the MSDOS name of the file
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4483
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4484
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4485
	 recordAttributes    - (VMS only:) recordAttributes
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4486
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4487
	 recordSize          - (VMS only:) record size.
3496
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
     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
  4490
     all of the information.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4491
     Return nil if such a file does not exist.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4492
     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
  4493
     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
  4494
     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
  4495
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4496
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4497
    |type mode uid gid size id nLink aOStime mOStime cOStime error|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4498
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4499
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4500
    int ret;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4501
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4502
    if (!__isStringLike(aPathName)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4503
	error = @symbol(badArgument);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4504
	goto out;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4505
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4506
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4507
# ifdef TRACE_STAT_CALLS
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4508
    printf("stat on '%s' for info\n", __stringVal(aPathName));
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4509
# endif
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4510
    __BEGIN_INTERRUPTABLE__
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4511
    do {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4512
	ret = stat((char *) __stringVal(aPathName), &buf);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4513
    } while ((ret < 0) && (errno == EINTR));
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4514
    __END_INTERRUPTABLE__
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4515
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4516
    if (ret < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4517
	error = __mkSmallInteger(errno);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4518
	@global(LastErrorNumber) = error;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4519
	goto out;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4520
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4521
    switch (buf.st_mode & S_IFMT) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4522
	case S_IFDIR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4523
	    type = @symbol(directory);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4524
	    break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4525
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4526
	case S_IFREG:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4527
	    type = @symbol(regular);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4528
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4529
# ifdef S_IFCHR
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4530
	case S_IFCHR:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4531
	    type = @symbol(characterSpecial);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4532
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4533
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4534
# ifdef S_IFBLK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4535
	case S_IFBLK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4536
	    type = @symbol(blockSpecial);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4537
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4538
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4539
# ifdef S_IFMPC
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4540
	case S_IFMPC:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4541
	    type = @symbol(multiplexedCharacterSpecial);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4542
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4543
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4544
# ifdef S_IFMPB
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4545
	case S_IFMPB:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4546
	    type = @symbol(multiplexedBlockSpecial);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4547
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4548
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4549
# ifdef S_IFLNK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4550
	case S_IFLNK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4551
	    type = @symbol(symbolicLink);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4552
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4553
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4554
# ifdef S_IFSOCK
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4555
	case S_IFSOCK:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4556
	    type = @symbol(socket);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4557
	    break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4558
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4559
# ifdef S_IFIFO
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4560
	case S_IFIFO:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4561
	    type = @symbol(fifo);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4562
	    break;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4563
# endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4564
	default:
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4565
	    type = @symbol(unknown);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4566
	    break;
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4567
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4568
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4569
    if (sizeof(buf.st_ino) == 8) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4570
	id = __MKUINT64(&buf.st_ino);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4571
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4572
	id = __MKUINT(buf.st_ino);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4573
    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4574
    mode = __mkSmallInteger(buf.st_mode & 0777);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4575
    uid = __mkSmallInteger(buf.st_uid);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4576
    gid = __mkSmallInteger(buf.st_gid);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4577
    nLink = __mkSmallInteger(buf.st_nlink);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4578
    if (sizeof(buf.st_size) == 8) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4579
	size = __MKINT64(&buf.st_size);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4580
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4581
	size = __MKINT(buf.st_size);
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4582
    }
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4583
    aOStime = __MKUINT(buf.st_atime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4584
    mOStime = __MKUINT(buf.st_mtime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4585
    cOStime = __MKUINT(buf.st_ctime);
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4586
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4587
    out:;
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4588
%}.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4589
     mode notNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4590
	"/ now done lazy in FileStatusInfo
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4591
	"/ atime := Timestamp fromOSTime:(aOStime * 1000).
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4592
	"/ mtime := Timestamp fromOSTime:(mOStime * 1000).
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4593
	"/ ctime := Timestamp fromOSTime:(cOStime * 1000).
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4594
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4595
	^ FileStatusInfo
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4596
		    type:type
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4597
		    mode:mode
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4598
		    uid:uid
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4599
		    gid:gid
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4600
		    size:size
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4601
		    id:id
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4602
		    accessed:aOStime
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4603
		    modified:mOStime
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4604
		    statusChanged:cOStime
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4605
		    path:nil
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4606
		    numLinks:nLink.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4607
    ].
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4608
    error notNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4609
	^ nil.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4610
    ].
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4611
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4612
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4613
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4614
   "
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4615
    OperatingSystem infoOf:'/ccccccc'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4616
    (OperatingSystem infoOf:'/') uid
7889
5e96f8cdf9aa Fix comment
Stefan Vogel <sv@exept.de>
parents: 7886
diff changeset
  4617
    (OperatingSystem infoOf:'/') accessTime
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4618
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4619
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4620
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4621
isDirectory:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4622
    "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
  4623
     (i.e. exists and is a directory).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4624
     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
  4625
     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
  4626
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4627
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4628
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4629
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4630
    if (__isStringLike(aPathName)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4631
        struct stat buf;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4632
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4633
# ifdef TRACE_STAT_CALLS
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4634
        printf("stat on '%s' for isDirectory\n", __stringVal(aPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4635
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4636
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4637
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4638
            ret = stat((char *) __stringVal(aPathName), &buf);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4639
        } while ((ret < 0) && (errno == EINTR));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4640
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4641
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4642
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4643
            RETURN ( false );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4644
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4645
        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
  4646
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4647
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4648
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4649
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4650
    "an alternative implementation would be:
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4651
        ^ (self infoOf:aPathName) type == #directory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4652
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4653
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4654
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4655
isExecutable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4656
    "return true, if the given file is executable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4657
     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
  4658
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4659
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4660
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4661
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4662
    if (__isStringLike(aPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4663
# ifdef TRACE_ACCESS_CALLS
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4664
        printf("access on '%s' for executable\n", __stringVal(aPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4665
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4666
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4667
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4668
            ret = access(__stringVal(aPathName), X_OK);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4669
        } while ((ret < 0) && (errno == EINTR));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4670
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4671
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4672
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4673
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4674
        RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4675
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4676
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4677
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4678
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4679
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4680
isReadable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4681
    "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
  4682
     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
  4683
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4684
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4685
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4686
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4687
    if (__isStringLike(aPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4688
# ifdef TRACE_ACCESS_CALLS
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4689
        printf("access on '%s' for readable\n", __stringVal(aPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4690
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4691
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4692
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4693
            ret = access(__stringVal(aPathName), R_OK);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4694
        } while ((ret < 0) && (errno == EINTR));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4695
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4696
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4697
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4698
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4699
        RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4700
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4701
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4702
    ^ self primitiveFailed
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4705
isValidPath:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4706
    "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
  4707
     (i.e. the file or directory exists)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4708
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4709
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4710
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4711
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4712
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4713
    if (__isStringLike(aPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4714
# ifdef TRACE_STAT_CALLS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4715
	printf("stat on '%s' for isValidPath\n", __stringVal(aPathName));
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4716
# endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4717
	__BEGIN_INTERRUPTABLE__
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4718
	do {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4719
	    ret = stat((char *) __stringVal(aPathName), &buf);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4720
	} while ((ret < 0) && (errno == EINTR));
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4721
	__END_INTERRUPTABLE__
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4722
	if (ret < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4723
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4724
	    RETURN (false);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4725
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4726
	RETURN ( ret ? false : true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4727
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4728
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4729
    ^ self primitiveFailed
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4730
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4731
"/ alternative:
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  4732
"/        ^ (self infoOf:aPathName) notNil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4733
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4734
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4735
isWritable:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4736
    "return true, if the given file is writable.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4737
     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
  4738
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4739
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4740
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4741
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4742
    if (__isStringLike(aPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4743
# ifdef TRACE_ACCESS_CALLS
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4744
        printf("access on '%s' for writable\n", __stringVal(aPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4745
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4746
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4747
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4748
            ret = access(__stringVal(aPathName), W_OK);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4749
        } while ((ret < 0) && (errno == EINTR));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4750
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4751
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4752
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4753
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  4754
        RETURN ( ((ret == 0) ? true : false) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4755
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4756
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4757
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4758
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4759
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4760
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
  4761
    "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
  4762
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4763
     The info (for which corresponding access methods are understood by
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4764
     the returned object) is:
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4765
	 type            - a symbol giving the files type
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4766
	 mode            - numeric access mode
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4767
	 uid             - owners user id
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4768
	 gid             - owners group id
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4769
	 size            - files size
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4770
	 id              - files number (i.e. inode number)
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4771
	 accessed        - last access time (as Timestamp)
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4772
	 modified        - last modification time (as Timestamp)
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4773
	 statusChanged   - last status change time (as Timestamp)
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4774
	 alternativeName     - (windows only:) the MSDOS name of the file
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4775
	 recordFormatNumeric - (VMS only:) numeric value of the recordFormat
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4776
	 recordFormat        - (VMS only:) symbolic value of the recordFormat
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4777
	 recordAttributes    - (VMS only:) recordAttributes
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4778
	 fixedHeaderSize     - (VMS only:) fixed header size in a variable record format
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4779
	 recordSize          - (VMS only:) record size.
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4780
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4781
     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
  4782
     all of the information.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4783
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4784
     If aPathName is invalid, or its NOT a symbolic link, nil is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4785
     (which means, that systems like VMS or MSDOS always return nil here.)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4786
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4787
     Return the info about the link itself,
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4788
     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
  4789
     in case of a symbolic link."
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4790
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4791
    |type mode uid gid size id nLink aOStime mOStime cOStime path|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4792
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4793
%{  /* STACK: 1200 */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  4794
#if defined(S_IFLNK)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4795
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4796
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4797
    char pathBuffer[1024];
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4798
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  4799
    if (__isStringLike(aPathName)) {
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4800
	__BEGIN_INTERRUPTABLE__
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4801
	do {
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4802
	    ret = lstat((char *) __stringVal(aPathName), &buf);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4803
	} while ((ret < 0) && (errno == EINTR));
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4804
	__END_INTERRUPTABLE__
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4805
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4806
	if (ret < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4807
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4808
	    RETURN ( nil );
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4809
	}
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4810
	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
  4811
    # ifdef S_IFLNK
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4812
	    case S_IFLNK:
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4813
		type = @symbol(symbolicLink);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4814
		if ((ret = readlink((char *) __stringVal(aPathName), pathBuffer, sizeof(pathBuffer))) < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4815
		    @global(LastErrorNumber) = __mkSmallInteger(errno);
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4816
		    RETURN ( nil );
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4817
		}
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4818
		pathBuffer[ret] = '\0';  /* readlink does not 0-terminate */
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4819
		path = __MKSTRING(pathBuffer);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4820
		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
  4821
    # endif
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4822
	    case S_IFDIR:
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4823
		type = @symbol(directory);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4824
		break;
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4825
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4826
	    case S_IFREG:
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4827
		type = @symbol(regular);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4828
		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
  4829
    # ifdef S_IFCHR
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4830
	    case S_IFCHR:
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4831
		type = @symbol(characterSpecial);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4832
		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
  4833
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4834
    # ifdef S_IFBLK
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4835
	    case S_IFBLK:
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4836
		type = @symbol(blockSpecial);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4837
		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
  4838
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4839
    # ifdef S_IFMPC
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4840
	    case S_IFMPC:
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4841
		type = @symbol(multiplexedCharacterSpecial);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4842
		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
  4843
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4844
    # ifdef S_IFMPB
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4845
	    case S_IFMPB:
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4846
		type = @symbol(multiplexedBlockSpecial);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4847
		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
  4848
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4849
    # ifdef S_IFSOCK
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4850
	    case S_IFSOCK:
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4851
		type = @symbol(socket);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4852
		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
  4853
    # endif
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
  4854
    # ifdef S_IFIFO
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4855
	    case S_IFIFO:
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4856
		type = @symbol(fifo);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4857
		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
  4858
    # endif
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4859
	    default:
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4860
		type = @symbol(unknown);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4861
		break;
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4862
	}
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4863
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4864
	if (sizeof(buf.st_ino) == 8) {
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4865
	    id = __MKUINT64(&buf.st_ino);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4866
	} else {
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4867
	    id = __MKUINT(buf.st_ino);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4868
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4869
	mode = __mkSmallInteger(buf.st_mode & 0777);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4870
	uid = __mkSmallInteger(buf.st_uid);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4871
	gid = __mkSmallInteger(buf.st_gid);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  4872
	nLink = __mkSmallInteger(buf.st_nlink);
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4873
	if (sizeof(buf.st_size) == 8) {
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4874
	    size = __MKINT64(&buf.st_size);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4875
	} else {
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4876
	    size = __MKINT(buf.st_size);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4877
	}
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4878
	aOStime = __MKUINT(buf.st_atime);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4879
	mOStime = __MKUINT(buf.st_mtime);
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4880
	cOStime = __MKUINT(buf.st_ctime);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4881
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4882
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4883
    RETURN ( nil );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4884
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4885
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4886
    mode notNil ifTrue:[
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4887
	^ FileStatusInfo
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4888
	    type:type
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4889
	    mode:mode
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4890
	    uid:uid
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4891
	    gid:gid
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4892
	    size:size
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4893
	    id:id
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4894
	    accessed:aOStime
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4895
	    modified:mOStime
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4896
	    statusChanged:cOStime
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4897
	    path:path
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4898
	    numLinks:nLink.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4899
   ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4900
   ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4901
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4902
   "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4903
    OperatingSystem infoOf:'Make.proto'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  4904
    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
  4905
    OperatingSystem linkInfoOf:'/usr/tmp'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4906
   "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4907
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4908
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4909
mountPoints
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4910
    "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
  4911
     As this might be expensive on some systems,
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4912
     the info is cached for some time (5 minutes)"
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4913
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4914
    CacheMountPointsTimeStamp notNil ifTrue:[
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4915
	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
  4916
	    ^ CachedMountPoints
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4917
	].
8735
531252ebbbe3 Fix a race in #mountPoints
Stefan Vogel <sv@exept.de>
parents: 8705
diff changeset
  4918
    ].
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4919
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4920
    '/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
  4921
	CachedMountPoints := self mountPointsFromProcFS.
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4922
	CacheMountPointsTimeStamp := Timestamp now.
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  4923
	^ CachedMountPoints
7760
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4924
    ].
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4925
e9e1e1650340 mount point stuff
Claus Gittinger <cg@exept.de>
parents: 7741
diff changeset
  4926
    "/ 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
  4927
    ^ #()
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4928
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4929
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4930
     OperatingSystem mountPoints
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4931
    "
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4932
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
  4933
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4934
parentDirectoryName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4935
    "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
  4936
     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
  4937
     for other systems.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4938
     (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
  4939
      preparation for the future)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4940
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4941
    ^ '..'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4942
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4943
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4944
pathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4945
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4946
     - 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
  4947
     This method needs the path to be valid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4948
     (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
  4949
     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
  4950
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4951
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4952
    |p path command|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4953
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4954
    "some systems have a convenient function for this ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4955
    path := self primPathNameOf:pathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4956
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4957
    path isNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4958
	(self isValidPath:pathName) ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4959
	    p := pathName.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4960
	    [(p size > 1)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4961
	     and:[p endsWith:(self fileSeparator)]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4962
	    ] whileTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4963
		p := p copyWithoutLast:1.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4964
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4965
	    ^ p
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4966
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4967
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4968
	(SlowFork==true or:[PipeFailed==true]) ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4969
	    PipeStream openErrorSignal handle:[:ex |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4970
		PipeFailed := true.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4971
		'UnixOperatingSystem [warning]: cannot fork/popen' errorPrintCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4972
		ex return.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4973
	    ] do:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4974
		"have to fall back ..."
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4975
		command := 'cd "' , pathName , '"; pwd'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4976
		p := PipeStream readingFrom:command.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4977
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4978
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4979
	    (p isNil or:[p atEnd]) ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4980
		('UnixOperatingSystem [warning]: PipeStream for <' , command , '> failed') errorPrintCR.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4981
	    ] ifFalse:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4982
		path := p nextLine.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4983
		p close.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4984
	    ]
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4985
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4986
	path isNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4987
	    "/
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4988
	    "/ return the original - there is nothing else can we do
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4989
	    "/
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4990
	    path := pathName
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4991
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4992
	(SlowFork==true or:[ForkFailed==true]) ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4993
	    path := self compressPath:path
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  4994
	]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4995
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4996
    ^ path.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4997
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4998
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  4999
     OperatingSystem pathNameOf:'.'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5000
     OperatingSystem pathNameOf:'../smalltalk/../smalltalk'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5001
     OperatingSystem pathNameOf:'../../..'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5002
     OperatingSystem pathNameOf:'..'
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5003
     OperatingSystem pathNameOf:'/tmp////'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5004
     OperatingSystem pathNameOf:'/foo/bar'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5005
     OperatingSystem pathNameOf:'/foo/bar/'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5006
     OperatingSystem pathNameOf:'/foo/bar//'
3496
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
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5009
    "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
  5010
    "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
  5011
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5012
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5013
primIdOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5014
    "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
  5015
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  5016
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5017
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5018
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5019
    unsigned INT ino;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5020
    OBJ retVal;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5021
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5022
    if (__isStringLike(aPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5023
# ifdef TRACE_STAT_CALLS
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5024
        printf("stat on '%s' for id\n", __stringVal(aPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5025
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5026
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5027
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5028
            ret = stat((char *) __stringVal(aPathName), &buf);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5029
        } while (ret < 0 && errno == EINTR);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5030
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5031
        if (ret >= 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5032
            ino = buf.st_ino;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5033
            retVal = __MKUINT(ino);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5034
            RETURN (retVal);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5035
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5036
        @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5037
        RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5038
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5039
    RETURN (nil);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5040
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5041
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5042
5492
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5043
primInfoOf:aPathName
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5044
   "for rel5 only"
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5045
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5046
   ^ self primitiveFailed
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5047
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5048
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5049
!
11d7a1839cfe rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
  5050
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5051
primPathNameOf:pathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5052
    "return the pathName of the argument, aPathString,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5053
     - 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
  5054
     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
  5055
     realPath library function.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5056
     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
  5057
     from what you expect."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5058
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5059
    |path|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5060
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  5061
%{  /* UNLIMITEDSTACK */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5062
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5063
    if (__isStringLike(pathName)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5064
        if (strcmp(__stringVal(pathName), ".") == 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5065
            char nameBuffer[MAXPATHLEN + 1];
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5066
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5067
            if (@global(CurrentDirectory) == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5068
                if (getcwd(nameBuffer, MAXPATHLEN)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5069
                    OBJ d;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5070
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5071
                    @global(CurrentDirectory) = d = __MKSTRING(nameBuffer);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5072
                    __GSTORE(d);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5073
                }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5074
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5075
            RETURN (@global(CurrentDirectory));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5076
        }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5077
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5078
#ifdef HAS_REALPATH
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5079
        {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5080
            char nameBuffer[MAXPATHLEN + 1 + MAXPATHLEN + 1];
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5081
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5082
            if (realpath(__stringVal(pathName), nameBuffer)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5083
                RETURN ( __MKSTRING(nameBuffer) );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5084
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5085
            RETURN ( nil );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5086
        }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5087
#endif /* ! HAS_REALPATH */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5088
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5089
%}.
5451
2e21cd54b656 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5448
diff changeset
  5090
    ^ nil
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5091
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5092
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5093
timeOfLastAccess:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5094
    "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
  5095
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5096
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5097
    "could be implemented as:
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5098
        (self infoOf:aPathName) accessed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5099
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5100
    |osSeconds i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5101
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5102
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5103
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5104
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5105
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5106
    if (__isStringLike(aPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5107
# ifdef TRACE_STAT_CALLS
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5108
        printf("stat on '%s' for timeOfLastAccess\n", __stringVal(aPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5109
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5110
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5111
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5112
            ret = stat((char *) __stringVal(aPathName), &buf);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5113
        } while (ret < 0 && errno == EINTR);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5114
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5115
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5116
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5117
            RETURN (nil);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5118
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5119
        osSeconds = __MKUINT(buf.st_atime);
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5120
    }
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5121
%}.
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5122
    osSeconds notNil ifTrue:[^ Timestamp fromOSTime:(osSeconds * 1000)].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5123
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5124
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5125
    i notNil ifTrue:[^ i accessed].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5126
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5127
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5128
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5129
     OperatingSystem timeOfLastAccess:'/'
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5133
timeOfLastChange:aPathName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5134
    "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
  5135
     For nonexistent files, nil is returned."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5136
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5137
    "could be implemented as:
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5138
        (self infoOf:aPathName) modified
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5139
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5140
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5141
    |osSeconds i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5142
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5143
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5144
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5145
    time_t mtime;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5146
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5147
    if (__isStringLike(aPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5148
# ifdef TRACE_STAT_CALLS
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5149
        printf("stat on '%s' for timeOfLastChange\n", __stringVal(aPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5150
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5151
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5152
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5153
            ret = stat((char *) __stringVal(aPathName), &buf);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5154
        } while (ret < 0 && errno == EINTR);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5155
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5156
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5157
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5158
            RETURN ( nil );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5159
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5160
        osSeconds = __MKUINT(buf.st_mtime);
8248
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5161
    }
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5162
%}.
d5d8da879eee Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 7889
diff changeset
  5163
    osSeconds notNil ifTrue:[^ Timestamp fromOSTime:(osSeconds * 1000)].
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5164
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5165
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5166
    i notNil ifTrue:[^ i modified].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5167
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5168
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5169
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5170
     OperatingSystem timeOfLastChange:'/'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5171
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5172
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5173
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5174
typeOf:aPathName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5175
    "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
  5176
     nil is returned.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5177
     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
  5178
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5179
    |i|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5180
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5181
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5182
     this could have been implemented as:
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5183
        (self infoOf:aPathName) type
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5184
     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
  5185
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5186
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5187
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5188
    struct stat buf;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5189
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5190
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5191
    if (__isStringLike(aPathName)) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5192
# ifdef TRACE_STAT_CALLS
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5193
        printf("stat on '%s' for type\n", __stringVal(aPathName));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5194
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5195
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5196
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5197
            ret = stat((char *) __stringVal(aPathName), &buf);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5198
        } while (ret < 0 && errno == EINTR);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5199
        __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5200
        if (ret < 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5201
            @global(LastErrorNumber) = __mkSmallInteger(errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5202
            RETURN ( nil );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5203
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5204
        switch (buf.st_mode & S_IFMT) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5205
            case S_IFDIR:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5206
                RETURN ( @symbol(directory) );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5207
            case S_IFREG:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5208
                RETURN ( @symbol(regular) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5209
# ifdef S_IFCHR
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5210
            case S_IFCHR:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5211
                RETURN ( @symbol(characterSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5212
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5213
# ifdef S_IFBLK
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5214
            case S_IFBLK:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5215
                RETURN ( @symbol(blockSpecial) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5216
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5217
# ifdef S_IFLNK
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5218
            case S_IFLNK:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5219
                RETURN ( @symbol(symbolicLink) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5220
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5221
# ifdef S_IFSOCK
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5222
            case S_IFSOCK:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5223
                RETURN ( @symbol(socket) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5224
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5225
# ifdef S_IFIFO
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5226
            case S_IFIFO:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5227
                RETURN ( @symbol(fifo) );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5228
# endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5229
            default:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5230
                RETURN ( @symbol(unknown) );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
  5231
        }
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5232
    }
3496
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
    i := self infoOf:aPathName.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5235
    i notNil ifTrue:[^ i type].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5236
    ^ nil.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5237
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5238
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5239
     OperatingSystem typeOf:'/'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5240
     OperatingSystem typeOf:'.'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5241
     OperatingSystem typeOf:'Make.proto'
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5242
     OperatingSystem typeOf:'resources/motif.style'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5243
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5244
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5245
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5246
volumeNameOf:aPathString
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5247
    "return the volumeName of the argument, aPath
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5248
     - thats the name of the volume where aPath is.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5249
     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
  5250
     this always returns an empty string."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5251
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5252
    ^ ''
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5253
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  5254
    "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
  5255
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5256
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5257
!UnixOperatingSystem class methodsFor:'interrupts & signals'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5258
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5259
defaultSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5260
    "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
  5261
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5262
     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
  5263
     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
  5264
     default for SIGQUIT (^ \) is to dump core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5265
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5266
     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
  5267
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5268
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5269
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5270
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5271
    if (__isSmallInteger(signalNumber)) {
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5272
#ifdef SIG_DFL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5273
	signal(__intVal(signalNumber), SIG_DFL);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5274
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5275
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5276
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5277
%}.
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
     this error is triggered on non-integer argument
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
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5282
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5283
    "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
  5284
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5285
     'if you hit ^C now, Smalltalk will exit immediately' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5286
     OperatingSystem defaultSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5287
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5288
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5289
     'normal ^C handling again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5290
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5291
!
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
disableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5294
    "turn off IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5295
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5296
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5297
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5298
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5299
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5300
#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
  5301
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5302
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5303
# if defined(SYSV4)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5304
	ret = ioctl(f, I_SETSIG, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5305
# else /*! SYSV4*/
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5306
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5307
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5308
	 * if already clear, there is no need for this syscall ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5309
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5310
	if (flags & FASYNC) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5311
	    ret = fcntl(f, F_SETFL, flags & ~FASYNC);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5312
	    if (ret >= 0) ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5313
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5314
	    ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5315
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5316
# endif /* !SYSV4 */
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5317
	RETURN ( __mkSmallInteger(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5318
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5319
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5320
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5321
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5322
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5323
     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
  5324
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5325
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5326
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5327
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5328
disableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5329
    "disable (Unix-) signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5330
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5331
     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
  5332
     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
  5333
     handling.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5334
     Also, NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5335
     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
  5336
     a signal.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5337
     Use only for fully debugged stand alone applications."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5338
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5339
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5340
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5341
    if (__isSmallInteger(signalNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5342
	int sigNo = __intVal(signalNumber);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5343
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5344
	if (sigNo == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5345
	    RETURN (self);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5346
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5347
#ifdef SIG_IGN
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5348
	signal(sigNo, SIG_IGN);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5349
	RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5350
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5351
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5352
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5353
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5354
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5355
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5356
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5357
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5358
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5359
     'now, ^C is totally ignored ...' printNewline.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5360
     OperatingSystem disableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5361
     1 to:1000000 do:[:i| ].
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5362
     OperatingSystem enableSignal:(OperatingSystem sigINT).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5363
     '^C handled again.' printNewline
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5364
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5365
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5366
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5367
disableTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5368
    "disable timer interrupts.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5369
     WARNING:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5370
	the system will not operate correctly with timer interrupts
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5371
	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
  5372
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5373
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5374
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5375
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5376
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5377
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5378
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5379
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5380
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5381
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5382
    setitimer(ITIMER_REAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5383
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5384
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5386
# if defined(USE_SLOW_ALARM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5387
#  if defined(SIGALRM)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5388
    alarm(0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5389
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5390
#  endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5391
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5392
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5393
#endif
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
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5396
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5397
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5398
enableChildSignalInterrupts
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5399
    "enable childSignal interrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5400
     (SIGCHLD, if the architecture supports it).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5401
     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
  5402
     'childSignalInterrupt' to the ChildSignalInterruptHandler object."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5403
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5404
    self enableSignal:(self sigCHLD)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5405
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5406
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5407
enableIOInterruptsOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5408
    "turn on IO interrupts for a filedescriptor"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5409
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5410
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5411
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5412
    int ret, flags, f;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5413
#ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5414
    extern void __signalIoInterrupt();
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
    static int firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5417
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5418
#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
  5419
    /*
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5420
     * 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
  5421
     * (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
  5422
     */
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5423
# ifdef SIGIO
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5424
#  define THESIGNAL SIGIO
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5425
# else
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5426
#  ifdef SIGPOLL
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5427
#   define THESIGNAL SIGPOLL
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5428
#  else
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5429
#   ifdef SIGURG
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5430
#    define THESIGNAL SIGURG
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5431
#   endif
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5432
#  endif
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5433
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5434
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5435
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5436
	if (firstCall) {
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5437
# ifdef HAS_SIGACTION
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5438
	    struct sigaction act;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5439
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5440
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5441
	     * Do not add SA_RESTART here. A signal can cause a
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5442
	     * thread switch, another thread can do a garbage collect
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5443
	     * and restarted system calls may write into old
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5444
	     * (collected) addresses.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5445
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5446
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5447
	    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
  5448
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5449
	    act.sa_handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5450
	    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
  5451
# else
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5452
#  ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5453
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5454
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5455
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5456
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5457
	    vec.sv_handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5458
	    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
  5459
#  else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5460
	    signal(THESIGNAL, __signalIoInterrupt);
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5461
#  endif /* SIGVEC */
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5462
# endif /* SIGACTION */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5463
	    firstCall = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5464
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5465
#undef THESIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5466
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5467
	f = __intVal(fd);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5468
# if defined(SYSV4)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5469
	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
  5470
# else /*! SYSV4*/
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5471
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5472
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5473
	 * if already set, there is no need for this syscall ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5474
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5475
	if (flags & FASYNC) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5476
	    ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5477
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5478
	    ret = fcntl(f, F_SETFL, flags | FASYNC);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5479
	    if (ret >= 0) ret = flags;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5480
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5481
# endif /*!SYSV4*/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5482
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5483
# if defined(F_SETOWN) || defined(FIOSETOWN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5484
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5485
	    int pid;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5486
	    int ok;
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
	    pid = getpid();
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5489
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5490
#  if defined(F_SETOWN)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5491
	    ok = fcntl(f, F_SETOWN, pid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5492
	    /* 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
  5493
#  else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5494
	    ok = ioctl(f, FIOSETOWN, &pid);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5495
	    /* 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
  5496
#  endif
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5497
	    if (ok < 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5498
		ret = ok;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5499
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5500
	}
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5501
# endif
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5502
	RETURN ( __MKUINT(ret) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5503
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5504
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5505
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5506
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5507
     this error is triggered on non-integer argument
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5508
     or if the system does not support SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5509
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5510
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5511
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5512
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5513
enableSignal:signalNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5514
    "enable (Unix-)signal processing for signalNumber.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5515
     Dont confuse Unix signals with smalltalk signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5516
     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
  5517
     (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
  5518
     sends #signalInterrupt:.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5519
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5520
     NOTICE that signal numbers are not portable between unix
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  5521
     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
  5522
     a signal."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5523
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5524
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5525
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5526
#ifdef NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5527
# define SIG_LIMIT NSIG
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5528
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5529
# ifdef SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5530
#  define SIG_LIMIT SIGUSR2
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5531
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5532
#  ifdef SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5533
#   define SIG_LIMIT SIGUSR
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5534
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5535
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5536
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5537
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5538
#if defined(SIGPOLL) && !defined(SIGIO)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5539
# define SIGIO SIGPOLL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5540
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5541
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5542
#ifdef SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5543
# define CHILD_SIGNAL   SIGCHLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5544
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5545
# ifdef SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5546
#  define CHILD_SIGNAL  SIGCLD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5547
# endif
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5550
    int sigNr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5551
#if defined(SIGINT) || defined(SIGQUIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5552
# ifndef __signalUserInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5553
    extern void __signalUserInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5554
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5555
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5556
#ifdef SIGFPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5557
# ifndef __signalFpExceptionInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5558
    extern void __signalFpExceptionInterrupt(SIGHANDLER_ARG);
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5561
#ifdef SIGIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5562
# ifndef __signalIoInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5563
    extern void __signalIoInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5564
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5565
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5566
#ifdef CHILD_SIGNAL
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5567
# ifndef __signalChildInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5568
    extern void __signalChildInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5569
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5570
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5571
#ifdef SIGPIPE
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5572
# ifndef __signalPIPEInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5573
    extern void __signalPIPEInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5574
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5575
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5576
#ifdef SIGBUS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5577
# ifndef __signalBUSInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5578
    extern void __signalBUSInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5579
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5580
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5581
#ifdef SIGSEGV
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5582
# ifndef __signalSEGVInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5583
    extern void __signalSEGVInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5584
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5585
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5586
#if defined(SIGILL) || defined(SIGEMT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5587
# ifndef __signalTrapInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5588
    extern void __signalTrapInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5589
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5590
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5591
#ifdef SIGALRM
4105
dd93ca0dc062 removed leftOver obsolete win32 code;
Claus Gittinger <cg@exept.de>
parents: 4102
diff changeset
  5592
# ifndef __signalTimerInterrupt
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5593
    extern void __signalTimerInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5594
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5595
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5596
#ifndef __signalInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5597
    extern void __signalInterrupt(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5598
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5599
    void (*handler)(SIGHANDLER_ARG);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5600
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5601
    if (__isSmallInteger(signalNumber)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5602
     && ((sigNr = __intVal(signalNumber)) >= 0)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5603
#ifdef SIG_LIMIT
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5604
     &&  (sigNr <= SIG_LIMIT)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5605
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5606
    ) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5607
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5608
	 * standard signals are forced into standard handlers
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5609
	 * - all others go into general signalInterrupt
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5610
	 */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5611
#if defined(SIGPOLL) && defined(SIGIO)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5612
	if (sigNr == SIGPOLL)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5613
	    sigNr = SIGIO;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5614
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5615
	switch (sigNr) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5616
	    case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5617
		/* enabling a non-supported signal */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5618
		RETURN (self);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5619
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5620
#ifdef SIGBREAK
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5621
	    case SIGBREAK:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5622
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5623
#ifdef SIGINT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5624
	    case SIGINT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5625
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5626
#ifdef SIGQUIT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5627
	    case SIGQUIT:
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5628
#endif
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  5629
#if defined(SIGINT) || defined(SIGQUIT) || defined(SIGBREAK)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5630
		handler = __signalUserInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5631
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5632
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5633
#ifdef SIGFPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5634
	    case SIGFPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5635
		handler = __signalFpExceptionInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5636
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5637
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5638
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5639
#ifdef SIGPIPE
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5640
	    case SIGPIPE:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5641
		handler = __signalPIPEInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5642
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5643
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5644
#ifdef SIGBUS
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5645
	    case SIGBUS:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5646
		handler = __signalBUSInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5647
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5648
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5649
#ifdef SIGSEGV
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5650
	    case SIGSEGV:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5651
		handler = __signalSEGVInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5652
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5653
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5654
#ifdef SIGILL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5655
	    case SIGILL:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5656
		handler = __signalTrapInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5657
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5658
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5659
#ifdef SIGEMT
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5660
	    case SIGEMT:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5661
		handler = __signalTrapInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5662
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5663
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5664
#ifdef SIGIO
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5665
	    case SIGIO:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5666
		handler = __signalIoInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5667
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5668
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5669
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5670
#ifdef CHILD_SIGNAL
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5671
	    case CHILD_SIGNAL:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5672
		handler = __signalChildInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5673
		break;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5674
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5675
#ifdef SIGALRM
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5676
	    case SIGALRM:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5677
		handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5678
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5679
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5680
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5681
	    default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5682
		handler = __signalInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5683
		break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5684
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5685
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5686
	{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5687
#ifdef HAS_SIGACTION
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5688
	    struct sigaction act;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5689
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5690
	    /*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5691
	     * Do not add SA_RESTART here. A signal can cause a
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5692
	     * thread switch, another thread can do a garbage collect
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5693
	     * and restarted system calls may write into old
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5694
	     * (collected) addresses.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5695
	     */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5696
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5697
	    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
  5698
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5699
	    act.sa_handler = handler;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5700
	    sigaction(sigNr, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5701
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5702
# ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5703
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5704
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5705
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5706
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5707
	    vec.sv_handler = handler;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5708
	    sigvec(sigNr, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5709
# else
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5710
	    (void) signal(sigNr, handler);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5711
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5712
#endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5713
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5714
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5715
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5716
	 * maybe, we should ret the old enable-status
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5717
	 * as boolean here ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5718
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5719
	RETURN (self);
3496
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
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5722
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5723
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5724
     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
  5725
     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
  5726
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5727
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5728
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5729
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5730
enableTimer:milliSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5731
    "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
  5732
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5733
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5734
    int millis;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5735
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5736
    millis = __intVal(milliSeconds);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5737
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5738
#ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5739
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5740
	static int firstCall = 1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5741
# ifndef __signalTimerInterrupt
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5742
	extern void __signalTimerInterrupt(SIGHANDLER_ARG);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5743
# endif
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5744
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5745
	if (firstCall) {
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5746
# ifdef HAS_SIGACTION
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
  5747
	    struct sigaction act;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5748
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5749
	    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
  5750
	    sigemptyset(&act.sa_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5751
	    act.sa_handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5752
	    sigaction(SIGALRM, &act, 0);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5753
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5754
#  ifdef HAS_SIGVEC
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5755
	    struct sigvec vec;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5756
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5757
	    vec.sv_flags = SV_INTERRUPT;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5758
	    sigemptyset(&vec.sv_mask);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5759
	    vec.sv_handler = __signalTimerInterrupt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5760
	    sigvec(SIGALRM, &vec, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5761
#  else /* neither SIGACTION nor SIGVEC */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5762
	    signal(SIGALRM, __signalTimerInterrupt);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5763
#  endif /* stupid system  */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5764
# endif
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5765
	    firstCall = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5766
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5767
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5768
#endif /* SIGALRM */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5769
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5770
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5771
#if defined(ITIMER_REAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5772
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5773
	struct itimerval dt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5774
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5775
	dt.it_interval.tv_sec = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5776
	dt.it_interval.tv_usec = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5777
	dt.it_value.tv_sec = millis / 1000;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5778
	dt.it_value.tv_usec = (millis % 1000) * 1000;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5779
	setitimer(ITIMER_REAL, &dt, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5780
	RETURN (true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5781
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5782
#else /* no ITIMER_REAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5783
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5784
# ifdef USE_SLOW_ALARM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5785
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5786
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5787
	 * last fallback - use alarm (which only gives 1 second resolution).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5788
	 * 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
  5789
	 * with this. The consequence is that pressing CTRL-C processing and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5790
	 * thread switching will take place much delayed.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5791
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5792
	alarm(1);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5793
	RETURN(true);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5794
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5795
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5796
#endif /* ITIMER_REAL */
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
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5799
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5800
6536
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5801
isFatalSignal:aNumber
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5802
   "return true if a signal with number aNumber is a fatal signal,
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5803
    i.e. some severe internal error occured"
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5804
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5805
   ^ (aNumber == self sigSEGV)
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5806
     or:[aNumber == self sigILL
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5807
     or:[aNumber == self sigBUS]]
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5808
!
bcbce3402340 New: #isFatalSignal:
Stefan Vogel <sv@exept.de>
parents: 6499
diff changeset
  5809
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5810
killProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5811
    "kill a unix process.
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5812
     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
  5813
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5814
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5815
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5816
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5817
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5818
    self sendSignal:(self sigKILL) to:processId.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5819
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5820
    "Modified: / 10.6.1998 / 11:59:12 / cg"
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5821
!
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5822
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5823
killProcessGroup:processGroupId
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5824
    "kill a unix process group.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5825
     The process has a no chance to do some cleanup.
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5826
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5827
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5828
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5829
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3541
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5830
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5831
    self sendSignal:(self sigKILL) to:(processGroupId negated).
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5832
7391c94f47b3 added killProcess / killProcessGroup
Claus Gittinger <cg@exept.de>
parents: 3540
diff changeset
  5833
    "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
  5834
!
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
sendSignal:signalNumber to:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5837
    "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
  5838
     Returns false if any error occurred, true otherwise.
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
     Do not confuse UNIX signals with Smalltalk-Signals.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5841
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5842
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5843
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5844
	      OperatingSystem>>getStatusOfProcess:aProcessId
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5845
	      if the signal terminates that process."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5846
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5847
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5848
    if (__bothSmallInteger(signalNumber, processId)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5849
	if (kill(__intVal(processId), __intVal(signalNumber)) < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  5850
	    @global(LastErrorNumber) = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5851
	    RETURN ( false );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5852
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5853
	RETURN ( true );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5854
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5855
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5856
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5857
    "/ either invalid argument (non-integers)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5858
    "/ or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5859
    "/
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5860
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5861
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5862
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5863
startSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5864
    "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
  5865
     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
  5866
     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
  5867
     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
  5868
     (which is of course less correct).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5869
     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
  5870
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5871
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5872
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5873
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5874
#ifndef __spyInterrupt
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5875
    extern void __spyInterrupt();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5876
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5877
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5878
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5879
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5880
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5881
# ifdef SIGVTALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5882
    signal(SIGVTALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5883
# else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5884
#  ifdef SIGALRM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5885
    signal(SIGALRM, __spyInterrupt);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5886
#  else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5887
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5888
     * mhmh - system has neither SIGBTALRM nor SIGALRM ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5889
     * what should we do here ?
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5890
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5891
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5892
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5893
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5894
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5895
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5896
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5897
    dt.it_value.tv_usec = 1000;   /* 1000 Hz */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5898
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5899
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5900
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5901
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5902
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5903
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5904
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5905
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5906
stopSpyTimer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5907
    "stop spy timing - disable spy timer.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5908
     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
  5909
	       spy interrupts."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5910
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5911
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5912
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5913
#if defined(ITIMER_VIRTUAL) && !defined(NO_SETITIMER)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5914
    struct itimerval dt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5915
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5916
    dt.it_interval.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5917
    dt.it_interval.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5918
    dt.it_value.tv_sec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5919
    dt.it_value.tv_usec = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5920
    setitimer(ITIMER_VIRTUAL, &dt, 0);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5921
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5922
#endif /* ITIMER_VIRTUAL */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5923
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5924
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5925
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5926
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5927
terminateProcess:processId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5928
    "terminate a unix process.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5929
     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
  5930
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5931
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5932
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5933
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5934
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  5935
    self sendSignal:(self sigTERM) to:processId.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5936
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5937
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5938
    "Modified: / 27.1.1998 / 20:05:47 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5939
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5940
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5941
terminateProcessGroup:processGroupId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5942
    "terminate a unix process group.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5943
     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
  5944
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5945
     WARNING: in order to avoid zombie processes (on unix),
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5946
	      you may have to fetch the processes exitstatus with
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  5947
	      OperatingSystem>>getStatusOfProcess:aProcessId."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5948
3540
f0a069e481b8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3539
diff changeset
  5949
    self sendSignal:(self sigTERM) to:(processGroupId negated).
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5950
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5951
    "Modified: / 28.12.1995 / 15:05:37 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5952
    "Created: / 23.4.1996 / 16:40:34 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5953
    "Modified: / 27.1.1998 / 20:05:59 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5954
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5955
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5956
!UnixOperatingSystem class methodsFor:'ipc support'!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5957
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5958
makeBidirectionalPipe
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5959
    "make a socketPair, return array with two filedescriptors on success,
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5960
     nil on failure.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5961
     This is a lowLevel entry, not for public use."
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5962
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5963
    |fd1 fd2|
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5964
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5965
%{
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5966
#ifndef NO_SOCKET
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5967
     int fds[2];
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5969
     if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) == -1) {
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  5970
	@global(LastErrorNumber) = __mkSmallInteger(errno);
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  5971
	RETURN ( nil );
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5972
     }
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5973
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5974
     fd1 = __mkSmallInteger(fds[0]);
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5975
     fd2 = __mkSmallInteger(fds[1]);
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5976
#endif
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5977
%}.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5978
    fd1 notNil ifTrue:[
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  5979
	^ Array with:fd1 with:fd2.
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5980
    ].
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5981
    ^ nil
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  5982
!
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5983
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5984
makePTYPair
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5985
    "make a pipe, return array with two filedescriptors on success,
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5986
     nil on failure.
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5987
     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
  5988
     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
  5989
     public interface."
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  5990
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5991
    |fdS fdM|
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5992
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  5993
%{
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5994
    /*
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5995
     * Find a pseudo tty to use and open both sides.
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5996
     *  _fdM receives the master file descriptor while _fdS
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  5997
     *  receives the slave.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5998
     */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  5999
3536
adad0d12c9a8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3534
diff changeset
  6000
#ifdef IRIX5
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6001
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6002
    char *slaveName;
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6003
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6004
    slaveName = _getpty(&_fdM, O_RDWR|O_NDELAY, 0600, 0);
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6005
    if ((slaveName != 0) && (_fdM >= 0)) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6006
	_fdS = open(slaveName, O_RDWR);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6007
	if (_fdS < 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6008
	    (void)close(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6009
	    _fdS = _fdM = -1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6010
	}
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6011
    } else {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6012
	_fdM -1;
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6013
    }
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6014
    if ((_fdM >= 0) && (_fdS >= 0)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6015
	 fdM = __mkSmallInteger(_fdM);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6016
	 fdS = __mkSmallInteger(_fdS);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6017
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6018
#   define PTY_IS_IMPLEMENTED 1
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6019
#endif /* IRIX5 */
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6020
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6021
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6022
#if defined(HAS_UNIX98_PTY)
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6023
    int _fdM, _fdS;
7001
212dce94d177 SYSV4 pseudoTTYs
penk
parents: 6993
diff changeset
  6024
    char *slaveName;
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6025
    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
  6026
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6027
    _fdM = open("/dev/ptmx", O_RDWR | O_NOCTTY);
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6028
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6029
    if (_fdM >= 0) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6030
	/*
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6031
	** grantpt() changes owner, group and mode of the pseudo-tty
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6032
	*/
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6033
	grantpt(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6034
	unlockpt(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6035
	slaveName = ptsname(_fdM);
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
	if (slaveName != NULL) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6038
	    /* printf("slave is: %s\n", slaveName); */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6039
	    _fdS = open(slaveName, O_RDWR);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6040
	    if (_fdS < 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6041
		(void)close(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6042
		_fdS = _fdM = -1;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6043
	    }
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6044
#if defined(UNIXWARE) || defined(solaris)
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6045
	    else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6046
		/* push terminal modules on stream */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6047
		ioctl(_fdS, I_PUSH, "ptem");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6048
		ioctl(_fdS, I_PUSH, "ldterm");
7736
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
#endif
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6051
	} else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6052
	    (void)close(_fdM);
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6053
	    _fdS = _fdM = -1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6054
	}
6987
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6055
    }
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6056
10a0dd0ac8c9 makeTTYPait for unixWare
penk
parents: 6960
diff changeset
  6057
    if ((_fdM >= 0) && (_fdS >= 0)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6058
	 fdM = __mkSmallInteger(_fdM);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6059
	 fdS = __mkSmallInteger(_fdS);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6060
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6061
#   define PTY_IS_IMPLEMENTED 1
7735
9e0da6630d80 HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7733
diff changeset
  6062
#endif /* HAS_UNIX98_PTY */
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6063
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6064
#if !defined(PTY_IS_IMPLEMENTED)
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6065
# ifdef LINUX
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6066
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6067
#   define PT_INDEX      5
3550
6c3824d07eac *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3549
diff changeset
  6068
#   define PTY_1_CHARS  "pqrstuabcdevwxyz"
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6069
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6070
# endif /* LINUX */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6071
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6072
# ifdef solaris
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6073
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6074
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6075
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6076
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6077
# endif /* solaris */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6078
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6079
# ifdef aix
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6080
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6081
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6082
#   define PTY_1_CHARS  "pqr"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6083
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6084
# endif /* aix */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6085
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6086
# ifdef next3
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6087
#   define PTY_TEMPL    "/dev/ptyXX"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6088
#   define PT_INDEX      5
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6089
#   define PTY_1_CHARS  "pqr"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6090
#   define PTY_2_CHARS  "0123456789abcdef"
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6091
# endif /* next3 */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6092
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6093
# ifdef hpux
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6094
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6095
#   define PT_INDEX      5
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6096
#   define PTY_1_CHARS  "pqrs"
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6097
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6098
# endif /* hpux */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6099
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6100
# if defined(__osf__)
4262
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6101
#   define PTY_TEMPL    "/dev/ptyXX"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6102
#   define PT_INDEX      5
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6103
#   define PTY_1_CHARS  "pq"
95ab0ee1a0d8 pty code for osf1
Claus Gittinger <cg@exept.de>
parents: 4259
diff changeset
  6104
#   define PTY_2_CHARS  "0123456789abcdef"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6105
# endif /* osf1 */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6106
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6107
# if defined(BSD) && !defined(PTY_TEMPL)
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6108
#   define PTY_TEMPL    "/dev/ptyXX"
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6109
#   define PT_INDEX      5
3539
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6110
#   define PTY_1_CHARS  "p"
1655aae9d622 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3538
diff changeset
  6111
#   define PTY_2_CHARS  "0123456789abcdefghijklmnopqrstuv"
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6112
# endif /* BSD */
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6113
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6114
3542
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6115
#   include <grp.h>
b6e8232516c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3541
diff changeset
  6116
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6117
    static int ttygid = -2;
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  6118
    char line[128];
3575
39723f691a0e hp-cc does not recognize const keyword
Claus Gittinger <cg@exept.de>
parents: 3571
diff changeset
  6119
    register CONST char *cp1, *cp2;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6120
    int len, _fdM = -1, _fdS = -1;
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6121
3981
c2582f877635 renamed __new() to __STX___new()
Claus Gittinger <cg@exept.de>
parents: 3970
diff changeset
  6122
    len = sizeof(PTY_TEMPL) - 1;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6123
    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
  6124
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6125
    if (ttygid == -2) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6126
	struct group *gr;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6127
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6128
	if ((gr = getgrnam("tty")) != NULL)
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6129
	    ttygid = gr->gr_gid;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6130
	else
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6131
	    ttygid = -1;
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6132
    }
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6133
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6134
    for (cp1 = PTY_1_CHARS; *cp1; cp1++) {
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6135
	line[len-2] = * cp1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6136
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6137
	for( cp2 = PTY_2_CHARS; *cp2; cp2++ ) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6138
	    line[PT_INDEX] = 'p';
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6139
	    line[len-1] = *cp2;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6140
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6141
	    if ((_fdM = open(line, O_RDWR, 0)) < 0) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6142
		if (errno == ENOENT) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6143
		    _fdM = _fdS = -1;
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6144
		    goto getOutOfHere; /* out of ptys */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6145
		}
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6146
	    } else {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6147
		line[PT_INDEX] = 't';
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6148
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6149
		/*
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6150
		 * try to set owner and mode.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6151
		 * this works only if running under root
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6152
		 */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6153
		(void) chown( line, getuid(), ttygid );
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6154
		(void) chmod( line, S_IRUSR | S_IWUSR | S_IWGRP );
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6155
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6156
		if( (_fdS = open(line, O_RDWR, 0)) >= 0 ) {
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6157
		    goto getOutOfHere; /* success */
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6158
		}
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6159
		(void) close(_fdM );
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6160
	    }
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6161
	}
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6162
    }
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6163
  getOutOfHere: ;
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6164
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6165
    if ((_fdM >= 0) && (_fdS >= 0)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6166
	 fdM = __mkSmallInteger(_fdM);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6167
	 fdS = __mkSmallInteger(_fdS);
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6168
    }
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6169
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  6170
#endif /* ! defined(PTY_IS_IMPLEMENTED) */
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6171
%}.
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6172
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6173
    fdM notNil ifTrue:[
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  6174
	^ Array with:fdM with:fdS.
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6175
    ].
3538
fcedde036bc3 added makePTYPair for others
Claus Gittinger <cg@exept.de>
parents: 3536
diff changeset
  6176
3534
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6177
    ^ nil
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6178
!
126b23939933 added makePTYPair (IRIX only - for now)
Claus Gittinger <cg@exept.de>
parents: 3518
diff changeset
  6179
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6180
makePipe
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6181
    "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
  6182
     nil on failure.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6183
     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
  6184
     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
  6185
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6186
    |fd1 fd2|
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6187
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6188
%{
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6189
     int fds[2];
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6190
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6191
     if (pipe(fds) < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6192
	@global(LastErrorNumber) = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6193
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6194
     }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6195
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6196
     fd1 = __mkSmallInteger(fds[0]);
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6197
     fd2 = __mkSmallInteger(fds[1]);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6198
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6199
    fd1 notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6200
	^ Array with:fd1 with:fd2.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6201
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6202
    ^ nil
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6203
!
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6204
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6205
resetTerminalInputOutputModes:fd
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6206
    "reset the terminal attributes"
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6207
%{
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6208
    struct termios switcher;
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6209
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6210
    printf("setMappingMaster fd:%d\n", __intVal(fd));
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6211
    if (__isSmallInteger(fd)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6212
	if (tcgetattr( __intVal(fd), &switcher) < 0) RETURN (false);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6213
	switcher.c_iflag = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6214
	switcher.c_oflag = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6215
	if (tcsetattr( __intVal(fd), TCSANOW, &switcher) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6216
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6217
	}
6760
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6218
    }
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6219
%}.
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6220
    ^ false
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6221
!
e62624827ffe add method for terminal settings
penk
parents: 6617
diff changeset
  6222
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6223
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
  6224
    "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
  6225
%{
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6226
#ifdef TIOCSWINSZ
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6227
    struct winsize wsize;
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6228
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6229
    if (__isSmallInteger(fd)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6230
     && __isSmallInteger(w)
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6231
     && __isSmallInteger(h)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6232
	wsize.ws_row = (unsigned short)__intVal(h);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6233
	wsize.ws_col = (unsigned short)__intVal(w);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6234
	if (ioctl(__intVal(fd), TIOCSWINSZ, (char *)&wsize) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6235
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6236
	}
3556
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6237
    }
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6238
#endif
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6239
%}.
03e4132de6da added ioctl to change a pseudo-terminals window size
Claus Gittinger <cg@exept.de>
parents: 3555
diff changeset
  6240
    ^ false
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6241
!
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6242
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6243
shutdownBidirectionalPipeOutput:fileDescriptor
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6244
    "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
  6245
     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
  6246
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6247
%{
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6248
#ifndef NO_SOCKET
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6249
    if (__isSmallInteger(fileDescriptor)) {
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  6250
	shutdown(__smallIntegerVal(fileDescriptor), 1);
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  6251
	RETURN(self);
8968
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6252
    }
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6253
#endif
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6254
%}.
879991b52630 Support for bidirectional PipeStreams
Stefan Vogel <sv@exept.de>
parents: 8934
diff changeset
  6255
    self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6256
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6257
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6258
!UnixOperatingSystem class methodsFor:'misc'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6259
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6260
closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6261
    "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
  6262
     getAddrInfo implementation:
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6263
	if it gets interrupted (via a timer, for example), its domain-name
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6264
	socket remains open and is NEVER closed.
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6265
	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
  6266
     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
  6267
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6268
    |p|
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6269
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6270
    p := PipeStream
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6271
	    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
  6272
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6273
    p linesDo:[:line |
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6274
	|words fd|
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6275
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6276
	words := line asCollectionOfWords.
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6277
	"/ COMMAND PID USER   FD   TYPE     DEVICE    SIZE    NODE NAME
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6278
	words first = 'stx' ifTrue:[
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6279
	    words second = (OperatingSystem getProcessId printString) ifTrue:[
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6280
		(words fourth endsWith:'u') ifTrue:[
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6281
		    (words fifth = 'IPv4') ifTrue:[
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6282
			(words seventh = 'UDP') ifTrue:[
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6283
			    (words last endsWith:'domain') ifTrue:[
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6284
				fd := Number readFrom:(words fourth copyWithoutLast:1).
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6285
Transcript showCR:line.
8762
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6286
				OperatingSystem closeFd:fd.
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6287
			    ]
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6288
			]
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6289
		    ]
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6290
		]
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6291
	    ]
2fe7d8c44ccf Must refetch pointers into ST objects when doing interruptable
Claus Gittinger <cg@exept.de>
parents: 8735
diff changeset
  6292
	]
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6293
    ].
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6294
    p close.
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6295
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6296
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6297
     self closeLeftOverFiles
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6298
    "
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6299
!
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
  6300
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6301
closePid:pid
7133
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  6302
    "free pid resource.
fc8f147d884a comment
Claus Gittinger <cg@exept.de>
parents: 7119
diff changeset
  6303
     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
  6304
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6305
    ^ true.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6306
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6307
    "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
  6308
    "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
  6309
    "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
  6310
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6311
10983
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6312
dup:aFileDescriptor
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6313
    "duplicate a file descriptor.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6314
     Only use internally"
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6315
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6316
%{
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6317
    int dupFd;
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6318
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6319
    if (__isSmallInteger(aFileDescriptor)) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6320
	dupFd = dup(__smallIntegerVal(aFileDescriptor));
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6321
	if (dupFd >= 0) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6322
	    RETURN(__mkSmallInteger(dupFd));
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6323
	}
10983
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6324
    }
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6325
%}.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6326
    ^ self primitiveFailed.
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6327
!
d62606dafb37 New: #dup:
Stefan Vogel <sv@exept.de>
parents: 10955
diff changeset
  6328
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6329
slowFork:aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6330
    "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
  6331
     Only used internally on SYSV3 systems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6332
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6333
    SlowFork := aBoolean
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6334
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6335
    "Modified: 22.4.1996 / 13:13:09 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6336
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6337
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6338
!UnixOperatingSystem class methodsFor:'os queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6339
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6340
executableFileExtensions
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6341
    "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
  6342
     Only req'd for msdos like systems ..."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6343
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6344
    ^ #('')
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6345
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  6346
    "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
  6347
    "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
  6348
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6349
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6350
getDomainName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6351
    "return the domain this host is in.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6352
     Notice:
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6353
	not all systems support this; on some, 'unknown' is returned."
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6354
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6355
    |domainName idx hostName|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6356
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6357
    DomainName notNil ifTrue:[
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6358
	^ DomainName
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6359
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6360
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6361
    domainName := self primGetDomainName.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6362
    domainName isEmptyOrNil ifTrue:[
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6363
	"sometimes, we can extract the domainName from the hostName ..."
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6364
	hostName := self primGetHostName.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6365
	hostName notNil ifTrue:[
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6366
	    idx := hostName indexOf:$..
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6367
	    idx ~~ 0 ifTrue:[
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6368
		domainName := hostName copyFrom:idx+1.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6369
	    ]
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6370
	].
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6371
	domainName isNil ifTrue:[
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6372
	    "/ fallBack
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6373
	    domainName := self getEnvironment:'DOMAIN'.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6374
	    domainName isNil ifTrue:[
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6375
		domainName := self getCommandOutputFrom:'/bin/domainname'
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6376
	    ].
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6377
	    domainName isNil ifTrue:[
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6378
		'UnixOperatingSystem [warning]: cannot find out domainname' errorPrintCR.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6379
		domainName := 'unknown'.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6380
	    ].
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6381
	    "cache only, if domain name fetching is expensive"
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6382
	    DomainName := domainName.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6383
	].
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6384
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6385
    ^ domainName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6386
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6387
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6388
     OperatingSystem getDomainName
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6389
     OperatingSystem getHostName
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  6390
     OperatingSystem primGetHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6391
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6392
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6393
    "Modified: 26.4.1996 / 10:04:54 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6394
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6395
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6396
getEnvironment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6397
    "answer the whole environment as a Dictionary"
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6398
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6399
    |resultArray error dict sz "{ Class: SmallInteger }"|
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6400
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6401
%{
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6402
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6403
    extern char **environ;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6404
    char **env;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6405
    int nEnv = 0;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6406
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6407
    /*
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6408
     * get the size of the environment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6409
     */
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6410
    if (environ) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6411
	for (env = environ; *env; env++) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6412
	    nEnv++;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6413
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6414
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6415
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6416
    /*
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6417
     * allcate an array for keys and values
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6418
     */
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  6419
    resultArray = __ARRAY_NEW_INT(nEnv * 2);
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6420
    if (resultArray == nil) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6421
	error = @symbol(allocationFailure);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6422
	goto bad;
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6423
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6424
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6425
    if (environ) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6426
	int envIndex;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6427
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6428
	for (env = environ, envIndex = 0; *env; env++) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6429
	    OBJ t;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6430
	    char *separatorPtr;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6431
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6432
	    separatorPtr = strchr(*env, '=');
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6433
	    t = __MKSTRING_L(*env, separatorPtr-*env);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6434
	    __arrayVal(resultArray)[envIndex++] = t;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6435
	    __STORE(resultArray, t);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6436
	    if (separatorPtr == 0) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6437
		t = nil;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6438
	    } else {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6439
		t = __MKSTRING(separatorPtr+1);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6440
	    }
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6441
	    __arrayVal(resultArray)[envIndex++] = t;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6442
	    __STORE(resultArray, t);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6443
	}
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6444
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6445
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6446
bad:;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6447
%}.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6448
    error notNil ifTrue:[
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6449
	^ self primitiveFailed:error.
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6450
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6451
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6452
    sz := resultArray size.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6453
    dict := Dictionary new:(sz // 2).
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6454
    1 to:sz by:2 do:[:i |
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6455
	|key|
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6456
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6457
	key := resultArray at:i.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6458
	"same behavior as getenv() - the first entry takes precedence"
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6459
	(dict includesKey:key) ifFalse:[
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6460
	    dict at:key put:(resultArray at:i+1)
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6461
	].
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6462
    ].
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6463
    ^ dict
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6464
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6465
    "
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6466
     OperatingSystem getEnvironment
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6467
    "
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6468
!
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6469
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6470
getEnvironment:aStringOrSymbol
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6471
    "get an environment string"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6472
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6473
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6474
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6475
    char *env;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6476
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6477
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  6478
    if (__isStringLike(aStringOrSymbol)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6479
	env =  getenv(__stringVal(aStringOrSymbol));
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6480
	if (env) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6481
	    RETURN ( __MKSTRING(env) );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6482
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6483
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6484
    }
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6485
%}.
5407
d6729266a95b *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
  6486
    ^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6487
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6488
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6489
     OperatingSystem getEnvironment:'LANG'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6490
     OperatingSystem getEnvironment:'LOGIN'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6491
     OperatingSystem getEnvironment:'HOME'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6492
     OperatingSystem getEnvironment:'NNTPSERVER'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6493
     OperatingSystem getEnvironment:'MAIL'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6494
     OperatingSystem getEnvironment:'PATH'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6495
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6496
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6497
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6498
getHostName
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6499
    "return the hostname we are running on.
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6500
     The host name returned is fully qualified - if returned so by the system."
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6501
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6502
    |hostName|
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
    HostName notNil ifTrue:[
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6505
        ^ HostName
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6506
    ].
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6507
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6508
    hostName := self primGetHostName.
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6509
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6510
    hostName isNil ifTrue:[
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6511
        "fallBack - in non-antique systes we never come here"
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6512
        hostName := self getEnvironment:'HOST'.
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6513
        hostName isNil ifTrue:[
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6514
            hostName := self getCommandOutputFrom:'/bin/hostname'
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6515
        ].
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6516
        hostName isNil ifTrue:[
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6517
            'UnixOperatingSystem [warning]: cannot find out hostname' errorPrintCR.
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6518
            hostName := 'unknown'.
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6519
        ].
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6520
        "cache, only because hostname fetching was expensive, 
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6521
         otherwise we want to see a changed hostname"
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6522
        HostName := hostName.
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6523
    ].
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  6524
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  6525
    ^ hostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6526
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6527
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6528
     OperatingSystem getHostName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6529
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6530
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6531
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6532
getLocaleInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6533
    "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
  6534
     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
  6535
     Possible fields are:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6536
	decimalPoint                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6537
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6538
	thousandsSep                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6539
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6540
	internationalCurrencySymbol     <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6541
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6542
	currencySymbol                  <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6543
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6544
	monetaryDecimalPoint            <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6545
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6546
	monetaryThousandsSeparator      <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6547
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6548
	positiveSign                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6549
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6550
	negativeSign                    <String>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6551
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6552
	internationalFractionalDigits   <Integer>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6553
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6554
	fractionalDigits                <Integer>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6555
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6556
	positiveSignPrecedesCurrencySymbol      <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6557
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6558
	negativeSignPrecedesCurrencySymbol      <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6559
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6560
	positiveSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6561
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6562
	negativeSignSeparatedBySpaceFromCurrencySymbol  <Boolean>
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6563
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6564
	positiveSignPosition                            <Symbol>
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6565
							one of: #parenthesesAround,
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6566
								#signPrecedes,
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6567
								#signSuceeds,
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6568
								#signPrecedesCurrencySymbol,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6569
								#signSuceedsCurrencySymbol
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6570
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6571
	negativeSignPosition                            <like above>
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6572
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6573
     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
  6574
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6575
     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
  6576
     it should be used by applications as required.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6577
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6578
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6579
    |info val|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6580
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6581
    LocaleInfo notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6582
	"/ return the internal info; useful on systems which do not
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6583
	"/ support this.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6584
	^ LocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6585
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6586
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6587
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6588
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6589
    char *decimalPoint;         /* something like "." (US) or "," (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6590
    char *thousandsSep;         /* something like "," (US) or "." (german) */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6591
    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
  6592
    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
  6593
    char *monDecimalPoint;      /* money: decimal point */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6594
    char *monThousandsSep;      /* money: thousands sep */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6595
    char *positiveSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6596
    char *negativeSign;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6597
    int   intFractDigits;       /* money: international digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6598
    int   fractDigits;          /* money: local digits after decPoint */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6599
    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
  6600
    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
  6601
    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
  6602
    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
  6603
    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
  6604
    int   csNegSignPosition;    /*        1: sign precedes the value & currency symbol */
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6605
				/*        2: sign succeeds the value & currency symbol */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6606
				/*        3: sign immediately precedes the currency symbol */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6607
				/*        4: sign immediately suceeds the currency symbol */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6608
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6609
#if defined(HAS_LOCALECONV)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6610
    struct lconv *conf;
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
    conf = localeconv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6613
    if (conf) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6614
	decimalPoint = conf->decimal_point;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6615
	thousandsSep = conf->thousands_sep;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6616
	intCurrencySymbol = conf->int_curr_symbol;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6617
	currencySymbol = conf->currency_symbol;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6618
	monDecimalPoint = conf->mon_decimal_point;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6619
	monThousandsSep = conf->mon_thousands_sep;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6620
	positiveSign = conf->positive_sign;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6621
	negativeSign = conf->negative_sign;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6622
	intFractDigits = conf->int_frac_digits;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6623
	fractDigits = conf->frac_digits;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6624
	csPosPrecedes = conf->p_cs_precedes;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6625
	csNegPrecedes = conf->n_cs_precedes;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6626
	csPosSepBySpace = conf->p_sep_by_space;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6627
	csNegSepBySpace = conf->n_sep_by_space;
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6628
	csPosSignPosition = conf->p_sign_posn;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6629
	csNegSignPosition = conf->n_sign_posn;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6630
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6631
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6632
    decimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6633
    thousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6634
    intCurrencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6635
    currencySymbol = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6636
    monDecimalPoint = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6637
    monThousandsSep = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6638
    positiveSign =  (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6639
    negativeSign =(char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6640
    intFractDigits = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6641
    fractDigits = -1;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6642
    csPosPrecedes = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6643
    csNegPrecedes = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6644
    csPosSepBySpace = -1;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6645
    csNegSepBySpace = -1;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6646
    csPosSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6647
    csNegSignPosition = -1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6648
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6649
    if (decimalPoint) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6650
	val = __MKSTRING(decimalPoint);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6651
	__AT_PUT_(info, @symbol(decimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6652
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6653
    if (thousandsSep) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6654
	val = __MKSTRING(thousandsSep);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6655
	__AT_PUT_(info, @symbol(thousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6656
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6657
    if (intCurrencySymbol) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6658
	val = __MKSTRING(intCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6659
	__AT_PUT_(info, @symbol(internationCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6660
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6661
    if (currencySymbol) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6662
	val = __MKSTRING(currencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6663
	__AT_PUT_(info, @symbol(currencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6664
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6665
    if (monDecimalPoint) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6666
	val = __MKSTRING(monDecimalPoint);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6667
	__AT_PUT_(info, @symbol(monetaryDecimalPoint), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6668
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6669
    if (monThousandsSep) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6670
	val = __MKSTRING(monThousandsSep);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6671
	__AT_PUT_(info, @symbol(monetaryThousandsSeparator), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6672
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6673
    if (positiveSign) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6674
	val = __MKSTRING(positiveSign);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6675
	__AT_PUT_(info, @symbol(positiveSign), 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
    if (negativeSign) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6678
	val = __MKSTRING(negativeSign);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6679
	__AT_PUT_(info, @symbol(negativeSign), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6680
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6681
    if (intFractDigits >= 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6682
	__AT_PUT_(info, @symbol(internationalFractionalDigits),  __mkSmallInteger(intFractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6683
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6684
    if (fractDigits >= 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  6685
	__AT_PUT_(info, @symbol(fractionalDigits),  __mkSmallInteger(fractDigits));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6686
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6687
    if (csPosPrecedes >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6688
	if (csPosPrecedes == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6689
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6690
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6691
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6692
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6693
	__AT_PUT_(info, @symbol(positiveSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6694
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6695
    if (csNegPrecedes >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6696
	if (csNegPrecedes == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6697
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6698
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6699
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6700
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6701
	__AT_PUT_(info, @symbol(negativeSignPrecedesCurrencySymbol), val );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6702
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6703
    if (csPosSepBySpace >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6704
	if (csPosSepBySpace == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6705
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6706
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6707
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6708
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6709
	__AT_PUT_(info, @symbol(positiveSignSeparatedBySpaceFromCurrencySymbol), val);
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
    if (csNegSepBySpace >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6712
	if (csNegSepBySpace == 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6713
	    val = false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6714
	} else {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6715
	    val = true;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6716
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6717
	__AT_PUT_(info, @symbol(negativeSignSeparatedBySpaceFromCurrencySymbol), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6718
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6719
    switch (csPosSignPosition) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6720
	case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6721
	    val = @symbol(parenthesesAround);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6722
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6723
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6724
	case 1:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6725
	    val = @symbol(signPrecedes);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6726
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6727
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6728
	case 2:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6729
	    val = @symbol(signSuceeds);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6730
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6731
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6732
	case 3:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6733
	    val = @symbol(signPrecedesCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6734
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6735
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6736
	case 4:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6737
	    val = @symbol(signSuceedsCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6738
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6739
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6740
	default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6741
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6742
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6743
    if (val != nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6744
	__AT_PUT_(info, @symbol(positiveSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6745
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6746
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6747
    switch (csNegSignPosition) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6748
	case 0:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6749
	    val = @symbol(parenthesesAround);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6750
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6751
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6752
	case 1:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6753
	    val = @symbol(signPrecedes);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6754
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6755
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6756
	case 2:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6757
	    val = @symbol(signSuceeds);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6758
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6759
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6760
	case 3:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6761
	    val = @symbol(signPrecedesCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6762
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6763
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6764
	case 4:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6765
	    val = @symbol(signSuceedsCurrencySymbol);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6766
	    break;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6767
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6768
	default:
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6769
	    val = nil;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6770
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6771
    if (val != nil) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  6772
	__AT_PUT_(info, @symbol(negativeSignPosition), val);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6773
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6774
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6775
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6776
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6777
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  6778
     OperatingSystem getLocaleInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6779
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6780
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6781
    "Created: 23.12.1995 / 14:19:20 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6782
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6783
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6784
getNetworkAddresses
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6785
    "return a dictionary filled with
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6786
	key -> name of interface
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6787
	value -> the socket adress of the interface
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6788
     for each interface"
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6789
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6790
    |addressArray nameArray noOfIf retDictionary error|
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6791
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6792
    noOfIf := 0.
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6793
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6794
%{
10787
6bce0b8c7e4d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10662
diff changeset
  6795
#if !defined(__osx__) && defined(SIOCGIFADDR) && defined(SIOCGIFCONF)
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6796
    int             afinet_socket = -1;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6797
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6798
    struct ifconf   ifc;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6799
    struct ifreq    *ifr;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6800
    struct ifreq    ifreq;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6801
    unsigned char   buf[1024];
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6802
    int             n_ifs, i, countOfIf;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6803
    OBJ             t;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6804
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6805
    /*
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6806
    ** Open an INET socket
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6807
    */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6808
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6809
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6810
    if (afinet_socket < 0) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6811
	error = __MKSTRING("Cannot open socket");
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6812
	goto bad;
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6813
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6814
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6815
    /*
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6816
    ** Get the list of network interfaces
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6817
    */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6818
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6819
    ifc.ifc_len = sizeof (buf);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6820
    ifc.ifc_buf = (caddr_t) buf;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6821
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6822
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6823
	close(afinet_socket);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6824
	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6825
	goto bad;
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6826
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6827
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6828
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6829
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  6830
    nameArray    = __ARRAY_NEW_INT(n_ifs);
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  6831
    addressArray = __ARRAY_NEW_INT(n_ifs);
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6832
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6833
    if (nameArray == nil || addressArray == nil) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6834
	/* Creating a string wouldn/t work here */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6835
	error = @symbol(allocationFailure);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6836
	goto bad;
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6837
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6838
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6839
    /*
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6840
    ** Iterate of the list of the system's netif. Find all
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6841
    ** active interfaces and their ethernet addresses
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6842
    */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6843
    countOfIf = 0;
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6844
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6845
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6846
	/*
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6847
	** Get Flags for this interface
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6848
	*/
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6849
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6850
	memcpy(&ifreq, ifr, sizeof(ifreq));
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6851
	/*
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6852
	** Get address for this interface
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6853
	*/
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6854
	memcpy(&ifreq, ifr, sizeof(ifreq));
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6855
	if (ioctl (afinet_socket, SIOCGIFADDR, &ifreq) >= 0) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6856
	    t = __MKBYTEARRAY((char *)&ifreq.ifr_addr, sizeof(ifreq.ifr_addr));
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6857
	    __arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6858
	    t = __MKSTRING(&ifreq.ifr_name);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6859
	    __arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6860
	    countOfIf += 1;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6861
	}
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6862
    }
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6863
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6864
    noOfIf = __mkSmallInteger(countOfIf);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6865
bad:
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6866
    if (afinet_socket >= 0)
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6867
	close(afinet_socket);
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6868
#else
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6869
    error = @symbol(notSupported);
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6870
#endif /* defined(SIOCGIFADDR) */
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6871
%}.
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6872
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6873
    retDictionary := Dictionary new:noOfIf.
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6874
    error notNil ifTrue:[
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6875
	self primitiveFailed:error.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6876
	"return empty dictionary if proceed from error"
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6877
	^  retDictionary.
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6878
    ].
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6879
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6880
    1 to:noOfIf do:[:cnt|
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6881
	retDictionary at:(nameArray at:cnt) put:(SocketAddress fromBytes:(addressArray at:cnt)).
8997
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6882
    ].
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6883
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6884
    ^ retDictionary
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6885
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6886
    "
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6887
      OperatingSystem getNetworkAddresses
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6888
    "
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6889
!
e6f0f9b71488 new: #getNetworkAddresses
Stefan Vogel <sv@exept.de>
parents: 8968
diff changeset
  6890
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6891
getNetworkMACAddresses
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6892
    "return a dictionary filled with
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6893
	key -> name of interface
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6894
	value -> the MAC adress (as ByteArray)
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6895
     for each interface"
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6896
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6897
    |addressArray nameArray noOfIf retDictionary error|
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6898
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6899
    noOfIf := 0.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6900
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6901
%{
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6902
#ifdef SIOCGIFHWADDR
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6903
    int             afinet_socket = -1;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6904
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6905
    struct ifconf   ifc;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6906
    struct ifreq    *ifr;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6907
    struct ifreq    ifreq;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6908
    unsigned char   buf[1024];
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6909
    int             n_ifs, i, countOfIf;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6910
    OBJ             t;
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6911
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6912
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6913
    ** Open an INET socket
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6914
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6915
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6916
    afinet_socket = socket(AF_INET, SOCK_DGRAM, 0);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6917
    if (afinet_socket < 0) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6918
	error = __MKSTRING("Cannot open socket");
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6919
	goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6920
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6921
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6922
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6923
    ** Get the list of network interfaces
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6924
    */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6925
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6926
    ifc.ifc_len = sizeof (buf);
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6927
    ifc.ifc_buf = (caddr_t) buf;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6928
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6929
    if (ioctl (afinet_socket, SIOCGIFCONF, (caddr_t) &ifc) < 0) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6930
	close(afinet_socket);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6931
	error = __MKSTRING("ioctl(SIOCGIFCONF) failed");
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6932
	goto bad;
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6933
    }
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6934
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6935
    n_ifs = ifc.ifc_len / sizeof (struct ifreq);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6936
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  6937
    nameArray    = __ARRAY_NEW_INT(n_ifs);
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  6938
    addressArray = __ARRAY_NEW_INT(n_ifs);
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6939
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6940
    if (nameArray == nil || addressArray == nil) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6941
	/* Creating a string wouldn/t work here */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6942
	error = @symbol(allocationFailure);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6943
	goto bad;
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6944
    }
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6945
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6946
    /*
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6947
    ** Iterate of the list of the system's netif. Find all
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6948
    ** active interfaces and their ethernet addresses
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6949
    */
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6950
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6951
    countOfIf = 0;
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6952
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6953
    for (i=0, ifr = ifc.ifc_req; i < n_ifs; i++, ifr++) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6954
	/*
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6955
	** Get Flags for this interface
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6956
	*/
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6957
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6958
	memcpy(&ifreq, ifr, sizeof(ifreq));
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6959
	if (ioctl (afinet_socket, SIOCGIFFLAGS, &ifreq) < 0) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6960
	    if (@global(InfoPrinting) == true) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6961
		fprintf(stderr, "OS [warning]: ioctl(SIOCGIFFLAGS) failed");
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6962
	    }
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6963
	} else {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6964
	    /*
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6965
	    ** Get Hardware address for this interface
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6966
	    */
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6967
	    memcpy(&ifreq, ifr, sizeof(ifreq));
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6968
	    if (ioctl (afinet_socket, SIOCGIFHWADDR, &ifreq) >= 0) {
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6969
		t = __MKBYTEARRAY(&ifreq.ifr_hwaddr.sa_data, IFHWADDRLEN);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6970
		__arrayVal(addressArray)[countOfIf] = t; __STORE(addressArray, t);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6971
		t = __MKSTRING(&ifreq.ifr_name);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6972
		__arrayVal(nameArray)[countOfIf] = t; __STORE(nameArray, t);
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6973
		countOfIf += 1;
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6974
	    }
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6975
	}
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6976
    }
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6977
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6978
    noOfIf = __mkSmallInteger(countOfIf);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  6979
bad:
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6980
    if (afinet_socket >= 0)
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6981
	close(afinet_socket);
7524
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6982
#else
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6983
    error = @symbol(notSupported);
cf39046ef6f8 MAC-Address fetching
Stefan Vogel <sv@exept.de>
parents: 7515
diff changeset
  6984
#endif /* SIOCGIFHWADDR */
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6985
%}.
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6986
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6987
    retDictionary := Dictionary new:noOfIf.
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6988
    error notNil ifTrue:[
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6989
	self primitiveFailed:error.
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6990
	"return empty dictionary if proceed from error"
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6991
	^  retDictionary.
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6992
    ].
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6993
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6994
    1 to:noOfIf do:[:cnt|
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  6995
	retDictionary at:(nameArray at:cnt) put:(addressArray at:cnt).
6362
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6996
    ].
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6997
de25331c7d80 add MAC adress access
penk
parents: 6357
diff changeset
  6998
    ^ retDictionary
7289
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  6999
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7000
    "
ae352d72ec31 Spelling (#getNetworkMACAddresses).
Stefan Vogel <sv@exept.de>
parents: 7259
diff changeset
  7001
      OperatingSystem getNetworkMACAddresses
6542
ecfe70e462fe *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6536
diff changeset
  7002
    "
6363
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  7003
!
4232bede2400 add MAC adress access
penk
parents: 6362
diff changeset
  7004
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7005
getNumberOfProcessors
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7006
    "answer the number of physical processors in the system"
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7007
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7008
%{ /* NOCONTEXT */
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7009
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7010
#ifdef _SC_NPROCESSORS_CONF
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7011
    RETURN(__mkSmallInteger(sysconf(_SC_NPROCESSORS_CONF)));
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7012
#endif
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7013
%}.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7014
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7015
    self shouldImplement.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7016
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7017
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7018
      self getNumberOfProcessors
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7019
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7020
!
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7021
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7022
getProcessId
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7023
    "return the (unix-)processId"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7024
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7025
%{  /* NOCONTEXT */
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7026
    RETURN ( __mkSmallInteger(getpid()) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7027
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7028
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7029
     OperatingSystem getProcessId
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7030
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7031
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7032
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7033
getSystemID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7034
    "if supported by the OS, return the systemID;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7035
     a unique per machine identification.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7036
     WARNING:
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7037
        not all systems support this; on some, 'unknown' is returned."
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7038
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7039
%{  /* NOCONTEXT */
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7040
#if defined(HAS_SYSINFO) && defined(SI_HW_SERIAL)
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7041
    {
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7042
        char buffer[128];
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7043
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7044
        buffer[0] = 0;
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7045
        if (sysinfo(SI_HW_SERIAL, buffer, sizeof(buffer))) {
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7046
            buffer[127] = 0;
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7047
            if (strlen(buffer) > 0) {
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7048
                RETURN(__MKSTRING(buffer));
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7049
            }
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7050
        }
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7051
    }
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7052
#elif defined(HAS_GETHOSTID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7053
    int runningId;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7054
    OBJ arr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7055
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7056
    runningId = gethostid();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7057
    arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(4);
6495
a8d7ed8fae59 use arrayVal & byteArrayVal macros
Claus Gittinger <cg@exept.de>
parents: 6465
diff changeset
  7058
    *(int *)(__byteArrayVal(arr)) = runningId;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7059
    RETURN (arr);
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7060
#elif defined(IRIX5)
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7061
    char idBuffer[MAXSYSIDSIZE];
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7062
    int retVal;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7063
    OBJ arr;
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7064
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7065
    if ((retVal = syssgi(SGI_SYSID, idBuffer)) == 0) {
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7066
        arr = __BYTEARRAY_UNINITIALIZED_NEW_INT(MAXSYSIDSIZE);
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7067
        bcopy(idBuffer, __byteArrayVal(arr), MAXSYSIDSIZE);
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  7068
        RETURN (arr);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7069
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7070
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7071
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7072
    ^ 'unknown'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7073
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7074
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7075
     OperatingSystem getSystemID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7076
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7077
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7078
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7079
getSystemInfo
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7080
    "return info on the system weare running on.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7081
     If the system supports the uname system call, that info is returned;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7082
     otherwise, some simulated info is returned.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7083
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7084
     WARNING:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7085
       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
  7086
       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
  7087
       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
  7088
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7089
       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
  7090
       information.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7091
       (in case of system/version specific OS errors, conditional workarounds and patches
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7092
        may be based upon this info).
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7093
       Also, applications could enable/disable buffering or otherwise reduce
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7094
       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
  7095
       Your application may make use of available information for tuning,
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7096
       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
  7097
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7098
     The returned info may (or may not) contain:
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7099
        #system -> some operating system identification (irix, Linux, nt, win32s ...)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7100
        #version -> OS version (some os version identification)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7101
        #release -> OS release (3.5, 1.2.1 ...)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7102
        #node   -> some host identification (hostname)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7103
        #domain  -> domain name (hosts domain)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7104
        #machine -> type of CPU (i586, mips ...)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7105
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7106
     those are currently returned on some machines (no warranty)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7107
     linux:
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7108
        #totalRam         -> total amount of memory available
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7109
        #sharedRam        -> amount of memory which is shared among processes
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7110
                             (i.e. shared code)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7111
        #bufferRam        -> amount used for buffers
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7112
        #swapSize         -> total size of swap space
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7113
        #freeSwap         -> free amount in swapSpace
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7114
        #numberOfCPUs     -> number of cpus in box
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7115
        #extendedInstructions -> extended instruction set info
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7116
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7117
     osf:
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7118
        #physicalRam      -> total amount of physical memory
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7119
        #cpuType          -> type of cpu (more detailed than machine)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7120
        #numberOfCPUs     -> number of cpus in box
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7121
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7122
     solaris:
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7123
        #physicalRam      -> total amount of physical memory
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7124
        #availableRam     -> total available amount of physical memory (i.e. unused ram)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7125
        #freeRam          -> amount of free memory
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7126
        #numberOfCPUs     -> number of cpus in box (online CPUS)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7127
        [#dCacheSize]     -> bytes in data cache (only available on some solaris versions)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7128
        [#iCacheSize]     -> bytes in data cache (only available on some solaris versions)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7129
        [#instructionSets]-> instruction sets available (only available on some solaris versions)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7130
        [#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
  7131
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7132
     hpux:
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7133
        #physicalRam      -> total amount of physical memory in box
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7134
        #activeRealMemory -> ? - read pstat documentation
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7135
        #activeVirtualRam -> ? - read pstat documentation
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7136
        #freeMemory       -> ? - read pstat documentation
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7137
        #realMemory       -> ? (amount of memory left to user programs)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7138
        #virtualRam       -> ? - read pstat documentation
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7139
    "
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7140
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7141
    |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
  7142
     physicalRam availableRam totalRam sharedRam bufferRam swapSize freeSwap
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7143
     numberOfCPUs numberOfPhysicalCPUs pageSize physicalPages availablePages dCacheSize iCacheSize
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7144
     virtualRam activeVirtualRam realMemory activeRealMemory freeMemory
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7145
     instructionSets extendedInstructions platform|
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7146
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7147
%{  /* STACK: 4096 */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7148
#ifdef LINUX
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  7149
# 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
  7150
    /*
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7151
     * additional info available ...
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7152
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7153
    struct sysinfo infoBuffer;
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7154
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7155
    if (sysinfo(&infoBuffer) >= 0) {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7156
        totalRam   = __MKUINT(infoBuffer.totalram);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7157
        sharedRam = __MKUINT(infoBuffer.sharedram);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7158
        bufferRam = __MKUINT(infoBuffer.bufferram);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7159
        swapSize  = __MKUINT(infoBuffer.totalswap);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7160
        freeSwap  = __MKUINT(infoBuffer.freeswap);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7161
    }
3696
a0c77f9bdbc7 oops - a.out linux has no sysinfo
Claus Gittinger <cg@exept.de>
parents: 3692
diff changeset
  7162
# endif
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7163
#endif /* LINUX */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7164
4088
622551d3c0d7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4084
diff changeset
  7165
#if defined(hpux) && !defined(__GNUC__)
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7166
# include <sys/pstat.h>
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7167
    struct pst_static stat_buf;
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7168
    struct pst_dynamic dynam_buf;
11285
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7169
    union pstun pstun_static;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7170
    union pstun pstun_dynamic;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7171
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7172
    pstun_static.pst_static = &stat_buf;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7173
    pstun_dynamic.pst_dynamic = &dynam_buf;
277953410c59 hp64 changes
Stefan Vogel <sv@exept.de>
parents: 11046
diff changeset
  7174
    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
  7175
    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
  7176
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7177
    physicalRam        = __MKUINT(stat_buf.physical_memory/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7178
    virtualRam         = __MKUINT(dynam_buf.psd_vm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7179
    activeVirtualRam   = __MKUINT(dynam_buf.psd_avm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7180
    realMemory         = __MKUINT(dynam_buf.psd_rm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7181
    activeRealMemory   = __MKUINT(dynam_buf.psd_arm/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7182
    freeMemory         = __MKUINT(dynam_buf.psd_free/256*1024*1024);
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7183
#endif
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7184
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7185
#if defined(HAS_UNAME)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7186
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7187
        struct utsname ubuff;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7188
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7189
        if (uname(&ubuff) >= 0) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7190
            sys  = __MKSTRING(ubuff.sysname);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7191
            node = __MKSTRING(ubuff.nodename);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7192
            rel  = __MKSTRING(ubuff.release);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7193
            ver  = __MKSTRING(ubuff.version);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7194
            mach = __MKSTRING(ubuff.machine);
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7195
# if defined(HAS_UTS_DOMAINNAME) || defined(_GNU_SOURCE)
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7196
            dom  = __MKSTRING(ubuff.domainname);
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7197
# endif /* no HAS_UTS_DOMAINNAME */
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7198
        }
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7199
    }
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7200
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7201
#else /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7202
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7203
    /*
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7204
     * use fallBack code below
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7205
     */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7206
#endif /* no UNAME */
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7207
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7208
#if defined(HAS_SYSINFO)
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7209
# if defined(SI_ARCHITECTURE)
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7210
    if (arch == nil) {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7211
        char buffer[128];
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7212
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7213
        if (sysinfo(SI_ARCHITECTURE, buffer, sizeof(buffer))) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7214
            arch = __MKSTRING(buffer);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7215
        }
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7216
    }
4923
1cacdcfc82c9 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4922
diff changeset
  7217
# endif /* SI_ARCHITECTURE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7218
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7219
# if defined(SI_ISALIST)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7220
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7221
        char buffer[128];
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7222
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7223
        if (sysinfo(SI_ISALIST, buffer, sizeof(buffer))) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7224
            instructionSets = __MKSTRING(buffer);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7225
        }
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7226
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7227
# endif /* SI_ISALIST */
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7228
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7229
# if defined(SI_PLATFORM)
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7230
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7231
        char buffer[128];
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7232
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7233
        if (sysinfo(SI_PLATFORM, buffer, sizeof(buffer))) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7234
            platform = __MKSTRING(buffer);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7235
        }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7236
    }
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7237
# endif /* SI_PLATFORM */
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7238
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7239
# if defined(SI_RELEASE)
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7240
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7241
        char buffer[128];
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7242
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7243
        if (sysinfo(SI_RELEASE, buffer, sizeof(buffer))) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7244
            rel = __MKSTRING(buffer);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7245
        }
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7246
    }
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  7247
# endif /* SI_RELEASE */
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7248
#endif /* HAS_SYSINFO */
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7249
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7250
#if defined(HAS_SYSCONF)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7251
# ifdef _SC_NPROCESSORS_ONLN
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7252
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7253
        long val;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7254
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7255
        val = sysconf(_SC_NPROCESSORS_ONLN);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7256
        if (val > 0) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7257
            numberOfCPUs = __MKINT(val);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7258
        }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7259
    }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7260
# endif
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7261
# ifdef _SC_NPROCESSORS_CONF
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7262
    {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7263
        long val;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7264
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7265
        val = sysconf(_SC_NPROCESSORS_CONF);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7266
        if (val > 0) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7267
            numberOfPhysicalCPUs = __MKINT(val);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7268
        }
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7269
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7270
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7271
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7272
# if defined(_SC_PAGESIZE)
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7273
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7274
        long val;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7275
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7276
        val = sysconf(_SC_PAGESIZE);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7277
        if (val != -1) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7278
            pageSize = __MKUINT(val);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7279
        }
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7280
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7281
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7282
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7283
# if defined(_SC_PHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7284
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7285
        long val;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7286
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7287
        val = sysconf(_SC_PHYS_PAGES);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7288
        if (val != -1) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7289
            physicalPages = __MKUINT(val);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7290
        }
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7291
    }
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7292
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7293
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7294
# if defined(_SC_AVPHYS_PAGES)
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7295
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7296
        long val;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7297
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7298
        val = sysconf(_SC_AVPHYS_PAGES);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7299
        if (val != -1) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7300
            availablePages = __MKUINT(val);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7301
        }
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7302
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7303
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7304
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7305
# if defined(_SC_ICACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7306
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7307
        long val;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7308
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7309
        val = sysconf(_SC_ICACHE_SZ);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7310
        if (val != -1) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7311
            iCacheSize = __MKUINT(val);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7312
        }
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7313
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7314
# endif
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7315
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7316
# if defined(_SC_DCACHE_SZ)
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7317
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7318
        long val;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7319
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7320
        val = sysconf(_SC_DCACHE_SZ);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7321
        if (val != -1) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7322
            dCacheSize = __MKUINT(val);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7323
        }
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7324
    }
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7325
# endif
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7326
#endif /* HAS_SYSCONF */
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7327
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7328
#if defined(HAS_GETSYSINFO)
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7329
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7330
        INT index;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7331
        int retInt32 = 0;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7332
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7333
# if defined(GSI_CPU)
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7334
        index = 0;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7335
        if (getsysinfo(GSI_CPU, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7336
            switch (retInt32) {
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7337
#  ifdef VAX_780
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7338
                case VAX_780:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7339
                    cpuType = __MKSTRING("VAX_780");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7340
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7341
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7342
#  ifdef VAX_750
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7343
                case VAX_750:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7344
                    cpuType = __MKSTRING("VAX_750");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7345
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7346
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7347
#  ifdef VAX_730
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7348
                case VAX_730:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7349
                    cpuType = __MKSTRING("VAX_730");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7350
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7351
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7352
#  ifdef VAX_8600
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7353
                case VAX_8600:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7354
                    cpuType = __MKSTRING("VAX_8600");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7355
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7356
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7357
#  ifdef VAX_8200
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7358
                case VAX_8200:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7359
                    cpuType = __MKSTRING("VAX_8200");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7360
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7361
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7362
#  ifdef VAX_8800
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7363
                case VAX_8800:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7364
                    cpuType = __MKSTRING("VAX_8800");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7365
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7366
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7367
#  ifdef MVAX_I
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7368
                case MVAX_I:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7369
                    cpuType = __MKSTRING("MVAX_I");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7370
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7371
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7372
#  ifdef MVAX_II
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7373
                case MVAX_II:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7374
                    cpuType = __MKSTRING("MVAX_II");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7375
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7376
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7377
#  ifdef V_VAX
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7378
                case V_VAX:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7379
                    cpuType = __MKSTRING("V_VAX");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7380
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7381
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7382
#  ifdef VAX_3600
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7383
                case VAX_3600:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7384
                    cpuType = __MKSTRING("VAX_3600");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7385
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7386
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7387
#  ifdef VAX_6200
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7388
                case VAX_6200:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7389
                    cpuType = __MKSTRING("VAX_6200");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7390
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7391
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7392
#  ifdef VAX_3400
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7393
                case VAX_3400:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7394
                    cpuType = __MKSTRING("VAX_3400");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7395
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7396
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7397
#  ifdef C_VAXSTAR
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7398
                case C_VAXSTAR:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7399
                    cpuType = __MKSTRING("C_VAXSTAR");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7400
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7401
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7402
#  ifdef VAX_60
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7403
                case VAX_60:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7404
                    cpuType = __MKSTRING("VAX_60");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7405
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7406
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7407
#  ifdef VAX_3900
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7408
                case VAX_3900:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7409
                    cpuType = __MKSTRING("VAX_3900");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7410
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7411
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7412
#  ifdef DS_3100
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7413
                case DS_3100:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7414
                    cpuType = __MKSTRING("DS_3100");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7415
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7416
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7417
#  ifdef VAX_8820
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7418
                case VAX_8820:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7419
                    cpuType = __MKSTRING("VAX_8820");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7420
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7421
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7422
#  ifdef DS_5400
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7423
                case DS_5400:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7424
                    cpuType = __MKSTRING("DS_5400");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7425
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7426
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7427
#  ifdef DS_5800
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7428
                case DS_5800:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7429
                    cpuType = __MKSTRING("DS_5800");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7430
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7431
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7432
#  ifdef DS_5000
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7433
                case DS_5000:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7434
                    cpuType = __MKSTRING("DS_5000");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7435
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7436
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7437
#  ifdef DS_CMAX
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7438
                case DS_CMAX:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7439
                    cpuType = __MKSTRING("DS_CMAX");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7440
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7441
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7442
#  ifdef VAX_6400
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7443
                case VAX_6400:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7444
                    cpuType = __MKSTRING("VAX_6400");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7445
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7446
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7447
#  ifdef VAXSTAR
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7448
                case VAXSTAR:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7449
                    cpuType = __MKSTRING("VAXSTAR");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7450
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7451
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7452
#  ifdef DS_5500
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7453
                case DS_5500:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7454
                    cpuType = __MKSTRING("DS_5500");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7455
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7456
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7457
#  ifdef DS_5100
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7458
                case DS_5100:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7459
                    cpuType = __MKSTRING("DS_5100");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7460
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7461
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7462
#  ifdef VAX_9000
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7463
                case VAX_9000:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7464
                    cpuType = __MKSTRING("VAX_9000");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7465
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7466
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7467
#  ifdef DS_500_100
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7468
                case DS_500_100:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7469
                    cpuType = __MKSTRING("DS_500_100");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7470
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7471
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7472
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7473
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7474
#  ifdef ALPHA_ADU
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7475
                case ALPHA_ADU:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7476
                    cpuType = __MKSTRING("ALPHA_ADU");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7477
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7478
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7479
#  ifdef DEC_4000
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7480
                case DEC_4000:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7481
                    cpuType = __MKSTRING("DEC_4000");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7482
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7483
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7484
#  ifdef DEC_3000_500
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7485
                case DEC_3000_500:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7486
                    cpuType = __MKSTRING("DEC_3000_500");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7487
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7488
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7489
#  ifdef DEC_7000
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7490
                case DEC_7000:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7491
                    cpuType = __MKSTRING("DEC_7000");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7492
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7493
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7494
#  ifdef DS_5000_300
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7495
                case DS_5000_300:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7496
                    cpuType = __MKSTRING("DS_5000_300");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7497
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7498
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7499
#  ifdef DEC_3000_300
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7500
                case DEC_3000_300:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7501
                    cpuType = __MKSTRING("DEC_3000_300");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7502
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7503
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7504
#  ifdef DEC_2000_300
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7505
                case DEC_2000_300:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7506
                    cpuType = __MKSTRING("DEC_2000_300");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7507
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7508
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7509
#  ifdef DEC_2100_A500
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7510
                case DEC_2100_A500:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7511
                    cpuType = __MKSTRING("DEC_2100_A500");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7512
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7513
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7514
#  ifdef DEC_2100_A50
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7515
                case DEC_2100_A50:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7516
                    cpuType = __MKSTRING("DEC_2100_A50");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7517
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7518
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7519
#  ifdef ALPHA_KN20AA
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7520
                case ALPHA_KN20AA:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7521
                    cpuType = __MKSTRING("ALPHA_KN20AA");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7522
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7523
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7524
#  ifdef DEC_21000
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7525
                case DEC_21000:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7526
                    cpuType = __MKSTRING("DEC_21000");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7527
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7528
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7529
#  ifdef DEC_AXPVME_64
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7530
                case DEC_AXPVME_64:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7531
                    cpuType = __MKSTRING("DEC_AXPVME_64");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7532
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7533
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7534
#  ifdef DEC_2100_C500
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7535
                case DEC_2100_C500:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7536
                    cpuType = __MKSTRING("DEC_2100_C500");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7537
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7538
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7539
#  ifdef DEC_AXPPCI_33
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7540
                case DEC_AXPPCI_33:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7541
                    cpuType = __MKSTRING("DEC_AXPPCI_33");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7542
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7543
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7544
#  ifdef DEC_1000
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7545
                case DEC_1000:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7546
                    cpuType = __MKSTRING("DEC_1000");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7547
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7548
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7549
#  ifdef EB64_PLUS
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7550
                case EB64_PLUS:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7551
                    cpuType = __MKSTRING("EB64_PLUS");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7552
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7553
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7554
#  ifdef LCA_EB66
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7555
                case LCA_EB66:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7556
                    cpuType = __MKSTRING("LCA_EB66");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7557
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7558
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7559
#  ifdef ALPHA_EB164
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7560
                case ALPHA_EB164:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7561
                    cpuType = __MKSTRING("ALPHA_EB164");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7562
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7563
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7564
#  ifdef DEC_EV45_PBP
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7565
                case DEC_EV45_PBP:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7566
                    cpuType = __MKSTRING("DEC_EV45_PBP");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7567
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7568
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7569
#  ifdef DEC_1000A
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7570
                case DEC_1000A:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7571
                    cpuType = __MKSTRING("DEC_1000A");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7572
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7573
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7574
#  ifdef DEC_4100
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7575
                case DEC_4100:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7576
                    cpuType = __MKSTRING("DEC_4100");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7577
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7578
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7579
#  ifdef DEC_ALPHAVME_224
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7580
                case DEC_ALPHAVME_224:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7581
                    cpuType = __MKSTRING("DEC_ALPHAVME_224");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7582
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7583
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7584
#  ifdef DEC_1000_5
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7585
                case DEC_1000_5:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7586
                    cpuType = __MKSTRING("DEC_1000_5");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7587
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7588
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7589
#  ifdef DEC_1000A_5
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7590
                case DEC_1000A_5:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7591
                    cpuType = __MKSTRING("DEC_1000A_5");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7592
                    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7593
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7594
#  ifdef DEC_EV56_PBP
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7595
                case DEC_EV56_PBP:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7596
                    cpuType = __MKSTRING("DEC_EV56_PBP");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7597
                    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7598
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7599
#  ifdef ALPHABOOK
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7600
                case ALPHABOOK:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7601
                    cpuType = __MKSTRING("ALPHABOOK");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7602
                    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7603
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7604
#  ifdef DEC_ALPHAVME_320
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7605
                case DEC_ALPHAVME_320:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7606
                    cpuType = __MKSTRING("DEC_ALPHAVME_320");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7607
                    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7608
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7609
#  ifdef DEC_550
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7610
                case DEC_550:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7611
                    cpuType = __MKSTRING("DEC_550");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7612
                    break;
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7613
#  endif
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7614
#  ifdef DEC_6600
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7615
                case DEC_6600:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7616
                    cpuType = __MKSTRING("DEC_6600");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7617
                    break;
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7618
#  endif
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7619
#  ifdef UNKN_SYSTEM
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7620
                case UNKN_SYSTEM:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7621
                    cpuType = __MKSTRING("UNKN_SYSTEM");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7622
                    break;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7623
#  endif
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7624
                default:
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7625
                    cpuType = __MKSTRING("OTHER_DEC_SYSTEM");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7626
                    break;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7627
            }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7628
        }
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7629
# endif /* GSI_CPU */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7630
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7631
# if defined(GSI_CPU_INFO)
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7632
        /*
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7633
         * stupid: OSF1 pre V4.0 has no mhz, but V4.0 has it.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7634
         * use the GSI_PLATFORM_NAME as a hint - it is only defined in
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7635
         * V4.0 and higher ... (sigh)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7636
         */
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  7637
#  if defined GSI_PLATFORM_NAME
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7638
        {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7639
            struct cpu_info cpuInfo;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7640
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7641
            index = 0;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7642
            if (getsysinfo(GSI_CPU_INFO, &cpuInfo, sizeof(cpuInfo), &index, NULL) > 0) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7643
                cpuSpeed   = __MKUINT(cpuInfo.mhz);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7644
            }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7645
        }
4258
4c1f909de78e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4228
diff changeset
  7646
#  endif
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7647
# endif /* GSI_CPU_INFO */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7648
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7649
# if defined(GSI_CPUS_IN_BOX)
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7650
        index = 0;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7651
        if (getsysinfo(GSI_CPUS_IN_BOX, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7652
            numberOfCPUs   = __MKUINT(retInt32);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7653
        }
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7654
# endif /* GSI_CPUS_IN_BOX */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7655
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7656
# if defined(GSI_PHYSMEM)
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7657
        index = 0;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7658
        if (getsysinfo(GSI_PHYSMEM, &retInt32, sizeof(retInt32), &index, NULL) > 0) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7659
            INT bytes = retInt32 * 1024;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7660
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7661
            physicalRam   = __MKUINT(bytes);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7662
        }
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7663
# endif /* GSI_PHYSMEM */
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7664
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7665
# if defined(GSI_PLATFORM_NAME) && (!defined(HAS_SYSINFO) || !defined(SI_PLATFORM))
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7666
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7667
        char buffer[128];
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7668
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7669
        index = 0;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7670
        if (getsysinfo(GSI_PLATFORM_NAME, buffer, sizeof(buffer), &index, NULL) > 0) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7671
            platform = __MKSTRING(buffer);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7672
        }
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7673
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7674
# endif /* GSI_PLATFORM_NAME */
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7675
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7676
    }
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7677
#endif /* HAS_GETSYSINFO */
3735
3560084b4f83 more sysInfo for alpha systems (cpuType & physicalRam)
Claus Gittinger <cg@exept.de>
parents: 3696
diff changeset
  7678
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7679
    {
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7680
        extern OBJ __getInstructionSetInfo();
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7681
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7682
        extendedInstructions = __getInstructionSetInfo();
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7683
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7684
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7685
    sys isNil ifTrue:[
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7686
        sys := self getSystemType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7687
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7688
    node isNil ifTrue:[
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7689
        node := self getHostName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7690
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7691
    dom isNil ifTrue:[
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7692
        dom := self getDomainName.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7693
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7694
    mach isNil ifTrue:[
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7695
        mach := self getCPUType.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7696
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7697
    arch isNil ifTrue:[
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7698
        arch := sys.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7699
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7700
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7701
    info := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7702
    info at:#system put:sys.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7703
    info at:#node put:node.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7704
    rel notNil ifTrue:[info at:#release put:rel].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7705
    ver notNil ifTrue:[info at:#version put:ver].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7706
    mach notNil ifTrue:[info at:#machine put:mach].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7707
    arch notNil ifTrue:[info at:#architecture put:arch].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7708
    dom notNil ifTrue:[info at:#domain put:dom].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7709
    (pageSize notNil and:[physicalPages notNil]) ifTrue:[
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7710
        physicalRam := pageSize * physicalPages. "/ done here - could be largeInt.
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7711
    ].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7712
    physicalRam notNil ifTrue:[info at:#physicalRam put:physicalRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7713
    (pageSize notNil and:[availablePages notNil]) ifTrue:[
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7714
        availableRam := pageSize * availablePages. "/ done here - could be largeInt.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7715
        availableRam notNil ifTrue:[info at:#availableRam put:availableRam].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7716
    ].
3690
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7717
    totalRam notNil ifTrue:[info at:#totalRam put:totalRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7718
    sharedRam notNil ifTrue:[info at:#sharedRam put:sharedRam].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7719
    bufferRam notNil ifTrue:[info at:#bufferRam put:bufferRam].
4020
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7720
    virtualRam notNil ifTrue:[info at:#virtualRam put:virtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7721
    activeVirtualRam notNil ifTrue:[info at:#activeVirtualRam put:activeVirtualRam].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7722
    realMemory notNil ifTrue:[info at:#realMemory put:realMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7723
    activeRealMemory notNil ifTrue:[info at:#activeRealMemory put:activeRealMemory].
e73a3c919ac0 more memory info for hpux
Claus Gittinger <cg@exept.de>
parents: 4018
diff changeset
  7724
    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
  7725
    swapSize notNil ifTrue:[info at:#swapSize put:swapSize].
7b7c5ff84986 more info in getSystemInfo (linux only)
Claus Gittinger <cg@exept.de>
parents: 3663
diff changeset
  7726
    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
  7727
    numberOfCPUs notNil ifTrue:[info at:#numberOfCPUs put:numberOfCPUs].
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  7728
    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
  7729
    cpuType notNil ifTrue:[info at:#cpuType put:cpuType].
4101
f3d1a13c64b0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4088
diff changeset
  7730
    cpuSpeed notNil ifTrue:[info at:#cpuSpeed put:cpuSpeed].
3737
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7731
    dCacheSize notNil ifTrue:[info at:#dCacheSize put:dCacheSize].
7560b716b2d5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
  7732
    iCacheSize notNil ifTrue:[info at:#iCacheSize put:iCacheSize].
4084
797fd09b7808 more systemInfo (solaris only)
Claus Gittinger <cg@exept.de>
parents: 4020
diff changeset
  7733
    instructionSets notNil ifTrue:[info at:#instructionSets put:instructionSets].
4922
6877d20bc7b5 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4882
diff changeset
  7734
    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
  7735
    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
  7736
    info at:#osType put:(self getOSType).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7737
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7738
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7739
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7740
     OperatingSystem getSystemInfo
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7741
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7742
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7743
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7744
getSystemType
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7745
    "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
  7746
     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
  7747
     is slightly different for some systems (i.e. iris vs. irix).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7748
     Dont 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
  7749
     here ...
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7750
     (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
  7751
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7752
    |sys|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7753
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7754
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7755
#   ifdef NEXT
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7756
#    define SYS_SYMBOL @symbol(next)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7757
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7758
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7759
#   ifdef IRIS
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7760
#    define SYS_SYMBOL @symbol(iris)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7761
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7762
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7763
#   ifdef SYS_SYMBOL
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7764
     sys = SYS_SYMBOL;
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7765
#    undef SYS_SYMBOL
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7766
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7767
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7768
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7769
    sys isNil ifTrue:[
12962
3215be68c1a0 changed:
Stefan Vogel <sv@exept.de>
parents: 12872
diff changeset
  7770
        ^ self getOSType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7771
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7772
    ^ sys
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7773
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7774
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7775
     OperatingSystem getSystemType
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7776
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7777
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7778
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7779
isBSDlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7780
    "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
  7781
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7782
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7783
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7784
#if defined(BSD) || defined(MACH) || defined(SYSV4)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7785
    RETURN ( true );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7786
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7787
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7788
    ^ false
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7789
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7790
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7791
     OperatingSystem isBSDlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7792
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7793
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7794
12640
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7795
isProcessIdPresent:pid
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7796
    "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
  7797
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7798
%{
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7799
    if (__isSmallInteger(pid)) {
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7800
        /* in UNIX, a kill(pid, 0) is a noop used to check if a pid exists */   
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7801
        if (kill(__smallIntegerVal(pid), 0) < 0 && errno != EPERM) {
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7802
            RETURN ( false );
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7803
        }
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7804
        RETURN ( true );
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7805
    }
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7806
%}.
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7807
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7808
    ^ self primitiveFailed:#invalidParameter
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7809
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7810
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7811
    "
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7812
      self isProcessIdPresent:self getProcessId
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7813
      self isProcessIdPresent:1
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7814
      self isProcessIdPresent:4711
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7815
    "    
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7816
!
0ce280195100 added: #isProcessIdPresent:
Stefan Vogel <sv@exept.de>
parents: 12530
diff changeset
  7817
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7818
isUNIXlike
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7819
    "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
  7820
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7821
    ^ true
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7822
6499
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7823
    "
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7824
     OperatingSystem isUNIXlike
d412a0eca722 fix getHostName/getDomainName in case no hostname is available, and
Claus Gittinger <cg@exept.de>
parents: 6495
diff changeset
  7825
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7826
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7827
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7828
maxFileNameLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7829
    "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
  7830
     CAVEAT:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7831
	 Actually, the following is somewhat wrong - some systems
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7832
	 support different sizes, depending on the volume.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7833
	 We return a somewhat conservative number here.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7834
	 Another entry, to query for volume specific max
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7835
	 will be added in the future."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7836
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7837
%{  /* NOCONTEXT */
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7838
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7839
    /*
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7840
     * 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
  7841
     */
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7842
#   if defined(MAXFILENAMELEN)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  7843
      RETURN ( __mkSmallInteger(MAXFILENAMELEN) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7844
#   else
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7845
#    if defined(BSD) || defined(SYSV4) || defined(LONGFILENAMES)
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  7846
      RETURN ( __mkSmallInteger(255) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7847
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7848
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7849
#    ifdef realIX
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  7850
       RETURN ( __mkSmallInteger(127) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7851
#    endif
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7852
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7853
#    ifdef SYSV
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  7854
       RETURN ( __mkSmallInteger(14) );
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7855
#    endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7856
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7857
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7858
    "unix default"
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
    ^ 14
5460
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7861
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7862
    "
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7863
     OperatingSystem maxFileNameLength
bf02ab313db2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 5451
diff changeset
  7864
    "
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
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7867
maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7868
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7869
%{
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7870
     long l;
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7871
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7872
     l = sysconf(_SC_OPEN_MAX);
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7873
     if (l >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7874
	 RETURN(__mkSmallInteger(l));
6579
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7875
     }
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7876
%}.
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7877
     self primitiveFailed
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7878
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7879
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7880
      self maxNumberOfOpenFiles
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7881
     "
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7882
!
2553ff4b56d9 #maxNumberOfOpenFiles
Stefan Vogel <sv@exept.de>
parents: 6542
diff changeset
  7883
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7884
maxPathLength
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7885
    "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
  7886
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7887
%{  /* NOCONTEXT */
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  7888
    RETURN ( __mkSmallInteger(MAXPATHLEN) );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7889
%}
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7890
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7891
     OperatingSystem maxPathLength
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7892
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7893
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7894
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7895
pathSeparator
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7896
    "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
  7897
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7898
    ^ $:
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7899
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7900
    "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
  7901
    "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
  7902
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7903
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7904
platformName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7905
    "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
  7906
     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
  7907
     #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
  7908
     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
  7909
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7910
    ^ #unix
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7911
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7912
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  7913
     OperatingSystem platformName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7914
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7915
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  7916
    "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
  7917
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  7918
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7919
primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7920
    "return the domain this host is in.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7921
     Notice:
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  7922
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7923
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7924
%{  /* STACK: 2048 */
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7925
#if defined(HAS_GETDOMAINNAME)
10955
6bf7da8e1c3d New: #getEnvironment
Stefan Vogel <sv@exept.de>
parents: 10930
diff changeset
  7926
    char buffer[256];
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7927
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7928
    if (getdomainname(buffer, sizeof(buffer)) == 0) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  7929
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7930
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7931
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7932
# if defined(HAS_UNAME) && defined(HAS_UTS_DOMAINNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7933
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7934
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7935
    if (uname(&ubuff) >= 0) {
11368
40cfb21ded45 +createFileForWrite
Claus Gittinger <cg@exept.de>
parents: 11285
diff changeset
  7936
	RETURN (__MKSTRING(ubuff.domainname));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7937
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7938
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7939
#  if defined(HAS_SYSINFO) && defined(SI_SRPC_DOMAIN)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7940
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7941
    int ret;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7942
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7943
    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
  7944
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7945
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7946
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7947
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7948
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7949
%}.
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7950
    ^ nil
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7951
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7952
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7953
     OperatingSystem primGetDomainName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7954
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7955
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7956
    "Modified: 26.4.1996 / 10:04:54 / stefan"
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7957
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7958
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7959
primGetHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7960
    "return the hostname we are running on - if there is
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7961
     a HOST environment variable, we are much faster here ...
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7962
     Notice:
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7963
	not all systems support this; on some, nil is returned."
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7964
6960
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7965
%{  /* STACK: 100000 */
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7966
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7967
    /* sigh - with libc.so.6, gethostname needs huge amounts of stack
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7968
     * actually this is linux specific, but should not hurt others
f53bba609580 stack in gethostname
Claus Gittinger <cg@exept.de>
parents: 6852
diff changeset
  7969
     */
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7970
#if defined(HAS_GETHOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7971
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7972
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7973
    if (gethostname(buffer, sizeof(buffer)) == 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7974
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7975
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7976
#else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7977
# if defined(HAS_UNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7978
    struct utsname ubuff;
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7979
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7980
    if (uname(&ubuff) >= 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  7981
	RETURN (__MKSTRING(ubuff.nodename));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7982
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7983
# else
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7984
#  if defined(HAS_SYSINFO) && defined(SI_HOSTNAME)
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7985
    char buffer[256];
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7986
    int ret;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7987
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7988
    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
  7989
	RETURN (__MKSTRING(buffer));
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7990
    }
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7991
#  endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7992
# endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7993
#endif
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7994
%}.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  7995
    ^ nil
5444
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7996
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7997
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7998
     OperatingSystem getHostName
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  7999
    "
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8000
!
5cbb37147eeb rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5438
diff changeset
  8001
12641
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8002
setEnvironment:aKeyStringOrSymbol to:aString
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8003
    "put a string to the environment.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8004
     If aString isNil, the variable will be removed from the environment.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8005
     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
  8006
     We could use ExternalBytes and keep the references in a Dictionary to free the
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8007
     memory on change or delete"
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8008
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8009
%{  /* NOCONTEXT */
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8010
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8011
    char *env;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8012
    int valueSize;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8013
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8014
    if (__isStringLike(aKeyStringOrSymbol)) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8015
        if (aString == nil) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8016
            /* env used only temporary for deregistration */
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8017
            valueSize = 0;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8018
            env = __stringVal(aKeyStringOrSymbol);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8019
        } else if (__isStringLike(aString)) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8020
            /* have to use stable memory for env */
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8021
            valueSize = __stringSize(aString);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8022
            env = (char *)malloc(__stringSize(aKeyStringOrSymbol) + valueSize + 2);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8023
            if (env == 0)
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8024
                goto err;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8025
            strcpy(env, __stringVal(aKeyStringOrSymbol));
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8026
            strcat(env, "=");
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8027
            strncat(env, __stringVal(aString), valueSize);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8028
        } else
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8029
            goto err;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8030
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8031
        if (putenv(env) == 0) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8032
            RETURN(self);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8033
        }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8034
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8035
        if (valueSize > 0) {
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8036
            /* could not register, free */
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8037
            free(env);
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8038
        }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8039
err:;
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8040
    }
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8041
%}.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8042
    ^ self primitiveFailed
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8043
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8044
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8045
     OperatingSystem setEnvironment:#TEST to:'abc'.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8046
     OperatingSystem getEnvironment:#TEST.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8047
     OperatingSystem executeCommand:'echo $TEST' outputTo:Transcript.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8048
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8049
     OperatingSystem setEnvironment:#TEST to:nil.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8050
     OperatingSystem setEnvironment:#TEST to:''.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8051
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8052
     OperatingSystem setEnvironment:#LD_LIBRARY_PATH to:'/opt/oracle/instantclient10_1'.
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8053
    "
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8054
!
Stefan Vogel <sv@exept.de>
parents: 12640
diff changeset
  8055
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8056
setLocaleInfo:anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8057
    "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
  8058
     (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
  8059
     See description of fields in #getLocaleInfo.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8060
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8061
     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
  8062
     it should be used by applications as required."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8063
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8064
    LocaleInfo := anInfoDictionary
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8065
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8066
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8067
     |d|
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
     d := IdentityDictionary new.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8070
     d at:#decimalPoint                 put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8071
     d at:#thousandsSeparator           put:','         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8072
     d at:#currencySymbol               put:'USD'       .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8073
     d at:#monetaryDecimalPoint         put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8074
     d at:#monetaryThousandsSeparator   put:'.'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8075
     d at:#fractionalDigits             put:2           .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8076
     d at:#positiveSign                 put:'+'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8077
     d at:#negativeSign                 put:'-'         .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8078
     d at:#positiveSignPrecedesCurrencySymbol put:true          .
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8079
     d at:#negativeSignPrecedesCurrencySymbol put:false         .
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8080
     OperatingSystem setLocaleInfo:d
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8081
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8082
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8083
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8084
supportsChildInterrupts
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8085
    "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
  8086
     through interrupts (i.e. SIGCHILD)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8087
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8088
%{  /* NOCONTEXT */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  8089
#if defined(SIGCHLD) || defined(SIGCLD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8090
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8091
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8092
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8093
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8094
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8095
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8096
     OperatingSystem supportsChildInterrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8097
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8098
!
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
supportsIOInterrupts
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8101
    "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
  8102
     (i.e. SIGPOLL/SIGIO).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8103
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8104
     Currently, this mechanism does not work on all
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8105
     systems ...
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8106
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8107
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8108
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8109
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8110
  /* positive defines here
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8111
   *  - irix5.2 does not work
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8112
   */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8113
#if defined(LINUX)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8114
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8115
# if defined(SIGIO) || defined(SIGPOLL)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8116
#  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
  8117
#   if defined(F_SETOWN) || defined(FIOSETOWN)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8118
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8119
    RETURN (true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8120
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8121
#   endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8122
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8123
# endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8124
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8125
#endif /* machines where it works */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8126
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8127
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8128
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8129
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8130
     OperatingSystem supportsIOInterrupts
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8131
    "
4934
6579e2e2ad7f solaris 5.6 DOES support IO-interrupts.
Claus Gittinger <cg@exept.de>
parents: 4933
diff changeset
  8132
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8133
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8134
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8135
supportsNonBlockingIO
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8136
    "return true, if the OS supports nonblocking IO."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8137
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8138
%{  /* NOCONTEXT */
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8139
#if defined(F_GETFL) && defined(F_SETFL)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8140
# 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
  8141
       RETURN (true);
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  8142
# endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8143
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8144
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8145
    ^ false
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8146
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8147
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8148
     OperatingSystem supportsNonBlockingIO
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8149
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8150
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8151
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8152
supportsSymbolicLinks
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8153
    "return true, if the OS supports symbolic (soft) links;
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8154
     most UNIX'es do; many other OS's do not."
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8155
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8156
%{  /* NOCONTEXT */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8157
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8158
#ifdef S_IFLNK
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8159
    /*
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8160
     * assume yes - if that is defined.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8161
     */
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8162
    RETURN(true);
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8163
#endif
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8164
%}.
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8165
    ^ false
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8166
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8167
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8168
     OperatingSystem supportsSymbolicLinks
3759
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8169
    "
1601d99a36b5 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 3737
diff changeset
  8170
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8171
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8172
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8173
!UnixOperatingSystem class methodsFor:'path queries'!
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8174
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8175
defaultSystemPath
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8176
    "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
  8177
     (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
  8178
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
  8179
    |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
  8180
ad054a02bc88 only add common dirs to the systemPath, IFF the
Claus Gittinger <cg@exept.de>
parents: 5639
diff changeset
  8181
    majorVersionNr := Smalltalk majorVersionNr.
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8182
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8183
    sysPath := super defaultSystemPath.
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8184
    #(
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8185
	'/usr/local/lib/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8186
	'/usr/local/lib/smalltalk'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8187
	'/usr/lib/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8188
	'/usr/lib/smalltalk'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8189
	'/lib/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8190
	'/lib/smalltalk'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8191
	'/opt/stx'
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8192
	'/opt/smalltalk'
7698
d8cd175e8e29 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7681
diff changeset
  8193
    ) do:[:dirName |
7736
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8194
	|dir|
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8195
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8196
	dir := dirName asFilename.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8197
	(dir isDirectory) ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8198
	    "/ try to guess a gnu-smalltalk; skip it
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8199
	    (dir construct:'initialize.st') exists ifFalse:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8200
		releaseFile := dir construct:'RELEASE'.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8201
		releaseFile exists ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8202
		    s := releaseFile readStreamOrNil.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8203
		    s notNil ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8204
			v := Integer readFrom:s onError:-1.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8205
			s close.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8206
			v == majorVersionNr ifTrue:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8207
			    sysPath add:dirName
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8208
			] ifFalse:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8209
			    ('UnixOperatingSystem [info]: ignore files in ' , dir pathName , ' (RELEASE mismatch)') infoPrintCR.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8210
			]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8211
		    ] ifFalse:[
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8212
			('UnixOperatingSystem [info]: ignore files in ' , dir pathName , ' (RELEASE missing)') infoPrintCR.
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8213
		    ]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8214
		]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8215
	    ]
85efb0b2e62c HAS_UNIX98_PTY handling
Stefan Vogel <sv@exept.de>
parents: 7735
diff changeset
  8216
	]
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8217
    ].
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8218
    ^ sysPath
5035
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8219
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8220
    "
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8221
     OperatingSystem defaultSystemPath
e80199cc4f50 comment
Claus Gittinger <cg@exept.de>
parents: 4935
diff changeset
  8222
    "
4018
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8223
! !
b4bb0f43d6a7 changed execute-in-dir
Claus Gittinger <cg@exept.de>
parents: 4001
diff changeset
  8224
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8225
!UnixOperatingSystem class methodsFor:'private'!
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8226
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8227
mountPointsFromProcFS
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8228
    "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
  8229
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8230
    |entries|
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8231
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8232
    entries := OrderedCollection new.
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8233
    ('/proc/mounts' asFilename) readingLinesDo:[:eachLine |
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8234
	|items mountInfo|
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8235
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8236
	items := eachLine asCollectionOfWords.
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8237
	mountInfo := (MountInfo new
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8238
	    mountPointPath:(items at:2)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8239
	    deviceOrRemotePath:(items at:1)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8240
	    fsType:(items at:3)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8241
	    attributeString:(items at:4)).
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8242
	entries add:mountInfo
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8243
    ].
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8244
    ^ entries
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8245
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8246
    "
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8247
     OperatingSystem mountPointsFromProcFS
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8248
    "
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8249
!
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  8250
3558
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8251
osProcessStatusClass
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8252
    ^ OSProcessStatus
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8253
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8254
    "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
  8255
! !
5a6c4b491b95 oops - OSProcessStatus is only known in a concrete class
Claus Gittinger <cg@exept.de>
parents: 3556
diff changeset
  8256
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8257
!UnixOperatingSystem class methodsFor:'shared memory access'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8258
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8259
shmAttach:id address:addr flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8260
    "low level entry to shmat()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8261
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8262
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8263
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8264
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8265
    void *address, *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8266
    int shmflg, shmid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8267
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8268
    if (__isSmallInteger(addr)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8269
     && __bothSmallInteger(flags, id)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8270
	shmaddr = (void *) __intVal(addr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8271
	shmflg = __intVal(flags);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8272
	shmid = __intVal(id);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8273
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8274
	address = shmat(shmid, shmaddr, shmflg);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8275
	if (address != (void *)-1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8276
	    RETURN (__MKEXTERNALBYTES(addr));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8277
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8278
	@global(LastErrorNumber) = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8279
	RETURN (nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8280
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8281
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8282
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8283
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8284
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8285
    "Modified: 22.4.1996 / 13:15:12 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8286
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8287
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8288
shmDetach:addr
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8289
    "low level entry to shmdt()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8290
     Not supported on all operatingSystems"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8291
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8292
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8293
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8294
    void *shmaddr;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8295
    int rslt;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8296
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8297
    if (__isSmallInteger(addr)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8298
	shmaddr = (void *) __intVal(addr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8299
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8300
	rslt = shmdt(shmaddr);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8301
	if (rslt != -1) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8302
	    RETURN (true);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8303
	}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8304
	@global(LastErrorNumber) = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8305
	RETURN (false);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8306
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8307
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8308
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8309
    ^ self primitiveFailed
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
    "Modified: 22.4.1996 / 13:15:03 / cg"
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8314
shmGet:key size:size flags:flags
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8315
    "low level entry to shmget()-system call.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8316
     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
  8317
     - use the provided wrapper class SharedExternalBytes instead."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8318
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8319
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8320
#ifdef WANT_SHM
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8321
    if (__bothSmallInteger(key, size)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8322
     && __isSmallInteger(flags)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8323
	int rslt;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8324
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8325
	rslt = shmget(__intVal(key), __intVal(size), __intVal(flags));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8326
	if (rslt != -1) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8327
	    RETURN (__mkSmallInteger(rslt));
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8328
	}
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8329
	@global(LastErrorNumber) = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8330
	RETURN (nil);
3496
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
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8333
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8334
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8335
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8336
    "Modified: 22.4.1996 / 13:14:46 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8337
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8338
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8339
!UnixOperatingSystem class methodsFor:'socket creation'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8340
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8341
socketAccessor
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8342
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8343
    ^ SocketHandle
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8344
!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
  8345
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8346
socketWithDomain:domainArg type:typeArg protocol:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8347
    "set up socket with domain, type and protocol number.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8348
     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
  8349
     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
  8350
     #inet,#unix, #appletalk, #x25 .. and #stream, #datagram, #raw resp."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8351
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8352
    ^ SocketHandle new domain:domainArg type:typeArg protocol:protocolArg
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8353
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  8354
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8355
!UnixOperatingSystem class methodsFor:'time and date'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8356
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8357
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
  8358
    "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
  8359
     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
  8360
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8361
    ^ self
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8362
	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
  8363
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8364
    "
5639
2e750f87b419 Fix UTC Time handling when daylight saving time applies.
Stefan Vogel <sv@exept.de>
parents: 5625
diff changeset
  8365
     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
  8366
     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
  8367
     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
  8368
     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
  8369
    "
4380
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8370
!
9f168c6f4beb New method to set UTC time.
Stefan Vogel <sv@exept.de>
parents: 4285
diff changeset
  8371
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8372
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
  8373
    "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
  8374
     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
  8375
     any daylight saving adjustings."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8376
6375
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8377
    ^ self
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8378
	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
  8379
    "
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8380
     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
  8381
    "
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8382
!
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8383
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8384
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
  8385
    "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
  8386
     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
  8387
     otherwise, in localtime including any daylight saving adjustings."
7391258a73e8 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 6372
diff changeset
  8388
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8389
    |osSeconds|
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
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8392
    struct tm tm;
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8393
    time_t t;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8394
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8395
    if (__bothSmallInteger(y, m)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8396
     && __bothSmallInteger(d, h)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8397
     && __bothSmallInteger(min, s)) {
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8398
        tm.tm_hour = __intVal(h);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8399
        tm.tm_min = __intVal(min);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8400
        tm.tm_sec = __intVal(s);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8401
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8402
        tm.tm_year = __intVal(y) - 1900;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8403
        tm.tm_mon = __intVal(m) - 1;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8404
        tm.tm_mday = __intVal(d);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8405
        tm.tm_isdst = -1;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8406
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8407
        t = mktime(&tm);                        /* mktime() interprets tm as localtime */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8408
        if ((INT)t != -1) {
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8409
            if (utcBoolean == true) {           /* convert to utc time */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8410
                t = (INT)t - TIMEZONE(&tm);     /* TIMZONE = seconds westward from 0 */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8411
            }
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8412
            osSeconds = __MKINT((INT)t);        /* be careful, t can be negative at the start of the epoch ! */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8413
        }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8414
    }
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
    osSeconds notNil ifTrue:[
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8417
        ^ osSeconds * 1000 + millis
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8418
    ].
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8419
    ^ TimeConversionError raiseRequest.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8420
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8421
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8422
     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
  8423
     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
  8424
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8425
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8426
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8427
getMicrosecondTime
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8428
    "This returns the microsecond timers value - if available.
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8429
     On some machines, times with this precision may not be available,
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8430
     on those, the returned value may be rounded towards some internal
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8431
     clock resolution value."
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8432
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8433
    |seconds micros error|
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8434
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8435
%{
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8436
    unsigned long _secs, _micros;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8437
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
  8438
#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
  8439
    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
  8440
    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
  8441
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8442
    if (has_clock_gettime) {
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8443
        if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8444
            _secs = ts.tv_sec;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8445
            _micros  = ts.tv_nsec / 1000;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8446
            goto out;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8447
        } else {
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8448
            /*
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8449
             * clock_gettime is not implemented in the kernel
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8450
             * fall through to alternative implementation
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8451
             */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8452
            has_clock_gettime = 0;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8453
        }
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8454
    }
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8455
#endif
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8456
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8457
#if defined(HAS_GETTIMEOFDAY)
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8458
    struct timeval tb;
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8459
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8460
    gettimeofday(&tb, NULL /* &tzb */);
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8461
    if (tb.tv_usec >= (1000000)) {
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8462
        error = @symbol(bad);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8463
        goto err;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8464
    }
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8465
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8466
    _secs = tb.tv_sec;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8467
    _micros  = tb.tv_usec;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8468
#endif
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8469
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8470
    /*
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8471
     * mhmh long-long stuff seems not to work correctly
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8472
     * on all machines (sparc)
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8473
     * being conservative here ...
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8474
     */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8475
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8476
#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(__i386__)
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8477
# define HAS_LONGLONG
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8478
#endif
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8479
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8480
out:
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8481
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8482
#if __POINTER_SIZE__ == 8
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8483
    {
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8484
        unsigned INT rslt;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8485
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8486
        rslt = (unsigned INT)_secs * 1000000 + _micros;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8487
        RETURN (__MKUINT(rslt));
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8488
    }
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8489
#else
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8490
# ifdef HAS_LONGLONG
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8491
    {
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8492
        unsigned long long rslt;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8493
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8494
        rslt = (unsigned long long)_secs * 1000000 + _micros;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8495
        RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8496
    }
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8497
# else
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8498
    seconds = __MKUINT(_secs);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8499
    micros = __MKUINT(_micros);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8500
# endif /* long long */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8501
#endif /* __POINTER_SIZE__ == 8 */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8502
err:;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8503
%}.
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8504
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8505
    seconds notNil ifTrue:[
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8506
        ^ (seconds * 1000000) + micros
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8507
    ].
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8508
    error isNil ifTrue:[
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8509
        ^ self getMillisecondTime * 1000
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8510
    ].
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8511
    self primitiveFailed:error.
3692
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8512
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8513
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8514
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8515
     Transcript showCR:(OperatingSystem getMicrosecondTime).
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8516
    "
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8517
!
0f0377cca3d6 added microSecondclock access.
Claus Gittinger <cg@exept.de>
parents: 3691
diff changeset
  8518
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8519
getMillisecondTime
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8520
    "Return the millisecond timers value.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8521
     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
  8522
     LargeInteger arithmetic when doing timeouts and delays.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8523
     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
  8524
     short relative time deltas.
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8525
     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
  8526
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8527
     BAD DESIGN:
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8528
        This should be changed to return some instance of RelativeTime,
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8529
        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
  8530
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8531
     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
  8532
     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
  8533
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8534
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8535
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8536
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8537
    long t = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8538
10800
1a11961ddab2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 10791
diff changeset
  8539
#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
  8540
    static has_clock_gettime = 1;
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8541
    struct timespec ts;
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8542
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8543
    if (has_clock_gettime) {
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8544
        if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) {
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8545
            t = ts.tv_sec*1000 + ts.tv_nsec/1000000;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8546
            goto out;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8547
        } else {
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8548
            /*
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8549
             * clock_gettime is not implemented in the kernel
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8550
             * fall through to alternative implementation
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8551
             */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8552
            has_clock_gettime = 0;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8553
        }
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8554
    }
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8555
#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
  8556
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8557
#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
  8558
/*
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8559
 * 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
  8560
 * 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
  8561
 */
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8562
# include <sys/times.h>
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8563
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8564
    static int millisecondsPerTick;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8565
    clock_t ticks;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8566
    struct tms tb;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8567
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8568
    if (!millisecondsPerTick) {
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8569
        int ticksPerSecond = sysconf(_SC_CLK_TCK);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8570
        if (ticksPerSecond <= 0)
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8571
            goto err;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8572
        if (ticksPerSecond > 1000)
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8573
            goto err;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8574
        millisecondsPerTick = 1000 / ticksPerSecond;
8592
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8575
/*
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8576
printf("milliSecondsPerTick: %d\n", millisecondsPerTick);
1c5216cd013e Use clock_gettime() to get monotonically increasing time.
Stefan Vogel <sv@exept.de>
parents: 8564
diff changeset
  8577
*/
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8578
    }
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8579
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8580
    ticks = times(&tb);
8672
f93733514fec Fix times() systemcall overflow into negative values (onl Solaris 9).
Stefan Vogel <sv@exept.de>
parents: 8618
diff changeset
  8581
    if (ticks == -1)
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8582
        goto err;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8583
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8584
    t = ticks * millisecondsPerTick;
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8585
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8586
#else /* !times */
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8587
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8588
    /* assume HAS_GETTIMEOFDAY
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8589
     * - will result in a linkage error
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8590
     * if not fixed.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8591
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8592
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8593
    struct timeval tb;
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8594
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8595
    gettimeofday(&tb, NULL);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8596
    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
  8597
#endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8598
8599
9edfb6a871bf Fix if _POSIX_MONOTONIC_CLOCK is defined and clock_gettime() is in
Stefan Vogel <sv@exept.de>
parents: 8592
diff changeset
  8599
out:
12832
fd20ec4fb909 Fix clock. Use clock_gettime() on LINUX.
Stefan Vogel <sv@exept.de>
parents: 12822
diff changeset
  8600
    RETURN ( __mkSmallInteger(t & 0x1FFFFFFF) );
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8601
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8602
err:;
5438
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8603
%}.
00e3c22156c3 added fallback st-code (for rel5 migration)
Claus Gittinger <cg@exept.de>
parents: 5407
diff changeset
  8604
    self primitiveFailed
8564
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8605
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8606
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8607
    "
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8608
      self getMillisecondTime
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8609
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8610
      Transcript showCR:(OperatingSystem getMillisecondTime).
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8611
      Transcript showCR:(OperatingSystem getMillisecondTime).
48fd5e5b9d21 Prefer times() in #getMillisecondTime to make system immune to
Stefan Vogel <sv@exept.de>
parents: 8496
diff changeset
  8612
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8613
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8614
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8615
getOSTime
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8616
    "This returns the OS time.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8617
     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
  8618
     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
  8619
     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
  8620
     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
  8621
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8622
     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
  8623
     interface. For compatibility with ST-80, use Time>>millisecondClockValue.
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8624
     or use instances of Time, Date or Timestamp to work with."
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8625
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8626
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8627
    |seconds millis|
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8628
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8629
%{
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8630
    unsigned long _secs, _millis;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8631
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8632
#if !defined(HAS_GETTIMEOFDAY)
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8633
# if defined(HAS_FTIME)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8634
    {
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8635
        struct timeb timebuffer;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8636
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8637
        ftime(&timebuffer);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8638
        _secs = timebuffer.time;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8639
        _millis = timebuffer.millitm;
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8640
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8641
#   define HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8642
# endif /* HAS_FTIME */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8643
#endif /* no HAS_GETTIMEOFDAY */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8644
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8645
#ifndef HAVE_TIME
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8646
    /*
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8647
     * use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8648
     * 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
  8649
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8650
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8651
    {
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8652
        /*
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8653
         * bsd time
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8654
         */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8655
        struct timeval tb;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8656
        /* struct timezone tzb; */
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8657
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8658
        gettimeofday(&tb, NULL /* &tzb */);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8659
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8660
        _secs = tb.tv_sec;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8661
        _millis = tb.tv_usec / 1000;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8662
    }
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8663
#endif
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8664
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8665
    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8666
     * mhmh long-long stuff seems not to work correctly
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8667
     * on all machines (sparc)
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8668
     * being conservative here ...
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8669
     */
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8670
8901
824a89d0b5c7 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 8883
diff changeset
  8671
#if defined(__GNUC__) && (__GNUC__ >= 2) && defined(__i386__)
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8672
# define HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8673
#endif
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8674
8901
824a89d0b5c7 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 8883
diff changeset
  8675
#if __POINTER_SIZE__ == 8
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8676
    {
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8677
        unsigned INT rslt;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8678
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8679
        rslt = (unsigned INT)_secs * 1000 + _millis;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8680
        RETURN (__MKUINT(rslt));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8681
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8682
#else
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8683
# ifdef HAS_LONGLONG
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8684
    {
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8685
        unsigned long long rslt;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8686
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8687
        rslt = (unsigned long long)_secs * 1000 + _millis;
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8688
        RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8689
    }
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8690
# else
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8691
    seconds = __MKUINT(_secs);
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8692
    millis = __MKUINT(_millis);
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8693
# endif /* long long */
8901
824a89d0b5c7 alpha64 vs. POINTER_SIZE cleanup
Claus Gittinger <cg@exept.de>
parents: 8883
diff changeset
  8694
#endif /* __POINTER_SIZE__ == 8 */
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8695
%}.
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8696
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8697
    seconds notNil ifTrue:[
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8698
        ^ (seconds * 1000) + millis
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8699
    ].
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8700
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8701
    self primitiveFailed.
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8702
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8703
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8704
    "
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8705
     OperatingSystem getOSTime printCR.
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8706
     Delay waitForSeconds:0.2.
12822
2016bf0b36bb changed:
Stefan Vogel <sv@exept.de>
parents: 12643
diff changeset
  8707
     OperatingSystem getOSTime printCR.
5488
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8708
    "
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8709
!
5d8def710e78 rel5 migration
Claus Gittinger <cg@exept.de>
parents: 5485
diff changeset
  8710
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8711
sleep:numberOfSeconds
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8712
    "{ Pragma: +optSpace }"
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
    "cease ANY action for some time. This suspends the whole smalltalk
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8715
     (unix-) process for some time if running threadless;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8716
     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
  8717
     only block until the next clock tick and return with the next
5233
e6756175b631 comments
Claus Gittinger <cg@exept.de>
parents: 5203
diff changeset
  8718
     timer interrupt.
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8719
     Use either OperatingSystem>>millisecondDelay: (which makes all
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8720
     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
  8721
     only the calling thread sleep)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8722
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8723
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8724
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8725
    if (__isSmallInteger(numberOfSeconds)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8726
	sleep(__intVal(numberOfSeconds));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8727
	RETURN ( self );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8728
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8729
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8730
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8731
     argument not integer
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8732
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8733
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8734
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8735
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8736
     OperatingSystem sleep:2
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8737
    "
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8738
!
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8739
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8740
timeInfoFromSeconds:osSeconds milliseconds:osMilliseconds localTime:isLocalTime
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8741
    "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
  8742
     OS-second value.
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8743
     An internal helper"
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8744
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8745
    |year month day hours minutes seconds utcOffset
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8746
     dst yDay wDay info|
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8747
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8748
%{
10285
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  8749
    struct tm tmValue;
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8750
    time_t tt;
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8751
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8752
    tt = __longIntVal(osSeconds);
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8753
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8754
    /* try cache */
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8755
    {
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8756
	OBJ lastSeconds, lastTimeInfo;
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8757
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8758
	lastSeconds = @global(LastTimeInfoSeconds);
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8759
	if (lastSeconds
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8760
	 && (__longIntVal(lastSeconds) == tt)
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8761
	 && (@global(LastTimeInfoMilliseconds) == osMilliseconds)
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8762
	 && (@global(LastTimeInfoIsLocal) == isLocalTime)
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8763
	) {
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8764
	    lastTimeInfo = @global(LastTimeInfo);
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8765
	    if (lastTimeInfo != nil) {
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8766
		RETURN (lastTimeInfo);
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8767
	    }
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8768
	}
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8769
    }
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8770
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8771
    if (isLocalTime == true) {
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8772
	localtime_r(&tt, &tmValue);
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8773
    } else {
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8774
	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
  8775
    }
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  8776
    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
  8777
    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
  8778
    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
  8779
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  8780
    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
  8781
    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
  8782
    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
  8783
016273fc1d38 Use thread save localtime_r() and gmtime_r() instead of localtime() and gmtime()
Stefan Vogel <sv@exept.de>
parents: 9078
diff changeset
  8784
    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
  8785
    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
  8786
    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
  8787
    dst = (tmValue.tm_isdst == 0 ? false : true);
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8788
%}.
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8789
    info := self timeInfoClass new.
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8790
    info
10346
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8791
	year:year
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8792
	month:month
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8793
	day:day
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8794
	hours:hours
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8795
	minutes:minutes
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8796
	seconds:seconds
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8797
	milliseconds:osMilliseconds
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8798
	utcOffset:utcOffset
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8799
	dst:dst
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8800
	dayInYear:yDay
5624ecbefd66 Cleanup time_t users
Stefan Vogel <sv@exept.de>
parents: 10285
diff changeset
  8801
	dayInWeek:wDay.
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8802
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8803
%{
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8804
    @global(LastTimeInfo) = info;                       __GSTORE(info);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8805
    @global(LastTimeInfoSeconds) = osSeconds;           __GSTORE(osSeconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8806
    @global(LastTimeInfoMilliseconds) = osMilliseconds; __GSTORE(osMilliseconds);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8807
    @global(LastTimeInfoIsLocal) = isLocalTime;         __GSTORE(isLocalTime);
7739
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8808
%}.
d09af69f0466 timeInfoFromOSTime - cache last return
Claus Gittinger <cg@exept.de>
parents: 7738
diff changeset
  8809
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8810
    ^ info
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8811
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8812
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8813
     OperatingSystem timeInfoFromSeconds:0 localTime:false
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8814
     OperatingSystem timeInfoFromSeconds:3600 localTime:false
7511
d6b7d28b135e added OSTimeInfo (instead of an array)
Claus Gittinger <cg@exept.de>
parents: 7510
diff changeset
  8815
    "
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8816
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8817
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8818
!UnixOperatingSystem class methodsFor:'users & groups'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8819
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8820
getEffectiveGroupID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8821
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8822
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8823
    "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
  8824
     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
  8825
     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
  8826
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8827
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8828
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8829
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8830
    uid = getegid();
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8831
    RETURN ( __mkSmallInteger(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8832
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8833
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8834
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8835
     OperatingSystem getEffectiveGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8836
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8837
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8838
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8839
getEffectiveUserID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8840
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8841
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8842
    "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
  8843
     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
  8844
     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
  8845
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8846
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8847
    int uid;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8848
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8849
    uid = geteuid();
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  8850
    RETURN ( __mkSmallInteger(uid) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8851
%}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8852
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8853
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8854
     OperatingSystem getEffectiveUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8855
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8856
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8857
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8858
getFullUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8859
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8860
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8861
    "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
  8862
     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
  8863
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8864
    |info gecos|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8865
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8866
    info := self userInfoOf:userID.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8867
    (info notNil
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8868
    and:[info includesKey:#gecos]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8869
	gecos := info at:#gecos.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8870
	(gecos includes:$,) ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8871
	    ^ gecos copyTo:(gecos indexOf:$,) - 1
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8872
	].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8873
	^ gecos
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8874
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8875
    ^ self getUserNameFromID:userID
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8876
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8877
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8878
     OperatingSystem getFullUserNameFromID:0
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8879
     OperatingSystem getFullUserNameFromID:(OperatingSystem getUserID)
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8880
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8881
     OperatingSystem getUserNameFromID:(OperatingSystem getUserID)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8882
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8883
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8884
    "Modified: 15.7.1996 / 12:44:21 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8885
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8886
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8887
getGroupID
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8888
    "return the current users (thats you) numeric group id"
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8889
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8890
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8891
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8892
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8893
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8894
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8895
    RETURN ( __mkSmallInteger(getgid()) );
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8896
%}.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8897
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8898
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8899
     OperatingSystem getGroupID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8900
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8901
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8902
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8903
getGroupNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8904
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8905
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8906
    "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
  8907
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8908
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8909
    struct group *g;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8910
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8911
    if (__isSmallInteger(aNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8912
	g = getgrgid(__intVal(aNumber));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8913
	if (g) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8914
	    RETURN ( __MKSTRING(g->gr_name) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  8915
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8916
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8917
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8918
    ^ '???'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8919
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8920
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8921
     OperatingSystem getGroupNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8922
     OperatingSystem getGroupNameFromID:10
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8923
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8924
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8925
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8926
getHomeDirectory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8927
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8928
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8929
    "return the name of the users home directory
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8930
     (i.e. yours)"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8931
11762
60eb1f51ffac comment
Stefan Vogel <sv@exept.de>
parents: 11626
diff changeset
  8932
    ^ self getEnvironment:'HOME'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8933
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8934
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8935
     OperatingSystem getHomeDirectory
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8936
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8937
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8938
    "Modified: 24.1.1997 / 11:32:13 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8939
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8940
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8941
getLoginName
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8942
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8943
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8944
    "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
  8945
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8946
%{  /* NOCONTEXT */
3970
22ea3856e87e egcs workaround
Claus Gittinger <cg@exept.de>
parents: 3956
diff changeset
  8947
    static char cachedName[128];
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8948
    static firstCall = 1;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8949
    extern char *getenv();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8950
    extern char *getlogin();
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8951
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8952
    char *name = (char *)0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8953
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8954
    if (firstCall) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8955
	/*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8956
	 * try a few common environment variables ...
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8957
	 */
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8958
	name = getenv("LOGNAME");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8959
	if (! name || (name[0] == 0)) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8960
	    name = getlogin();
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8961
	    if (! name || (name[0] == 0) ) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8962
		name = getenv("LOGIN");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8963
		if (! name || (name[0] == 0) ) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8964
		    name = getenv("USER");
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8965
		}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8966
	    }
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8967
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8968
	if (name && (strlen(name) < sizeof(cachedName))) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8969
	    strcpy(cachedName, name);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8970
	    firstCall = 0;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8971
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8972
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8973
	name = cachedName;
7767
1ee3973efa3a changed order getting login name in getLoginName
Michael Beyl <mb@exept.de>
parents: 7766
diff changeset
  8974
    }
1ee3973efa3a changed order getting login name in getLoginName
Michael Beyl <mb@exept.de>
parents: 7766
diff changeset
  8975
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8976
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8977
     * nope - I really font know who you are.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8978
     */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8979
    if (! name || (name[0] == 0) ) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  8980
	name = "you";
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8981
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8982
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8983
    RETURN ( __MKSTRING(name) );
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8984
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8985
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  8986
     OperatingSystem getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8987
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8988
!
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
getUserID
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8991
    "return the current users (thats you) numeric user id"
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8992
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8993
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8994
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8995
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  8996
12643
2318625acc5e changed:5 methods comments
Stefan Vogel <sv@exept.de>
parents: 12641
diff changeset
  8997
    RETURN ( __mkSmallInteger(getuid()) );
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  8998
%}
3496
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
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9001
     OperatingSystem getUserID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9002
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9003
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9004
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9005
getUserNameFromID:aNumber
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9006
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9007
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9008
    "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
  9009
     This is the login name, not the fullName."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9010
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9011
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9012
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9013
# ifndef NO_PWD
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9014
    struct passwd *p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9015
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9016
    if (__isSmallInteger(aNumber)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9017
	p = getpwuid(__intVal(aNumber));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9018
	if (p) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9019
	    RETURN ( __MKSTRING(p->pw_name) );
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9020
	}
3512
5d1c5de6b9ca removed most WIN32 and VMS stuff. Now in separate classFiles.
Claus Gittinger <cg@exept.de>
parents: 3501
diff changeset
  9021
    }
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9022
#endif /* unix-like */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9023
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9024
    aNumber == self getUserID ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9025
	^ self getLoginName
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9026
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9027
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9028
    ^ '? (' , aNumber printString , ')'
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9029
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9030
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9031
     OperatingSystem getUserNameFromID:0
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9032
     OperatingSystem getUserNameFromID:100
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9033
     OperatingSystem getUserNameFromID:9991
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9034
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9035
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9036
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9037
primUserInfoOf:aNameOrID
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9038
    "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
  9039
     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
  9040
     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
  9041
     DOS systems return nothing;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9042
     non-SYSV4 systems have no age/comment.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9043
     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
  9044
     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
  9045
     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
  9046
     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
  9047
     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
  9048
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9049
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9050
%{ /* UNLIMITEDSTACK */  /* Don't know whether NIS, LDAP or whatever is consulted */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9051
#if !defined(NO_PWD)
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9052
    struct passwd *result = 0;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9053
    int ret;
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9054
    int idx = 0;
12870
a2e6de216c3b changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12868
diff changeset
  9055
    OBJ returnArray;
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9056
    OBJ tmp;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9057
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9058
#if defined(_POSIX_SOURCE)
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9059
    char buf[4096];
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9060
    struct passwd pwd;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9061
7886
e2f993f0fbf5 LargeFile support for truncate
Stefan Vogel <sv@exept.de>
parents: 7883
diff changeset
  9062
    if (__isStringLike(aNameOrID)) {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9063
        getpwnam_r(__stringVal(aNameOrID), &pwd, buf, sizeof(buf), &result);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9064
    } else if (__isSmallInteger(aNameOrID)) {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9065
        getpwuid_r(__intVal(aNameOrID), &pwd, buf, sizeof(buf), &result);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9066
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9067
#else
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9068
    if (__isStringLike(aNameOrID)) {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9069
        result = getpwnam(__stringVal(aNameOrID));
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9070
    } else if (__isSmallInteger(aNameOrID)) {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9071
        result = getpwuid(__intVal(aNameOrID));
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9072
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9073
#endif /* ! _POSIX_SOURCE */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9074
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9075
    if (result) {
12872
db44ed6d4233 Use __ARRAY_NEW_INT() instead of __MKARRAY()
Stefan Vogel <sv@exept.de>
parents: 12871
diff changeset
  9076
        returnArray = __ARRAY_NEW_INT(20);
12870
a2e6de216c3b changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12868
diff changeset
  9077
        __PROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9078
        tmp = __MKSTRING(result->pw_name);
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9079
        __UNPROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9080
        __arrayVal(returnArray)[idx++] = @symbol(name);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9081
        __arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9082
#  ifndef NO_PWD_PASSWD
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9083
        __PROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9084
        tmp = __MKSTRING(result->pw_passwd);
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9085
        __UNPROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9086
        __arrayVal(returnArray)[idx++] = @symbol(passwd);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9087
        __arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9088
#  endif
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9089
#  ifdef SYSV4
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9090
        __PROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9091
        tmp = __MKSTRING(result->pw_age);
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9092
        __UNPROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9093
        __arrayVal(returnArray)[idx++] = @symbol(age);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9094
        __arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9095
        __PROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9096
        tmp = __MKSTRING(result->pw_comment);
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9097
        __UNPROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9098
        __arrayVal(returnArray)[idx++] = @symbol(comment);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9099
        __arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9100
#  endif
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9101
        __PROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9102
        tmp = __MKSTRING(result->pw_dir);
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9103
        __UNPROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9104
        __arrayVal(returnArray)[idx++] = @symbol(dir);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9105
        __arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9106
#  ifndef NO_PWD_GECOS
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9107
        __PROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9108
        tmp = __MKSTRING(result->pw_gecos);
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9109
        __UNPROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9110
        __arrayVal(returnArray)[idx++] = @symbol(gecos);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9111
        __arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9112
#  endif
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9113
        __PROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9114
        tmp = __MKSTRING(result->pw_shell);
12871
4b2f341b457d changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12870
diff changeset
  9115
         __UNPROTECT__(returnArray);
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9116
        __arrayVal(returnArray)[idx++] = @symbol(shell);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9117
        __arrayVal(returnArray)[idx++] = tmp; __STORE(returnArray, tmp);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9118
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9119
        __arrayVal(returnArray)[idx++] = @symbol(uid);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9120
        __arrayVal(returnArray)[idx++] = __mkSmallInteger(result->pw_uid);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9121
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9122
        __arrayVal(returnArray)[idx++] = @symbol(gid);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9123
        __arrayVal(returnArray)[idx++] = __mkSmallInteger(result->pw_gid);
12870
a2e6de216c3b changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12868
diff changeset
  9124
        RETURN(returnArray);
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9125
    }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9126
# endif /* ! NO_PWD */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9127
%}.
12870
a2e6de216c3b changed: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12868
diff changeset
  9128
    ^ nil
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9129
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9130
    "
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9131
     OperatingSystem primUserInfoOf:'root'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9132
     OperatingSystem primUserInfoOf:1
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9133
     OperatingSystem primUserInfoOf:'cg'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9134
     OperatingSystem primUserInfoOf:'fooBar'
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9135
     OperatingSystem primUserInfoOf:(OperatingSystem getUserID)
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9136
    "
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9137
!
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9138
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9139
userInfoOf:aNameOrID
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9140
    "{ Pragma: +optSpace }"
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9141
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9142
    "return a dictionary filled with userinfo. The argument can be either
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9143
     a string with the users name or its numeric id.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9144
     Notice, that not all systems provide (all of) this info;
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9145
     DOS systems return nothing;
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9146
     non-SYSV4 systems have no age/comment.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9147
     Portable applications may want to check the systemType and NOT depend
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9148
     on all keys to be present in the returned dictionary.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9149
     Another notice: on some systems (SYSV4), the gecos field includes multiple
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9150
     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
  9151
     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
  9152
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9153
    |infoArray info name dir|
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9154
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9155
    infoArray := self primUserInfoOf:aNameOrID.
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9156
    info := IdentityDictionary new.
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9157
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9158
    infoArray notNil ifTrue:[    
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9159
        infoArray pairWiseDo:[:key :value|
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9160
            key notNil ifTrue:[
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9161
                info at:key put:value.
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9162
                key == #name ifTrue:[name := value].
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9163
                key == #dir  ifTrue:[dir := value].
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9164
            ].
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9165
        ].
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9166
    ].
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9167
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9168
    name isNil ifTrue:[
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9169
        info at:#name put:#unknown
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9170
    ].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9171
    dir isNil ifTrue:[
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9172
        aNameOrID == self getUserID ifTrue:[
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9173
            info at:#dir put:self getHomeDirectory
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9174
        ]
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9175
    ].
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
  9176
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9177
    ^ info
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9178
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9179
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9180
     OperatingSystem userInfoOf:'root'
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9181
     OperatingSystem userInfoOf:1
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
  9182
     OperatingSystem userInfoOf:'cg'
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9183
     OperatingSystem userInfoOf:'fooBar'
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9184
     OperatingSystem userInfoOf:(OperatingSystem getUserID)
3496
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
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9187
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9188
!UnixOperatingSystem class methodsFor:'waiting for events'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9189
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9190
blockingChildProcessWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9191
     "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
  9192
      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
  9193
      a subprocesses status (to avoid blocking)."
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9194
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9195
%{ /*NOCONTEXT*/
3780
7d735472f937 removed some WIN32 stuff
Claus Gittinger <cg@exept.de>
parents: 3773
diff changeset
  9196
#if defined(HAS_WAITPID) || defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9197
    RETURN(false);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9198
#else
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9199
    RETURN(true);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9200
#endif
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
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9204
childProcessWait:blocking pid:pidToWait
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9205
    "{ Pragma: +optSpace }"
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
    "get status changes from child processes.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9208
     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
  9209
     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
  9210
     otherwise we return immediately.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9211
     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
  9212
     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
  9213
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9214
    |pid status code core|
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9215
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9216
    int p;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9217
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9218
#if defined(HAS_WAITPID)
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
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9221
#   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
  9222
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9223
#else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9224
# if defined(HAS_WAIT3)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9225
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9226
    union wait s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9227
#   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
  9228
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9229
# 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
  9230
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9231
    int s;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9232
#   define __WAIT      wait(&s)
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9233
#   define __BLOCKING_WAIT__ 1
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
    if (blocking != true) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9236
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9237
	 * We do not support nonBlocking waits, so signal an error
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9238
	 * Sorry about the goto, but with all these ifdefs ...
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9239
	 */
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9240
	goto done;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9241
    }
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9242
# endif /*!HAS_WAIT3*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9243
#endif  /*!HAS_WAITPID*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9244
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9245
#if !defined(WIFEXITED)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9246
# define WIFEXITED(stat)      (((int)((stat)&0377))==0)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9247
# 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
  9248
# 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
  9249
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9250
# define WEXITSTATUS(stat)    ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9251
# define WTERMSIG(stat)       (((int)((stat)&0377))&0177)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9252
# define WSTOPSIG(stat)       ((int)(((stat)>>8)&0377))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9253
#endif /*!WIFEXITED*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9254
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9255
#if !defined(WCOREDUMP)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9256
   /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9257
    * 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
  9258
    */
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9259
# if defined(HAS_WAIT3)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9260
#  define WCOREDUMP(status)    (((union __wait*)&(status))->__w_coredump)
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9261
# else
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9262
#  define WCOREDUMP(status)    ((int)(((status)>>8)&0200))
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9263
# endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9264
#endif /*!WCOREDUMP*/
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9265
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9266
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9267
    __BEGIN_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9268
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9269
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9270
    do {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9271
	p = __WAIT;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9272
    } while (p == -1 && errno == EINTR);
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9273
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9274
#if __BLOCKING_WAIT__
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9275
    __END_INTERRUPTABLE__
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9276
#  undef __BLOCKING_WAIT__
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9277
#endif
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9278
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9279
#undef __WAIT
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9280
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9281
    if (p == 0)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9282
	RETURN(nil)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9283
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9284
    if (p == -1) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9285
	if (errno == ECHILD)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9286
	    RETURN(nil);
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9287
    } else {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9288
	pid = __mkSmallInteger(p);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9289
	if (WIFEXITED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9290
	    status = @symbol(exit);
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9291
	    code = __mkSmallInteger(WEXITSTATUS(s));
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9292
	    core = WCOREDUMP(s) ? true : false;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9293
	} else if (WIFSIGNALED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9294
	    status = @symbol(signal);
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9295
	    code = __mkSmallInteger(WTERMSIG(s));
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9296
	} else if (WIFSTOPPED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9297
	    status = @symbol(stop);
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9298
	    code = __mkSmallInteger(WSTOPSIG(s));
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9299
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9300
#if defined(WIFCONTINUED)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9301
	else if (WIFCONTINUED(s)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9302
	    status = @symbol(continue);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9303
	}
3930
22edc626ba1b removed VMS stuff
Claus Gittinger <cg@exept.de>
parents: 3928
diff changeset
  9304
#endif
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9305
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9306
done: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9307
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9308
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9309
    (status isNil or:[pid isNil]) ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9310
	^ self primitiveFailed
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9311
    ].
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
"/ 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
  9314
"/ show:' code: '; show:code; show:' core:'; showCR:core.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9315
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9316
    ^ 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
  9317
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9318
    "
3795
fbdfe2dd4e77 comments
Claus Gittinger <cg@exept.de>
parents: 3793
diff changeset
  9319
     OperatingSystem childProcessWait:false
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9320
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9321
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9322
    "Created: 5.1.1996 / 16:39:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9323
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9324
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9325
isBlockingOn:fd
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9326
    "{ Pragma: +optSpace }"
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9327
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9328
    "return the blocking attribute - if set (which is the default)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9329
     a read on the fileDescriptor will block until data is available.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9330
     If clear, a read operation will immediately return with a value nil.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9331
     Also affects write operations, which may perform partial writes when
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9332
     blocking is off"
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9333
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9334
%{  /* NOCONTEXT */
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9335
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9336
    int flags;
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9337
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9338
#if defined(F_GETFL) && defined(F_SETFL)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9339
# undef DELAY_FLAG
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9340
# if defined(O_NONBLOCK)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9341
#  define DELAY_FLAG O_NONBLOCK
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9342
# elif defined(O_NDELAY)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9343
#  define DELAY_FLAG O_NDELAY
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9344
# elif defined(FNDELAY)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9345
#  define DELAY_FLAG FNDELAY
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9346
# endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9347
# if defined(DELAY_FLAG)
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9348
    if (__isSmallInteger(fd)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9349
	int f = __intVal(fd);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9350
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9351
	flags = fcntl(f, F_GETFL, 0);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9352
	RETURN ((flags & DELAY_FLAG) ? false : true );
7802
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9353
    }
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9354
#  undef DELAY_FLAG
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9355
# endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9356
#endif
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9357
%}.
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9358
    "
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9359
     fd argument not integer or bad return code
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9360
    "
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9361
    ^ self primitiveFailed
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9362
!
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9363
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9364
numAvailableForReadOn:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9365
    "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
  9366
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9367
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9368
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9369
     * 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
  9370
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9371
# if 0 && defined(FIONREAD)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9372
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9373
	int n;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9374
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9375
	if (__isSmallInteger(fd)) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9376
	    if (ioctl(__intVal(fd), FIONREAD, &n) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9377
		RETURN (__MKINT(n));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9378
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9379
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9380
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9381
# endif /* FIONREAD */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9382
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9383
    ^ (self readCheck:fd) ifTrue:[1] ifFalse:[0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9384
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9385
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9386
readCheck:fd
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9387
    "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
  9388
     (i.e. read is possible without blocking).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9389
     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
  9390
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9391
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9392
    /*
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9393
     * 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
  9394
     */
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9395
#if 0 && defined(FIONREAD)
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
  9396
    if (__isSmallInteger(fd)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9397
	int result = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9398
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9399
	if (ioctl(__smallIntegerVal(fd), FIONREAD, &result) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9400
	    RETURN(result > 0 ? true : false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9401
	}
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9402
    }
6352
3d59cdc05365 Disable FIONREAD for now (pure superstition).
Stefan Vogel <sv@exept.de>
parents: 6350
diff changeset
  9403
#endif /* FIONREAD */
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9404
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9405
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9406
    ^ super readCheck:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9407
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9408
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9409
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9410
	readableInto:readableResultFdArray writableInto:writableResultFdArray
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9411
	exceptionInto:exceptionResultFdArray
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9412
	withTimeOut:millis
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9413
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9414
    "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
  9415
     writeFdArray to become ready for writing,
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9416
     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
  9417
     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
  9418
     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
  9419
     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
  9420
     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
  9421
     writableResultFdArray and exceptionResultFdArray respectively.
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9422
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9423
     Return the (overall) number of selected filedescriptors.
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9424
     readableResultFdArray, writableResultFdArray and exceptionResultFdArray will
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9425
     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
  9426
     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
  9427
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9428
%{
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9429
    fd_set rset, wset, eset;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9430
    struct timeval wt, et;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9431
    int maxF;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9432
    INT t;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9433
    int ret;
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9434
    int cntR = 0, cntW = 0, cntE = 0;
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9435
    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
  9436
    int numFds = 0;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9437
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9438
    if (!__isSmallInteger(millis)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9439
	goto fail;
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9440
    }
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9441
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9442
    if (readableResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9443
	if (! __isArrayLike(readableResultFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9444
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9445
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9446
	resultSizeReadable = __arraySize(readableResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9447
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9448
    if (writableResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9449
	if (! __isArrayLike(writableResultFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9450
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9451
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9452
	resultSizeWritable = __arraySize(writableResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9453
    }
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9454
    if (exceptionResultFdArray != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9455
	if (! __isArrayLike(exceptionResultFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9456
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9457
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9458
	resultSizeException = __arraySize(exceptionResultFdArray);
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9459
    }
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9460
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9461
    FD_ZERO(&rset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9462
    FD_ZERO(&wset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9463
    FD_ZERO(&eset);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9464
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9465
    maxF = -1;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9466
    if (__isNonNilObject(readFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9467
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9468
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9469
	if (! __isArrayLike(readFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9470
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9471
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9472
	count = __arraySize(readFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9473
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9474
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9475
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9476
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9477
	    fd = __ArrayInstPtr(readFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9478
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9479
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9480
		    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9481
			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
  9482
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9483
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9484
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9485
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9486
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9487
		    if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9488
			FD_SET(f, &rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9489
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9490
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9491
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9492
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9493
			    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
  9494
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9495
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9496
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9497
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9498
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9499
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9500
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9501
    if (__isNonNilObject(writeFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9502
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9503
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9504
	if (! __isArrayLike(writeFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9505
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9506
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9507
	count = __arraySize(writeFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9508
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9509
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9510
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9511
	    fd = __ArrayInstPtr(writeFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9512
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9513
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9514
		    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9515
			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
  9516
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9517
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9518
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9519
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9520
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9521
		    if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9522
			FD_SET(f, &wset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9523
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9524
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9525
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9526
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9527
			    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
  9528
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9529
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9530
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9531
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9532
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9533
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9534
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9535
    if (__isNonNilObject(exceptFdArray)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9536
	int i, count;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9537
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9538
	if (! __isArrayLike(exceptFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9539
	    goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9540
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9541
	count = __arraySize(exceptFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9542
	for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9543
	    OBJ fd;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9544
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9545
	    fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9546
	    if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9547
		if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9548
		    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9549
			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
  9550
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9551
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9552
		    int f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9553
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9554
		    f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9555
		    if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9556
			FD_SET(f, &eset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9557
			if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9558
			numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9559
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9560
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9561
			    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
  9562
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9563
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9564
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9565
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9566
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9567
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9568
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9569
    t = __intVal(millis);
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9570
    if (t) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9571
	wt.tv_sec = t / 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9572
	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
  9573
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9574
	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
  9575
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9576
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9577
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9578
     * 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
  9579
     * 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
  9580
     */
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9581
    __BEGIN_INTERRUPTABLE__
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9582
    errno = 0;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9583
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9584
    if (t == 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9585
	/*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9586
	 * if there is no timeout time, we can stay here interruptable.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9587
	 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9588
	do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9589
	    ret = select(maxF+1, &rset, &wset, &eset, &wt);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9590
	} 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
  9591
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9592
	do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9593
	    ret = select(maxF+1, &rset, &wset, &eset, &wt);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9594
	    /*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9595
	     * 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
  9596
	     * could otherwise stay in this loop forever ...
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9597
	     * 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
  9598
	     * 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
  9599
	     */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9600
	} 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
  9601
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9602
    __END_INTERRUPTABLE__
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9603
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9604
    if (ret > 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9605
	OBJ *__resultR = __arrayVal(readableResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9606
	OBJ *__resultW = __arrayVal(writableResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9607
	OBJ *__resultE = __arrayVal(exceptionResultFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9608
	int i;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9609
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9610
	for (i=0; i <= maxF; i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9611
	    if (FD_ISSET(i, &rset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9612
		if (cntR < resultSizeReadable) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9613
		    __resultR[cntR] = __mkSmallInteger(i);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9614
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9615
		cntR++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9616
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9617
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9618
	    if (FD_ISSET(i, &wset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9619
		if (cntW < resultSizeWritable) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9620
		    __resultW[cntW] = __mkSmallInteger(i);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9621
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9622
		cntW++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9623
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9624
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9625
	    if (FD_ISSET(i, &eset)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9626
		if (cntE < resultSizeException) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9627
		    __resultE[cntE] = __mkSmallInteger(i);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9628
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9629
		cntE++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9630
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9631
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9632
	/* add a delimiter */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9633
	if (cntR < resultSizeReadable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9634
	    __resultR[cntR] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9635
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9636
	if (cntW < resultSizeWritable) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9637
	    __resultW[cntW] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9638
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9639
	if (cntE < resultSizeException) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9640
	    __resultE[cntE] = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9641
	}
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9642
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9643
	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
  9644
    } else {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9645
	if (ret < 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9646
	    if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9647
		errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9648
		@global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9649
	    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9650
		if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9651
		    fprintf(stderr, "OS [info]: select errno = %d\n", errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9652
		}
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9653
		@global(LastErrorNumber) = __mkSmallInteger(errno);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9654
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9655
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9656
	    @global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9657
	}
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9658
    }
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9659
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9660
    /*
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9661
     * Return 0 (no filedescriptor ready)
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9662
     */
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9663
    RETURN (__mkSmallInteger(0));
7494
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9664
fail: ;
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9665
%}.
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9666
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9667
     timeout argument not integer,
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9668
     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
  9669
     or not supported by OS
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9670
    "
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9671
    ^ self primitiveFailed
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9672
!
2dd5a54c22ed New select for fair scheduling (not giving low filedescriptors
Stefan Vogel <sv@exept.de>
parents: 7465
diff changeset
  9673
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9674
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray withTimeOut:millis
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9675
    "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
  9676
     writeFdArray to become ready for writing,
7510
46a848d466b5 select: wake up readFDs if readable only;
Claus Gittinger <cg@exept.de>
parents: 7509
diff changeset
  9677
     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
  9678
     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
  9679
     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
  9680
     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
  9681
     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
  9682
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9683
%{
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9684
    fd_set rset, wset, eset;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9685
    struct timeval wt, et;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9686
    int f, maxF, i, lX, bX;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9687
    INT t;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9688
    OBJ fd, retFd;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9689
    int ret;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9690
    int count;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9691
    int numFds = 0;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9692
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9693
    if (__isSmallInteger(millis)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9694
	FD_ZERO(&rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9695
	FD_ZERO(&wset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9696
	FD_ZERO(&eset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9697
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9698
	maxF = -1;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9699
	if (__isNonNilObject(readFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9700
	    if (! __isArrayLike(readFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9701
		goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9702
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9703
	    count = __arraySize(readFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9704
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9705
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9706
		fd = __ArrayInstPtr(readFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9707
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9708
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9709
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9710
			    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
  9711
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9712
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9713
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9714
			if ((unsigned)f < FD_SETSIZE) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9715
			    FD_SET(f, &rset);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9716
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9717
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9718
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9719
			    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9720
				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
  9721
			    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9722
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9723
		    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9724
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9725
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9726
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9727
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9728
	if (__isNonNilObject(writeFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9729
	    if (! __isArrayLike(writeFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9730
		goto fail;
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9731
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9732
	    count = __arraySize(writeFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9733
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9734
		fd = __ArrayInstPtr(writeFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9735
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9736
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9737
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9738
			    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
  9739
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9740
		    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9741
			f = __intVal(fd);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9742
			if ((unsigned)f < FD_SETSIZE) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9743
			    FD_SET(f, &wset);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9744
			    if (f > maxF) maxF = f;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9745
			    numFds++;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9746
			} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9747
			    if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9748
				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
  9749
			    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9750
			}
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
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9753
	    }
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
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9756
	if (__isNonNilObject(exceptFdArray)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9757
	    if (! __isArrayLike(exceptFdArray)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9758
		goto fail;
7515
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
	    count = __arraySize(exceptFdArray);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9761
	    for (i=0; i<count;i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9762
		fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9763
		if (fd != nil) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9764
		    if (! __isSmallInteger(fd)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9765
			if (@global(InfoPrinting) == true) {
12833
e97fa81621d6 Fix printf argument types
Stefan Vogel <sv@exept.de>
parents: 12832
diff changeset
  9766
			    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
  9767
			}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9768
		    } else {
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) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9771
			    FD_SET(f, &eset);
7515
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 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
  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
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9782
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9783
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9784
	t = __intVal(millis);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9785
	if (t) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9786
	    wt.tv_sec = t / 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9787
	    wt.tv_usec = (t % 1000) * 1000;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9788
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9789
	    wt.tv_sec = wt.tv_usec = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9790
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9791
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9792
	/*
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9793
	 * make certain, that interrupt gets us out of the select
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9794
	 * However, we must then care for moved objects.
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9795
	 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9796
	__BEGIN_INTERRUPTABLE__
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9797
	errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9798
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9799
	if (t == 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9800
	    /*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9801
	     * if there is no timeout time, we can stay here interruptable.
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
	    do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9804
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9805
	    } while ((ret < 0) && (errno == EINTR));
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9806
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9807
	    do {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9808
		ret = select(maxF+1, &rset, &wset, &eset, &wt);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9809
		/*
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9810
		 * 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
  9811
		 * could otherwise stay in this loop forever ...
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9812
		 * 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
  9813
		 * 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
  9814
		 */
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9815
	    } while (0 /* (ret < 0) && (errno == EINTR) */ );
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9816
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9817
	__END_INTERRUPTABLE__
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9818
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9819
	if (ret > 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9820
	    for (i=0; i <= maxF; i++) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9821
		if (FD_ISSET(i, &rset)
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9822
		 || FD_ISSET(i, &wset)
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9823
		 || FD_ISSET(i, &eset)) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9824
		    RETURN ( __mkSmallInteger(i) );
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9825
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9826
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9827
	} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9828
	    if (ret < 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9829
		if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9830
		    errno = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9831
		    @global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9832
		} else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9833
		    if (@global(InfoPrinting) == true) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9834
			fprintf(stderr, "OS [info]: select errno = %d\n", errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9835
		    }
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
  9836
		    @global(LastErrorNumber) = __mkSmallInteger(errno);
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9837
		}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9838
	    } else {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9839
		@global(LastErrorNumber) = nil;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9840
	    }
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9841
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9842
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9843
	/*
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
  9844
	 * Return nil (means time expired or interrupted)
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
	RETURN ( nil );
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9847
    }
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9848
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9849
fail: ;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9850
%}.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9851
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9852
     timeout argument not integer,
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9853
     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
  9854
     or not supported by OS
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9855
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9856
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9857
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9858
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9859
setBlocking:aBoolean on:fd
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9860
    "{ Pragma: +optSpace }"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9861
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9862
    "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
  9863
     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
  9864
     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
  9865
     Also affects write operations, which may perform partial writes when
79bda5b10e90 comments;
Claus Gittinger <cg@exept.de>
parents: 7790
diff changeset
  9866
     blocking is off.
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  9867
     Return the previous blocking state."
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9868
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9869
%{  /* NOCONTEXT */
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9870
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  9871
    int ret = 0, flags;
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9872
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9873
#if defined(F_GETFL) && defined(F_SETFL)
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9874
# undef DELAY_FLAG
7732
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  9875
# if defined(O_NONBLOCK)
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  9876
#  define DELAY_FLAG O_NONBLOCK
2f588f8c8c91 #setBlocking:on: with nil arg and O_NONBLOCK.
Stefan Vogel <sv@exept.de>
parents: 7709
diff changeset
  9877
# elif defined(O_NDELAY)
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9878
#  define DELAY_FLAG O_NDELAY
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9879
# elif defined(FNDELAY)
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9880
#  define DELAY_FLAG FNDELAY
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9881
# endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9882
# if defined(DELAY_FLAG)
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9883
    if (__isSmallInteger(fd)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9884
	int f = __intVal(fd);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9885
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9886
	flags = fcntl(f, F_GETFL, 0);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9887
	if (aBoolean == true) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9888
	    ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9889
	} else if (aBoolean == false) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9890
	    ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9891
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9892
	if (ret >= 0) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9893
	    RETURN ((flags & DELAY_FLAG) ? false : true );
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9894
	}
7500
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9895
    }
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9896
#  undef DELAY_FLAG
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9897
# endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9898
#endif
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9899
%}.
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9900
    "
e4fbe86c7341 ExternalStream>>blocking: returns previous blocking status
Stefan Vogel <sv@exept.de>
parents: 7494
diff changeset
  9901
     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
  9902
    "
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9903
    ^ self primitiveFailed
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9904
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  9905
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9906
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'change & update'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9907
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9908
update:aspect with:argument from:anObject
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9909
    "one of our registered handles has been collected"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9910
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9911
    aspect == #ElementExpired ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9912
	OpenFiles keysAndValuesDo:[:fd :handle |
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9913
	    handle == 0 ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9914
		"Have to close the file descriptor"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9915
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9916
		OperatingSystem closeFd:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9917
		OpenFiles at:fd put:nil.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9918
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
  9919
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9920
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9921
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9922
    "Created: 30.9.1997 / 12:57:35 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9923
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9924
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9925
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9926
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9927
initialize
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9928
     OpenFiles := WeakArray new:10.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
  9929
     OpenFiles addDependent:self.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9930
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9931
     "self initialize"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9932
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9933
    "Created: 26.9.1997 / 17:15:50 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9934
    "Modified: 30.9.1997 / 12:40:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9935
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9936
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9937
!UnixOperatingSystem::FileDescriptorHandle class methodsFor:'instance creation'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9938
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9939
for:aFileDescriptor
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9940
    "create an instance of myself for a given fileDescriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9941
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9942
    ^ self new for:aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9943
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9944
    "Created: 30.9.1997 / 14:00:00 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9945
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9946
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9947
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'error handling'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9948
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9949
error:anErrorSymbolOrErrno
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9950
    "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
  9951
     or the error number as returned by the OperatingSystem"
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9952
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9953
    anErrorSymbolOrErrno isInteger ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9954
	(UnixOperatingSystem errorHolderForNumber:anErrorSymbolOrErrno) reportError
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9955
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
  9956
    self primitiveFailed:anErrorSymbolOrErrno.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9957
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9958
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9959
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'file access'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9960
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9961
close
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9962
    "close the descriptor"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9963
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9964
    |desc|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9965
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9966
    desc := fd.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9967
    self invalidate.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9968
    ^ OperatingSystem closeFd:desc.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9969
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9970
    "Modified: 30.9.1997 / 13:06:55 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9971
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9972
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9973
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'initialization'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9974
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9975
for:aFileDescriptor
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9976
    "create a file for a handle"
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9977
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9978
    |oldHandle|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9979
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9980
    fd := aFileDescriptor.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9981
    oldHandle := OpenFiles at:aFileDescriptor.
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
  9982
    "/ 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
  9983
    "/ 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
  9984
    (oldHandle notNil and:[oldHandle ~~ 0 and:[ oldHandle ~~ self]]) ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
  9985
	oldHandle invalidate.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9986
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9987
    self register.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9988
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9989
    "Created: 26.9.1997 / 17:14:40 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9990
    "Modified: 30.9.1997 / 12:41:43 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9991
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9992
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9993
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'input/output'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9994
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9995
readBytes:count into:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
  9996
    "read count bytes into a byte-buffer;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9997
     Return the number of bytes read.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9998
     The read is non-blocking. If the operation would block
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
  9999
     either an incomplete count or nil will be returned.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10000
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10001
     An exception is raised on any other error"
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10002
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10003
    |error|
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10004
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10005
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10006
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10007
    int nRead = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10008
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10009
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10010
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10011
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10012
    if (! __isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10013
	error = @symbol(errorNotOpen);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10014
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10015
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10016
    if (! __bothSmallInteger(count, firstIndex)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10017
	error = @symbol(badArgument);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10018
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10019
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10020
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10021
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10022
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10023
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10024
    if (fd < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10025
	error = @symbol(internalError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10026
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 10027
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 10028
    if (__isExternalBytesLike(aByteBuffer)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10029
	OBJ sz;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10030
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10031
	nInstBytes = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10032
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10033
	sz = __externalBytesSize(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10034
	if (__isSmallInteger(sz)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10035
	    objSize = __smallIntegerVal(sz);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10036
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10037
	    objSize = -1; /* unknown */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10038
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10039
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10040
	OBJ oClass;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10041
	int nInstVars;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10042
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10043
	oClass = __Class(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10044
	switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10045
	    case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10046
	    case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10047
	    case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10048
	    case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10049
	    case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10050
	    case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10051
	    case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10052
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10053
	    default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10054
		error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10055
		goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10056
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10057
	extPtr = (char *)0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10058
	nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10059
	nInstBytes = __OBJS2BYTES__(nInstVars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10060
	objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10061
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10062
    if ((offs >= 0)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10063
	&& (cnt >= 0)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10064
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10065
	nRead = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10066
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10067
	do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10068
	    int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10069
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10070
	    if (extPtr) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10071
		n = read(fd, extPtr+offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10072
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10073
		char *bp;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10074
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10075
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10076
		 * on interrupt, anObject may be moved to another location.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10077
		 * So we recompute the byte-address here.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10078
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10079
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10080
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10081
		n = read(fd, bp + offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10082
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10083
	    if (n > 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10084
		cnt -= n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10085
		offs += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10086
		nRead += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10087
	    } else if (n == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10088
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10089
	    } else if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10090
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10091
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10092
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10093
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10094
#ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10095
		    || errno == EAGAIN
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10096
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10097
		) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10098
		     RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10099
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10100
		if (errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10101
		     error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10102
		     goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10103
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10104
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10105
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10106
	} while (cnt > 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10107
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10108
	RETURN (__mkSmallInteger(nRead));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10109
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10110
bad: ;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10111
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10112
    ^ self error:error.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10113
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10114
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10115
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10116
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10117
     h := OperatingSystem openFileForRead:'/etc/hosts'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10118
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10119
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10120
     Transcript show:n; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10121
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10122
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10123
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10124
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10125
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10126
     h := OperatingSystem openFileForRead:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10127
     buff := ByteArray new:1000. buff inspect.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10128
     n := h readBytes:1000 into:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10129
     Transcript show:n printString; space; showCR:buff asString.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10130
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10131
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10132
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10133
writeBytes:count from:aByteBuffer startingAt:firstIndex
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10134
    "write count bytes from a byte-buffer;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10135
     Return the number of bytes written (negative on error)"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10136
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10137
    |error|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10138
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10139
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10140
    unsigned char *extPtr;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10141
    int nWritten = -1;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10142
    INT fd;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10143
    INT cnt, offs;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10144
    int nInstBytes, objSize;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10145
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10146
    if (! __isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10147
	error = @symbol(errorNotOpen);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10148
	goto bad;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10149
    }
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10150
    if (! __bothSmallInteger(count, firstIndex)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10151
	error = @symbol(badArgument);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10152
	goto bad;
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10153
    }
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10154
    fd = __smallIntegerVal(__INST(fd));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10155
    cnt = __smallIntegerVal(count);
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10156
    offs = __smallIntegerVal(firstIndex) - 1;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10157
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10158
    if (fd < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10159
	error = @symbol(internalError);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10160
	goto bad;
7198
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 10161
    }
62450598d208 also handle subclasses of ExternalBytes (Mapped..)
Claus Gittinger <cg@exept.de>
parents: 7185
diff changeset
 10162
    if (__isExternalBytesLike(aByteBuffer)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10163
	OBJ sz;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10164
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10165
	nInstBytes = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10166
	extPtr = (char *)(__externalBytesAddress(aByteBuffer));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10167
	sz = __externalBytesSize(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10168
	if (__isSmallInteger(sz)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10169
	    objSize = __smallIntegerVal(sz);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10170
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10171
	    objSize = -1; /* unknown */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10172
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10173
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10174
	OBJ oClass;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10175
	int nInstVars;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10176
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10177
	oClass = __Class(aByteBuffer);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10178
	switch (__smallIntegerVal(__ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10179
	    case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10180
	    case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10181
	    case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10182
	    case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10183
	    case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10184
	    case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10185
	    case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10186
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10187
	    default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10188
		error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10189
		goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10190
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10191
	extPtr = (char *)0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10192
	nInstVars = __smallIntegerVal(__ClassInstPtr(oClass)->c_ninstvars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10193
	nInstBytes = __OBJS2BYTES__(nInstVars);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10194
	objSize = __Size(aByteBuffer) - OHDR_SIZE - nInstBytes;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10195
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10196
    if ((offs >= 0)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10197
	&& (cnt >= 0)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10198
	&& ((objSize == -1) || (objSize >= (cnt + offs)))) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10199
	nWritten = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10200
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10201
	do {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10202
	    int n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10203
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10204
	    if (extPtr) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10205
		n = write(fd, extPtr+offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10206
	    } else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10207
		char *bp;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10208
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10209
		/*
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10210
		 * on interrupt, anObject may be moved to another location.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10211
		 * So we recompute the byte-address here.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10212
		 */
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10213
		bp = __byteArrayVal(aByteBuffer) + nInstBytes;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10214
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10215
		n = write(fd, bp + offs, cnt);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10216
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10217
	    if (n > 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10218
		cnt -= n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10219
		offs += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10220
		nWritten += n;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10221
	    } else if (n == 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10222
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10223
	    } else if (n < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10224
		if (0
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10225
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10226
		    || errno == EWOULDBLOCK
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10227
#endif
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10228
#ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10229
		    || errno == EAGAIN
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10230
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10231
		) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10232
		     RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10233
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10234
		if (errno != EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10235
		     error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10236
		     goto bad;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10237
		}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10238
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10239
	    }
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10240
	} while (cnt > 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10241
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10242
	RETURN (__mkSmallInteger(nWritten));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10243
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10244
bad: ;
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10245
%}.
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10246
    ^ self error:error
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10247
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
     |h buff n|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10250
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10251
     h := OperatingSystem createFileForReadWrite:'/tmp/xx'.
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10252
     buff := '12345678901234567890'.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10253
     n := h writeBytes:10 from:buff startingAt:1.
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
6306
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10256
    "
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10257
     |h buff n|
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10258
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10259
     h := OperatingSystem createFileForReadWrite:'/dev/cua0'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10260
     buff := '12345678901234567890'.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10261
     n := h writeBytes:10 from:buff startingAt:1.
0e4cc1ce9245 More FileDescriptorHandle stuff
Stefan Vogel <sv@exept.de>
parents: 6301
diff changeset
 10262
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10263
! !
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
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'misc functions'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10266
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10267
nextError
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10268
    "retrieve the pending error from the current fileDescriptor
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10269
     and raise an error exception.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10270
     This should be only called, when an error is pending.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10271
     Otherwise a byte may be lost"
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10272
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10273
    |dummyByte|
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10274
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10275
    dummyByte := ByteArray new:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10276
    ^ self readBytes:1 into:dummyByte startingAt:1.
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10277
!
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 10278
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10279
seekTo:newPosition from:whence
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10280
    "seek to newPosition
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10281
     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
 10282
     Return the new position."
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10283
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10284
    |error|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10285
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10286
%{
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10287
    INT fd;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10288
    INT __whence;
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10289
    off_t pos, ret;
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10290
    OBJ rslt;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10291
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10292
    if (! __isSmallInteger(__INST(fd))) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10293
	error = @symbol(errorNotOpen);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10294
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10295
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10296
    if (__isSmallInteger(newPosition)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10297
	pos = __smallIntegerVal(newPosition);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10298
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10299
	pos = __signedLongIntVal(newPosition);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10300
	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
 10301
	    error = @symbol(badArgument1);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10302
	    goto bad;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10303
	}
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10304
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10305
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10306
    fd = __smallIntegerVal(__INST(fd));
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10307
    if (fd < 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10308
	error = @symbol(internalError);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10309
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10310
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10311
    if (whence == @symbol(begin)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10312
	__whence = SEEK_SET;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10313
    } else if (whence == @symbol(current)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10314
	__whence = SEEK_CUR;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10315
    } else if (whence == @symbol(end)) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10316
	__whence = SEEK_END;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10317
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10318
	error = @symbol(badArgument2);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10319
	goto bad;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10320
    }
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10321
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10322
again:
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10323
    ret = lseek(fd, pos, __whence);
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10324
    if (ret < 0) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10325
	if (errno == EINTR) {
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10326
	    __HANDLE_INTERRUPTS__;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10327
	    goto again;
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10328
	}
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10329
	error = __mkSmallInteger(errno);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10330
	goto bad;
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10331
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10332
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10333
    if (sizeof(ret) == 8) {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10334
	rslt = __MKINT64 (&ret);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10335
    } else {
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10336
	rslt = __MKINT(ret);
7883
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10337
    }
1039acd0624b Large file support (off_t with 64 bits) for UNIX
Stefan Vogel <sv@exept.de>
parents: 7873
diff changeset
 10338
    RETURN (rslt);
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10339
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10340
bad: ;
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10341
%}.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10342
    ^ self error:error.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10343
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10344
    "
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10345
     |h buff n|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10346
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10347
     h := OperatingSystem openFileForRead:'/etc/hosts'.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10348
     h seekTo:10 from:#begin.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10349
     buff := ByteArray new:1000. buff inspect.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10350
     n := h readBytes:1000 into:buff startingAt:1.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10351
     Transcript show:n; space; showCR:buff asString.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10352
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10353
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10354
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10355
selectWithTimeOut:millis
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10356
    "wait for aFileDesriptor to become ready; timeout after t milliseconds.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10357
     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
 10358
     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
 10359
     of read-data.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10360
     Experimental."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10361
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10362
    ^ OperatingSystem selectOnAnyReadable:(Array with:fd)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10363
		      writable:(Array with:fd)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10364
		     exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10365
		   withTimeOut:millis
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10366
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10367
    "Created: 1.10.1997 / 08:51:11 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10368
!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10369
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10370
setBlocking:aBoolean
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10371
    "{ Pragma: +optSpace }"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10372
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10373
    "set/clear the blocking attribute - if set (which is the default)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10374
     a read on the fileDescriptor will block until data is available.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10375
     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
 10376
     nil if no data is available."
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10377
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10378
    |err|
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10379
%{
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10380
    int ret, flags;
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10381
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10382
#if defined(F_GETFL) && defined(F_SETFL)
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10383
# if defined(O_NDELAY)
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10384
#  define DELAY_FLAG O_NDELAY
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10385
# else
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10386
#  if defined(FNDELAY)
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10387
#   define DELAY_FLAG FNDELAY
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10388
#  endif
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10389
# endif
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10390
# if defined(DELAY_FLAG)
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10391
    if (__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10392
	int f = __intVal(__INST(fd));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10393
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10394
	flags = fcntl(f, F_GETFL, 0);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10395
	if (aBoolean == true) {
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10396
	    ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10397
	} else {
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10398
	    ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10399
	}
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10400
	if (ret >= 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 10401
	    RETURN(__mkSmallInteger(flags));
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10402
	} else {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 10403
	    err = __mkSmallInteger(errno);
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10404
	}
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10405
    }
8705
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10406
# undef DELAY_FLAG
fad08dd9cec5 mac changes
Claus Gittinger <cg@exept.de>
parents: 8672
diff changeset
 10407
# endif /* DELAY_FLAG */
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10408
#endif
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10409
%}.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10410
    err notNil ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10411
	self error:err
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10412
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10413
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10414
     fd argument not integer
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10415
    "
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10416
    ^ self primitiveFailed
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10417
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10418
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10419
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10420
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 10421
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'private-accessing'!
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10422
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10423
fileDescriptor
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10424
    "return the (integer) fileDescriptor"
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10425
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10426
%{
7462
05b5202d988a Fix compiler warning
Stefan Vogel <sv@exept.de>
parents: 7461
diff changeset
 10427
    OBJ handle = __externalAddressVal(self);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10428
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10429
    if (__isSmallInteger(handle)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 10430
	RETURN (handle);
7185
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10431
    }
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10432
%}.
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10433
    ^ nil
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10434
!
0a3ba41f0d31 care for released fd (0) in OpenFiles-WeakArray.
penk
parents: 7175
diff changeset
 10435
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10436
setFileDescriptor:anInteger
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10437
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10438
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10439
    if (__isSmallInteger(anInteger)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10440
	__externalAddressVal(self) = (OBJ)(__smallIntegerVal(anInteger));
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10441
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10442
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10443
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10444
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10445
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10446
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10447
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'queries'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10448
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10449
canReadWithoutBlocking
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10450
    "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
 10451
     (i.e. read is possible without blocking).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10452
     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
 10453
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10454
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10455
    int fd;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10456
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10457
    if (__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10458
	fd = __smallIntegerVal(__INST(fd));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10459
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10460
	/*
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10461
	 * if available, try FIONREAD first, which is usually done faster.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10462
	 */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10463
# ifdef FIONREAD
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10464
	{
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10465
	    int result = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10466
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10467
	    if (ioctl(fd, FIONREAD, &result) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10468
		RETURN(result > 0 ? true : false);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10469
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10470
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10471
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10472
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10473
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10474
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10475
    OperatingSystem supportsSelect ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10476
	"/ mhmh - what should we do then ?
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10477
	"/ For now, return true as if data was present,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10478
	"/ and let the thread fall into the read.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10479
	"/ It will then (hopefully) be desceduled there and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10480
	"/ effectively polling for input.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10481
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10482
	^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10483
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10484
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10485
    ^ (OperatingSystem selectOnAnyReadable:(Array with:fd)
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10486
		       writable:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10487
		       exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10488
		       withTimeOut:0) == fd
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10489
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10490
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10491
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10492
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10493
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10494
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10495
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10496
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10497
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10498
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10499
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10500
     h := OperatingSystem openFileForRead:'/dev/ttyS0'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10501
     n := h canReadWithoutBlocking.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10502
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10503
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10504
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10505
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10506
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10507
canWriteWithoutBlocking
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10508
    "return true, if filedescriptor can be written without blocking"
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10509
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10510
    OperatingSystem supportsSelect ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10511
	"/ mhmh - what should we do then ?
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10512
	"/ For now, return true as if data was present,
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10513
	"/ and let the thread fall into the write.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10514
	"/ It will then (hopefully) be desceduled there and
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10515
	"/ effectively polling for output.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10516
	^ true
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10517
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10518
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10519
    ^ (OperatingSystem selectOnAnyReadable:nil
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10520
		       writable:(Array with:fd)
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10521
		       exception:nil
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10522
		       withTimeOut:0) == fd
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10523
!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10524
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10525
isValid
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10526
    "answer true, if the handle is valid, i.e. connected to
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10527
     a file or some other OS object"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10528
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10529
    ^ fd notNil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10530
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10531
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10532
numAvailableForRead
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10533
    "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
 10534
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10535
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10536
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10537
     * 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
 10538
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10539
# if defined(FIONREAD)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10540
    {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10541
	int n = 0;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10542
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10543
	if (__isSmallInteger(__INST(fd))) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10544
	    if (ioctl(__smallIntegerVal(__INST(fd)), FIONREAD, &n) >= 0) {
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10545
		RETURN (__MKINT(n));
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10546
	    }
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10547
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10548
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10549
# endif /* FIONREAD */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10550
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10551
    ^ self canReadWithoutBlocking ifTrue:[1] ifFalse:[0]
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10552
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10553
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10554
     |h n|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10555
     h := OperatingSystem openFileForRead:'/etc/hosts'.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10556
     n := h numAvailableForRead.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10557
     h close.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10558
     n
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 10559
    "
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10560
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10561
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10562
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'registering'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10563
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10564
register
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10565
    "register myself as an open file"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10566
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10567
    |sz old|
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10568
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10569
    sz := OpenFiles size.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10570
    fd > sz ifTrue:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10571
	"grow for more descriptors"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10572
	old := OpenFiles.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10573
	OpenFiles := WeakArray new:(sz * 2).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10574
	old removeDependent:(self class).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10575
	OpenFiles addDependent:(self class).
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10576
	old keysAndValuesDo:[:index :elem|
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10577
	    "be careful to not overwrite new entries in OpenFiles"
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10578
	    elem notNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10579
		OpenFiles at:index put:elem.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10580
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10581
	].
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10582
    ].
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10583
    OpenFiles at:fd put:self.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10584
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10585
    "Created: 30.9.1997 / 12:51:48 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10586
    "Modified: 30.9.1997 / 12:58:37 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10587
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10588
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10589
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'releasing'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10590
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10591
invalidate
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10592
    "a file handle has become invalid"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10593
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10594
    OpenFiles at:fd put:nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10595
    fd := nil.
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10596
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10597
    "Created: 30.9.1997 / 12:37:26 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10598
    "Modified: 30.9.1997 / 12:42:16 / stefan"
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10599
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10600
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10601
!UnixOperatingSystem::FileDescriptorHandle methodsFor:'waiting'!
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10602
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10603
readWaitWithTimeoutMs:timeout
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10604
    "suspend the current process, until the receiver
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10605
     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
 10606
     If data is already available, return immediate.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10607
     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
 10608
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10609
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10610
    |inputSema hasData wasBlocked|
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10611
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10612
    fd isNil ifTrue:[^ self error:#errorNotOpen].
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
    wasBlocked := OperatingSystem blockInterrupts.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10615
    hasData := self canReadWithoutBlocking.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10616
    hasData ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10617
	inputSema := Semaphore new name:'readWait'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10618
	[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10619
	    timeout notNil ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10620
		Processor signal:inputSema afterMilliseconds:timeout
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10621
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10622
	    Processor signal:inputSema onInput:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10623
	    Processor activeProcess state:#ioWait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10624
	    inputSema wait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10625
	    Processor disableSemaphore:inputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10626
	    hasData := self canReadWithoutBlocking.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10627
	] ifCurtailed:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10628
	    Processor disableSemaphore:inputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10629
	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10630
	]
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10631
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10632
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10633
    ^ hasData not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10634
!
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
writeWaitWithTimeoutMs:timeout
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10637
    "suspend the current process, until the receiver
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10638
     becomes ready for writing or a timeout (in seconds) expired.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10639
     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
 10640
     Return immediate if the receiver is already ready.
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10641
     The other threads are not affected by the wait."
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10642
6343
3e35a55af7c5 checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6340
diff changeset
 10643
    |outputSema canWrite wasBlocked|
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10644
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10645
    fd isNil ifTrue:[^ self error:#errorNotOpen].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10646
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10647
    wasBlocked := OperatingSystem blockInterrupts.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10648
    canWrite := self canWriteWithoutBlocking.
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10649
    canWrite ifFalse:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10650
	outputSema := Semaphore new name:'writeWait'.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10651
	[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10652
	    timeout notNil ifTrue:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10653
		Processor signal:outputSema afterMilliseconds:timeout
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10654
	    ].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10655
	    Processor signal:outputSema onOutput:fd.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10656
	    Processor activeProcess state:#ioWait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10657
	    outputSema wait.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10658
	    Processor disableSemaphore:outputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10659
	    canWrite := self canWriteWithoutBlocking.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10660
	] ifCurtailed:[
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10661
	    Processor disableSemaphore:outputSema.
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10662
	    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10663
	]
6340
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10664
    ].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10665
    wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10666
    ^ canWrite not
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10667
! !
65183f0db451 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 6334
diff changeset
 10668
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10669
!UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10670
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10671
closeFile
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10672
    "close the underlying file"
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
%{
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10675
    FILE *f = (FILE *)(__externalAddressVal(self));
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10676
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10677
    if (f) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10678
	__externalAddressVal(self) = NULL;
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10679
	fclose(f);
6301
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10680
    }
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10681
%}
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10682
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10683
! !
f95d23e6da4d checkin from browser
Stefan Vogel <sv@exept.de>
parents: 6287
diff changeset
 10684
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10685
!UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10686
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10687
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
 10688
    ^ self basicNew
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 10689
	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
 10690
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10691
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10692
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10693
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10694
accessTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10695
    "return accessed"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10696
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10697
    accessed isInteger ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10698
	"/ lazy time conversion
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10699
	accessed := Timestamp fromOSTime:(accessed * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10700
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10701
    ^ accessed
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10702
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10703
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10704
alternativeName
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10705
    "return the files other name (DOS name on windows).
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10706
     Nil if there is no other name"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10707
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10708
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10709
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10710
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10711
creationTime
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10712
    ^ nil
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10713
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10714
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10715
fileSize
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10716
    "return size"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10717
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10718
    ^ size
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10719
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10720
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10721
gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10722
    "return gid"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10723
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10724
    ^ gid
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10725
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10726
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10727
id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10728
    "return id"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10729
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10730
    ^ id
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10731
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10732
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10733
mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10734
    "return mode"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10735
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10736
    ^ mode
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10737
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10738
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10739
modificationTime
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10740
    "return modified"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10741
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10742
    modified isInteger ifTrue:[
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10743
	"/ lazy time conversion
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10744
	modified := Timestamp fromOSTime:(modified * 1000).
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10745
    ].
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10746
    ^ modified
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10747
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10748
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10749
numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10750
    "return numLinks"
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10751
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10752
    ^ numLinks
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10753
!
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10754
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10755
path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10756
    "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
 10757
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10758
    ^ path
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10759
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10760
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10761
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10762
statusChangeTime
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10763
    statusChanged isInteger ifTrue:[
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10764
	"/ lazy time conversion
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10765
	statusChanged := Timestamp fromOSTime:(statusChanged * 1000).
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10766
    ].
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10767
    ^ statusChanged
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10768
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10769
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10770
type
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10771
    "return type"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10772
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10773
    ^ type
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10774
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10775
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10776
uid
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10777
    "return uid"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10778
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10779
    ^ uid
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10780
! !
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10781
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10782
!UnixOperatingSystem::FileStatusInfo methodsFor:'accessing-vms'!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10783
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10784
fixedHeaderSize
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10785
    "return the fixedHeaderSize (VMS only; nil everywhere else)"
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10786
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10787
    ^ nil
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10788
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10789
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10790
recordAttributes
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10791
    "return the recordAttributes (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10792
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10793
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10794
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10795
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10796
recordFormat
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10797
    "return the recordFormat (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10798
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10799
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10800
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10801
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10802
recordFormatNumeric
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10803
    "return the recordFormat as numeric (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10804
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10805
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10806
!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10807
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10808
recordSize
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10809
    "return the recordSize (VMS only; nil everywhere else)"
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10810
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10811
    ^ nil
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10812
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10813
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10814
!UnixOperatingSystem::FileStatusInfo methodsFor:'backward compatibility'!
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10815
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10816
accessed
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 10817
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10818
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10819
    self obsoleteMethodWarning:'use #accessTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10820
    ^ self accessTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10821
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10822
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10823
at:key
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10824
    "backward compatibility access: in previous releases, IdentityDictionaries
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10825
     were used to hold my information. Allow access via key messages.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10826
     This method will vanish - use the proper access protocol."
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10827
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10828
    ^ self perform:key
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10829
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10830
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10831
modified
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 10832
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10833
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10834
    self obsoleteMethodWarning:'use #modificationTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10835
    ^ self modificationTime
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10836
!
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10837
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10838
statusChanged
8355
b46ecc1b4d79 Mark obsolete methods
Stefan Vogel <sv@exept.de>
parents: 8337
diff changeset
 10839
    <resource:#obsolete>
6792
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10840
ebd0bc1c5c6d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 6780
diff changeset
 10841
    self obsoleteMethodWarning:'use #statusChangeTime'.
6797
7be10c02be3b speedup info using lazy times
ca
parents: 6796
diff changeset
 10842
    ^ self statusChangeTime
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10843
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10844
7259
e8c3fc540c21 method category rename
Claus Gittinger <cg@exept.de>
parents: 7256
diff changeset
 10845
!UnixOperatingSystem::FileStatusInfo methodsFor:'private-accessing'!
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10846
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10847
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
 10848
    type := t.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10849
    mode := m.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10850
    uid := u.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10851
    gid := g.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10852
    size := s.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10853
    id := i.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10854
    accessed := aT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10855
    modified := mT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10856
    statusChanged := sT.
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10857
    path := lP.
6371
ca3db1423d8d added numLinks to fileStatus info
Claus Gittinger <cg@exept.de>
parents: 6363
diff changeset
 10858
    numLinks := nL.
5854
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10859
! !
b451c2eda355 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 5656
diff changeset
 10860
10586
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10861
!UnixOperatingSystem::FileStatusInfo methodsFor:'queries-access'!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10862
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10863
isGroupExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10864
    ^ mode bitTest:8r10
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10865
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10866
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10867
      '/etc/passwd' asFilename info isGroupExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10868
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10869
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10870
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10871
isGroupReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10872
    ^ mode bitTest:8r40
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10873
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10874
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10875
      '/etc/passwd' asFilename info isGroupReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10876
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10877
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10878
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10879
isGroupWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10880
    ^ mode bitTest:8r20
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10881
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10882
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10883
      '/etc/passwd' asFilename info isGroupWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10884
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10885
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10886
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10887
isOwnerExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10888
    ^ mode bitTest:8r100
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10889
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10890
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10891
      '/etc/passwd' asFilename info isOwnerExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10892
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10893
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10894
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10895
isOwnerReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10896
    ^ mode bitTest:8r400
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10897
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10898
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10899
      '/etc/passwd' asFilename info isOwnerReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10900
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10901
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10902
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10903
isOwnerWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10904
    ^ mode bitTest:8r200
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10905
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10906
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10907
      '/etc/passwd' asFilename info isOwnerWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10908
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10909
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10910
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10911
isWorldExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10912
    ^ mode bitTest:8r1
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10913
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10914
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10915
      '/etc/passwd' asFilename info isWorldExecutable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10916
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10917
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10918
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10919
isWorldReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10920
    ^ mode bitTest:8r4
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10921
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10922
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10923
      '/etc/passwd' asFilename info isWorldReadable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10924
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10925
!
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10926
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10927
isWorldWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10928
    ^ mode bitTest:8r2
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10929
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10930
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10931
      '/etc/passwd' asFilename info isWorldWritable
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10932
    "
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10933
! !
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10934
7249c850299f FileStatusInfo - methods to check access rights
Stefan Vogel <sv@exept.de>
parents: 10406
diff changeset
 10935
!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
 10936
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10937
isBlockSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10938
    ^ 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
 10939
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10940
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10941
isCharacterSpecial
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10942
    ^ 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
 10943
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10944
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10945
isDirectory
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10946
    ^ 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
 10947
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10948
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10949
isFifo
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10950
    ^ 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
 10951
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10952
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10953
isRegular
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10954
    ^ 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
 10955
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10956
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10957
isSocket
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10958
    ^ 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
 10959
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10960
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10961
isSymbolicLink
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10962
    ^ 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
 10963
!
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10964
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10965
isUnknown
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10966
    ^ 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
 10967
! !
24e7d19b3475 #linkInfo now returns the info also for files that are not a symlink
Stefan Vogel <sv@exept.de>
parents: 8469
diff changeset
 10968
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10969
!UnixOperatingSystem::MountInfo methodsFor:'accessing'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10970
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10971
mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10972
    "return the value of the instance variable 'mountPointPath' (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10973
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10974
    ^ mountPointPath
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10975
!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10976
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10977
mountPointPath:mountPointArg deviceOrRemotePath:deviceOrRemotePathArg fsType:fsTypeArg attributeString:attributeStringArg
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10978
    "set instance variables (automatically generated)"
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10979
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10980
    mountPointPath := mountPointArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10981
    deviceOrRemotePath := deviceOrRemotePathArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10982
    fsType := fsTypeArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10983
    attributeString := attributeStringArg.
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10984
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10985
7762
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 10986
!UnixOperatingSystem::MountInfo methodsFor:'printing'!
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 10987
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 10988
printOn:aStream
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10989
    aStream
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10990
	nextPutAll:'MountInfo for ';
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 10991
	nextPutAll:mountPointPath.
7762
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 10992
! !
26182f6ff625 mountInfo printing
Claus Gittinger <cg@exept.de>
parents: 7760
diff changeset
 10993
6779
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10994
!UnixOperatingSystem::MountInfo methodsFor:'queries'!
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10995
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10996
isRemote
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10997
    ^ fsType = 'nfs'
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10998
! !
bd65f054770d add mountPoint methods
penk
parents: 6772
diff changeset
 10999
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11000
!UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11001
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11002
documentation
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11003
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11004
    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
 11005
    operating system processes (these are no smalltalk processes!!).
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11006
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11007
    [Instance variables:]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11008
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11009
	pid     <Integer>       OS-Process identifier
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11010
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11011
	status  <Symbol>        either #exit #signal #stop #continue
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11012
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11013
	code    <Integer>       either exitcode or signalnumber
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11014
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11015
	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
 11016
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11017
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11018
    [author:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11019
	Stefan Vogel
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11020
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11021
    [see also:]
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 11022
	OperatingSystem
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11023
"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11024
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11025
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11026
!UnixOperatingSystem::OSProcessStatus class methodsFor:'instance creation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11027
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11028
pid:pid status:status code:code core:core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11029
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11030
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11031
    ^ 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
 11032
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11033
    "Created: 28.12.1995 / 14:16:14 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11034
    "Modified: 30.4.1996 / 18:25:00 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11035
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11036
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11037
processCreationFailure
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11038
    "private interface for UnixOperatingSystem"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11039
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11040
    ^ 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
 11041
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11042
    "Created: 28.12.1995 / 14:35:29 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11043
    "Modified: 30.4.1996 / 18:25:05 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11044
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11045
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11046
!UnixOperatingSystem::OSProcessStatus methodsFor:'accessing'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11047
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11048
code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11049
    "return the exitcode / signalNumber"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11050
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11051
    ^ code
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11052
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11053
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11054
    "Modified: 30.4.1996 / 18:26:23 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11055
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11056
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11057
core
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11058
    "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
 11059
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11060
    ^ core == true
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11061
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11062
    "Modified: 28.12.1995 / 14:14:38 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11063
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11064
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11065
pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11066
    "return the pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11067
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11068
    ^ pid
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11069
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11070
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11071
    "Modified: 30.4.1996 / 18:26:30 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11072
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11073
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11074
status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11075
    "return status as a Symbol;
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11076
     one of #exit #signal #stop #continue"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11077
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11078
    ^ status
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11079
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11080
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11081
    "Modified: 30.4.1996 / 18:26:54 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11082
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11083
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11084
!UnixOperatingSystem::OSProcessStatus methodsFor:'initialization'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11085
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11086
pid:newPid status:newStatus code:newCode core:newCore
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11087
    pid := newPid.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11088
    status := newStatus.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11089
    code := newCode.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11090
    core := newCore.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11091
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11092
    "Created: 28.12.1995 / 14:18:22 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11093
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11094
7175
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11095
!UnixOperatingSystem::OSProcessStatus methodsFor:'printing & storing'!
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11096
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11097
printOn:aStream
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11098
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11099
    aStream nextPutAll:'ExitStatus ('.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11100
    status printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11101
    aStream nextPutAll:', code='.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11102
    code printOn:aStream.
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11103
    aStream nextPut:$).
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11104
! !
e3bba0479a52 #printOn: in OSProcessStatus
Stefan Vogel <sv@exept.de>
parents: 7171
diff changeset
 11105
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11106
!UnixOperatingSystem::OSProcessStatus methodsFor:'private-OS interface'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11107
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11108
code:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11109
    "set the exitCode"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11110
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11111
    code := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11112
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11113
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11114
    "Modified: 30.4.1996 / 18:25:18 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11115
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11116
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11117
core:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11118
    "set core"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11119
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11120
    core := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11121
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11122
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11123
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11124
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11125
pid:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11126
    "set pid"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11127
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11128
    pid := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11129
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11130
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11131
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11132
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11133
status:something
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11134
    "set status"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11135
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11136
    status := something.
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11137
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11138
    "Created: 28.12.1995 / 14:05:07 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11139
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11140
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11141
!UnixOperatingSystem::OSProcessStatus methodsFor:'queries'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11142
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11143
couldNotExecute
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11144
    "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
 11145
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11146
    ^ status == #exit and:[code = 127].
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11147
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11148
    "Created: 28.12.1995 / 15:43:17 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11149
    "Modified: 30.4.1996 / 18:27:03 / cg"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11150
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11151
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11152
stillAlive
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11153
    "true if process is still alive"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11154
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11155
    ^ status == #stop or:[status == #continue]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11156
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11157
    "Created: 28.12.1995 / 14:27:26 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11158
!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11159
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11160
success
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11161
    "true if process terminated successfully"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11162
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11163
    ^ status == #exit and:[code = 0]
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11164
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11165
    "Created: 28.12.1995 / 14:13:05 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11166
    "Modified: 28.12.1995 / 14:13:41 / stefan"
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11167
! !
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 11168
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11169
!UnixOperatingSystem::SocketHandle class methodsFor:'constants'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11170
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11171
protocolCodeOf:aNameOrNumber
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11172
    "convert a symbol to a numeric protocol code"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11173
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11174
    |protocolCode protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11175
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11176
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11177
    if (__isSmallInteger(aNameOrNumber) || aNameOrNumber == nil) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11178
        RETURN(aNameOrNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11179
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11180
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11181
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11182
    ProtocolCache notNil ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11183
        protocolCode := ProtocolCache at:(aNameOrNumber asSymbol) ifAbsent:[].
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11184
        protocolCode notNil ifTrue:[
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11185
            ^ protocolCode.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11186
        ].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11187
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11188
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11189
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11190
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11191
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11192
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11193
    if (__isStringLike(aNameOrNumber)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11194
        protoent = getprotobyname((char *) __stringVal(aNameOrNumber));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11195
        if (protoent) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11196
            protocolCode = __mkSmallInteger(protoent->p_proto);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11197
            protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11198
        }
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11199
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11200
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11201
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11202
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11203
    protocolSymbol notNil ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11204
        ProtocolCache isNil ifTrue:[
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11205
            ProtocolCache := IdentityDictionary new.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11206
        ].
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11207
        "beware of polluting the protocol cache with aliases"
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11208
        ProtocolCache at:protocolSymbol put:protocolCode.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11209
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11210
    ^ protocolCode
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11211
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11212
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11213
     self protocolCodeOf:#tcp
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11214
     self protocolCodeOf:#udp
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11215
     self protocolCodeOf:#raw
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11216
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11217
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11218
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11219
protocolSymbolOf:anInteger
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11220
    "convert a numeric protocol code to a symbol"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11221
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11222
    |protocolSymbol|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11223
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11224
    ProtocolCache notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11225
	protocolSymbol := ProtocolCache keyAtIdentityValue:anInteger ifAbsent:[].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11226
	protocolSymbol notNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11227
	    ^ protocolSymbol.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11228
	].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11229
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11230
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11231
%{
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11232
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11233
    struct protoent *protoent = 0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11234
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11235
    if (__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11236
	protoent = getprotobynumber(__intVal(anInteger));
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11237
	if (protoent) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11238
	    protocolSymbol = __MKSYMBOL(protoent->p_name, 0);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11239
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11240
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11241
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11242
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11243
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11244
    protocolSymbol notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11245
	ProtocolCache isNil ifTrue:[
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11246
	    ProtocolCache := IdentityDictionary new.
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11247
	].
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 11248
	ProtocolCache at:protocolSymbol put:anInteger.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11249
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11250
    ^ protocolSymbol
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11251
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11252
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11253
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11254
     self protocolSymbolOf:(self protocolCodeOf:#tcp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11255
     self protocolSymbolOf:(self protocolCodeOf:#udp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11256
     self protocolSymbolOf:(self protocolCodeOf:#icmp)
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11257
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11258
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11259
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11260
!UnixOperatingSystem::SocketHandle class methodsFor:'initialization'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11261
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11262
reinitialize
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11263
    "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
 11264
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11265
    ProtocolCache := nil.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11266
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 11267
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11268
!UnixOperatingSystem::SocketHandle class methodsFor:'queries'!
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11269
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11270
XXgetAddressInfo:hostName serviceName:serviceNameArg domain:domainArg type:typeArg protocol:protoArg flags:flags
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11271
    "answer an Array of socket addresses for serviceName on hostName
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11272
     Domain, type, protocol may be nil or specify a hint for the socket
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11273
     addresses to be returned."
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11274
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
 11275
    |error errorString result domain type proto serviceName|
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11276
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11277
    domain := OperatingSystem domainCodeOf:domainArg.
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 11278
    type := OperatingSystem socketTypeCodeOf:typeArg.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11279
    proto := self protocolCodeOf:protoArg.
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
 11280
    serviceNameArg notNil ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11281
        serviceName := serviceNameArg printString.      "convert integer port numbers"
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11282
    ].
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11283
12967
f3273ea6f426 SocketHandle>>getAddressInfo: ..
Stefan Vogel <sv@exept.de>
parents: 12962
diff changeset
 11284
%{ /* STACK: 200000 */  /* Don't know whether DNS, NIS, LDAP or whatever is consulted */
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11285
#undef xxAI_NUMERICHOST /* remove xx to test gethost...() path */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11286
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11287
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11288
#if !defined(NO_SOCKET)
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11289
    char *__hostName, *__serviceName;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11290
    int ret, cnt = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11291
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11292
    if (hostName == nil) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11293
        __hostName = 0;
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
 11294
    } else if (__isStringLike(hostName)) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11295
        __hostName = __stringVal(hostName);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11296
    } else {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11297
        error = @symbol(badArgument1);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11298
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11299
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11300
    if (serviceName == nil) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11301
        __serviceName = 0;
10791
6af9a9da7262 #getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 10787
diff changeset
 11302
    } else if (__isStringLike(serviceName)) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11303
        __serviceName = __stringVal(serviceName);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11304
    } else {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11305
        error = @symbol(badArgument2);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11306
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11307
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11308
    if (__hostName == 0 && __serviceName == 0) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11309
        error = @symbol(badArgument);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11310
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11311
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11312
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11313
{
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11314
# if defined(AI_NUMERICHOST)
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11315
    /*
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 11316
     * Use getaddrinfo()
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 11317
     */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11318
    struct addrinfo hints;
7782
c42d11aaedb1 oops: please do not forget the garbage collector when allocating
Claus Gittinger <cg@exept.de>
parents: 7767
diff changeset
 11319
    struct addrinfo *info = NULL, *infop;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11320
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11321
    memset(&hints, 0, sizeof(hints));
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11322
    if (__isSmallInteger(domain))
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11323
        hints.ai_family = __intVal(domain);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11324
    if (__isSmallInteger(type))
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11325
        hints.ai_socktype = __intVal(type);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11326
    if (__isSmallInteger(proto))
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11327
        hints.ai_protocol = __intVal(proto);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11328
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11329
    do {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11330
        if (hostName == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11331
            __hostName = 0;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11332
        } else if (__isStringLike(hostName)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11333
            __hostName = __stringVal(hostName);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11334
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11335
        if (serviceName == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11336
            __serviceName = 0;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11337
        } else if (__isStringLike(serviceName)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11338
            __serviceName = __stringVal(serviceName);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11339
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11340
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11341
        __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11342
        ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11343
        __END_INTERRUPTABLE__
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11344
    } while (ret == EAI_SYSTEM && errno == EINTR);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11345
    if (ret != 0) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11346
        switch (ret) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11347
        case EAI_FAMILY:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11348
            error = @symbol(badProtocol);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11349
            break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11350
        case EAI_SOCKTYPE:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11351
            error = @symbol(badSocketType);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11352
            break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11353
        case EAI_BADFLAGS:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11354
            error = @symbol(badFlags);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11355
            break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11356
        case EAI_NONAME:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11357
            error = @symbol(unknownHost);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11358
            break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11359
        case EAI_SERVICE:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11360
            error = @symbol(unknownService);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11361
            break;
11625
f158b3fba3fb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11547
diff changeset
 11362
#ifdef EAI_ADDRFAMILY
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11363
        case EAI_ADDRFAMILY :
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11364
            error = @symbol(unknownHostForProtocol);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11365
            break;
11625
f158b3fba3fb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11547
diff changeset
 11366
#endif
f158b3fba3fb *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11547
diff changeset
 11367
#ifdef EAI_NODATA
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11368
        case EAI_NODATA:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11369
            error = @symbol(noAddress);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11370
            break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11371
#endif
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11372
        case EAI_MEMORY:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11373
            error = @symbol(allocationFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11374
            break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11375
        case EAI_FAIL:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11376
            error = @symbol(permanentFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11377
            break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11378
        case EAI_AGAIN:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11379
            error = @symbol(tryAgain);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11380
            break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11381
        case EAI_SYSTEM:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11382
            error = @symbol(systemError);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11383
            break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11384
        default:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11385
            error = @symbol(unknownError);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11386
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11387
        errorString = __MKSTRING(gai_strerror(ret));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11388
        goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11389
    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11390
    for (cnt=0, infop=info; infop; infop=infop->ai_next)
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11391
        cnt++;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11392
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11393
    result = __ARRAY_NEW_INT(cnt);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11394
    if (result == nil) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11395
        error = @symbol(allocationFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11396
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11397
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11398
    for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11399
        OBJ o, resp;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11400
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11401
        resp = __ARRAY_NEW_INT(6);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11402
        if (resp == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11403
            error = @symbol(allocationFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11404
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11405
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11406
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11407
        __ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11408
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11409
        __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11410
        __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11411
        __ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11412
        __ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11413
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11414
        __PROTECT__(resp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11415
        o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11416
        __UNPROTECT__(resp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11417
        if (o == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11418
            error = @symbol(allocationFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11419
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11420
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11421
        memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11422
       __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11423
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11424
        if (infop->ai_canonname) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11425
            __PROTECT__(resp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11426
            o = __MKSTRING(infop->ai_canonname);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11427
            __UNPROTECT__(resp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11428
            if (o == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11429
                error = @symbol(allocationFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11430
                goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11431
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11432
            __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11433
        }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11434
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11435
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11436
err:
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11437
    if (info) freeaddrinfo(info);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11438
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11439
# else /* ! AI_NUMERICHOST =============================================================*/
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11440
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11441
    /*
7315
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 11442
     * Use getservbyname() / gethostByName()
491207823313 some socket query code moved from socket to here;
Claus Gittinger <cg@exept.de>
parents: 7314
diff changeset
 11443
     */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11444
    struct hostent *hp;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11445
    char **addrpp;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11446
    int port = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11447
    int i;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11448
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11449
    if (__serviceName) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11450
        struct servent *sp;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11451
        char *__proto = 0;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11452
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11453
        if (__isStringLike(protoArg))
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11454
            __proto = __stringVal(protoArg);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11455
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11456
        sp = getservbyname(__serviceName, __proto);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11457
        if (sp == NULL) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11458
            errorString = @symbol(unknownService);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11459
            error = __mkSmallInteger(-3);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11460
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11461
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11462
        port = sp->s_port;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11463
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11464
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11465
    if (__hostName) {
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11466
#  ifdef USE_H_ERRNO
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11467
        do {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11468
            if (hostName == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11469
                __hostName = 0;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11470
            } else if (__isStringLike(hostName)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11471
                __hostName = __stringVal(hostName);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11472
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11473
            /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11474
             * uses a static data area
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11475
             */
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11476
            __BEGIN_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11477
            hp = gethostbyname(__hostName);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11478
            __END_INTERRUPTABLE__
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11479
        } while ((hp == NULL)
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11480
                  && (
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11481
                        (h_errno == TRY_AGAIN)
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11482
                      || errno == EINTR
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11483
#   ifdef IRIX5_3
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11484
                      || (errno == ECONNREFUSED)
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11485
#   endif
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11486
                     )
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11487
        );
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11488
        if (hp == 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11489
            switch (h_errno) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11490
            case HOST_NOT_FOUND:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11491
                errorString = @symbol(unknownHost);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11492
                break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11493
            case NO_ADDRESS:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11494
                errorString = @symbol(noAddress);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11495
                break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11496
            case NO_RECOVERY:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11497
                errorString = @symbol(permanentFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11498
                break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11499
            case TRY_AGAIN:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11500
                errorString = @symbol(tryAgain);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11501
                break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11502
            default:
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11503
                errorString = @symbol(unknownError);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11504
                break;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11505
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11506
            error = __mkSmallInteger(h_errno);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11507
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11508
        }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11509
#  else /* !USE_H_ERRNO */
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11510
        hp = gethostbyname(__hostName);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11511
        if (hp == 0) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11512
            errorString = @symbol(unknownHost);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11513
            error = __mkSmallInteger(-1);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11514
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11515
        }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11516
#  endif /* !USE_H_ERRNO*/
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11517
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11518
        if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11519
            errorString = @symbol(unknownHost);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11520
            error = __mkSmallInteger(-2);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11521
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11522
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11523
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11524
        for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11525
            cnt++;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11526
        addrpp = hp->h_addr_list;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11527
    } else {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11528
        cnt = 1;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11529
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11530
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11531
    result = __ARRAY_NEW_INT(cnt);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11532
    if (result == nil) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11533
        error = @symbol(allocationFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11534
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11535
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11536
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11537
    for (i = 0; i < cnt; i++) {
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11538
        OBJ o, resp;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11539
        struct sockaddr_in *sa;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11540
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11541
        resp = __ARRAY_NEW_INT(6);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11542
        if (resp == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11543
            error = @symbol(allocationFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11544
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11545
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11546
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11547
        __ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11548
        __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11549
        __ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11550
        __ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11551
        __PROTECT__(resp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11552
        o = __BYTEARRAY_NEW_INT(sizeof(*sa));
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11553
        __UNPROTECT__(resp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11554
        if (o == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11555
            error = @symbol(allocationFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11556
            goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11557
        }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11558
        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11559
        sa = (struct sockaddr_in *)__byteArrayVal(o);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11560
        sa->sin_port = port;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11561
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11562
        if (__hostName) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11563
            sa->sin_family = hp->h_addrtype;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11564
            memcpy(&sa->sin_addr, *addrpp, hp->h_length);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11565
            __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11566
            if (hp->h_name) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11567
                __PROTECT__(resp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11568
                o = __MKSTRING(hp->h_name);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11569
                __UNPROTECT__(resp);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11570
                if (o == nil) {
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11571
                    error = @symbol(allocationFailure);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11572
                    goto err;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11573
                }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11574
                __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11575
            }
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11576
            addrpp++;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11577
        } else{
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11578
            __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11579
        }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11580
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11581
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11582
err:;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11583
# endif /* ! AI_NUMERICHOST */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11584
}
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11585
#else /* ! HAS_SOCKET */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11586
    error = @symbol(notImplemented);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11587
#endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11588
%}.
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11589
    error notNil ifTrue:[
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11590
        |request|
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11591
        request := SocketAddressInfo new
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11592
            domain:domainArg;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11593
            type:typeArg;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11594
            protocol:protoArg;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11595
            canonicalName:hostName;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11596
            serviceName:serviceName.
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11597
        ^ (HostNameLookupError new
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11598
                parameter:error;
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11599
                messageText:' - ', (errorString ? error printString);
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11600
                request:request) raiseRequest.
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11601
    ].
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11602
    1 to:result size do:[:i |
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11603
        |entry dom info|
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11604
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11605
        entry := result at:i.
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11606
12868
69d9e2b0b5b5 Fix SocketAddress getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12863
diff changeset
 11607
        info := SocketAddressInfo new.
69d9e2b0b5b5 Fix SocketAddress getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12863
diff changeset
 11608
        info
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11609
            flags:(entry at:1);
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11610
            domain:(dom := OperatingSystem domainSymbolOf:(entry at:2));
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11611
            type:(OperatingSystem socketTypeSymbolOf:(entry at:3));
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11612
            protocol:(self protocolSymbolOf:(entry at:4));
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11613
            socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5));
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11614
            canonicalName:(entry at:6).
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11615
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11616
        result at:i put:info.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11617
    ].
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11618
    ^ result
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11619
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11620
    "
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11621
     self getAddressInfo:'localhost' serviceName:nil
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11622
            domain:nil type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11623
     self getAddressInfo:'localhost' serviceName:nil
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11624
            domain:#inet type:#stream protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11625
     self getAddressInfo:'localhost' serviceName:nil
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11626
            domain:#inet type:#stream protocol:#tcp flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11627
     self getAddressInfo:'blurb.exept.de' serviceName:nil
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11628
            domain:#inet type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11629
     self getAddressInfo:'1.2.3.4' serviceName:'bla'
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11630
            domain:#inet type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11631
     self getAddressInfo:'localhost' serviceName:'echo'
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11632
            domain:#inet type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11633
     self getAddressInfo:nil serviceName:'echo'
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11634
            domain:#inet type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11635
     self getAddressInfo:nil serviceName:nil
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11636
            domain:#inet type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11637
     self getAddressInfo:'www.google.de' serviceName:nil
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11638
            domain:nil type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11639
     self getAddressInfo:'smc1' serviceName:nil
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 11640
            domain:nil type:nil protocol:nil flags:nil
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11641
    "
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11642
!
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11643
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11644
getAddressInfo:hostName serviceName:serviceNameArg domain:domainArg type:typeArg protocol:protoArg flags:flags
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11645
    "answer an Array of socket addresses for serviceName on hostName
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11646
     Domain, type, protocol may be nil or specify a hint for the socket
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11647
     addresses to be returned."
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11648
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11649
    |result domain type proto serviceName|
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11650
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11651
    domain := OperatingSystem domainCodeOf:domainArg.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11652
    type := OperatingSystem socketTypeCodeOf:typeArg.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11653
    proto := self protocolCodeOf:protoArg.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11654
    serviceNameArg notNil ifTrue:[
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11655
        serviceName := serviceNameArg printString.      "convert integer port numbers"
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11656
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11657
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11658
    result := self primGetAddressInfo:hostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11659
    result isArray ifFalse:[
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11660
        |request|
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11661
        request := SocketAddressInfo new
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11662
            domain:domainArg;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11663
            type:typeArg;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11664
            protocol:protoArg;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11665
            canonicalName:hostName;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11666
            serviceName:serviceName.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11667
        ^ (HostNameLookupError new
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11668
                parameter:result;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11669
                messageText:' - ', (result printString);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11670
                request:request) raiseRequest.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11671
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11672
    1 to:result size do:[:i |
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11673
        |entry dom info|
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11674
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11675
        entry := result at:i.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11676
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11677
        info := SocketAddressInfo new.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11678
        info
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11679
            flags:(entry at:1);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11680
            domain:(dom := OperatingSystem domainSymbolOf:(entry at:2));
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11681
            type:(OperatingSystem socketTypeSymbolOf:(entry at:3));
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11682
            protocol:(self protocolSymbolOf:(entry at:4));
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11683
            socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5));
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11684
            canonicalName:(entry at:6).
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11685
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11686
        result at:i put:info.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11687
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11688
    ^ result
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11689
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11690
    "
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11691
     self getAddressInfo:'localhost' serviceName:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11692
            domain:nil type:nil protocol:nil flags:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11693
     self getAddressInfo:'localhost' serviceName:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11694
            domain:#inet type:#stream protocol:nil flags:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11695
     self getAddressInfo:'localhost' serviceName:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11696
            domain:#inet type:#stream protocol:#tcp flags:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11697
     self getAddressInfo:'blurb.exept.de' serviceName:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11698
            domain:#inet type:nil protocol:nil flags:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11699
     self getAddressInfo:'1.2.3.4' serviceName:'bla'
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11700
            domain:#inet type:nil protocol:nil flags:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11701
     self getAddressInfo:'localhost' serviceName:'echo'
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11702
            domain:#inet type:nil protocol:nil flags:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11703
     self getAddressInfo:nil serviceName:'echo'
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11704
            domain:#inet type:nil protocol:nil flags:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11705
     self getAddressInfo:nil serviceName:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11706
            domain:#inet type:nil protocol:nil flags:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11707
     self getAddressInfo:'www.google.de' serviceName:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11708
            domain:nil type:nil protocol:nil flags:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11709
     self getAddressInfo:'smc1' serviceName:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11710
            domain:nil type:nil protocol:nil flags:nil
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11711
    "
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11712
!
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11713
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11714
getNameInfo:socketAddress wantHostName:wantHostName wantServiceName:wantServiceName datagram:useDatagram flags:flags
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11715
    "answer an Array containing the hostName and serviceName
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11716
     in socketAddress.
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11717
     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
 11718
     this returns multiple hostnames (if appropriate)"
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11719
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11720
    |error errorString hostName serviceName|
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11721
12863
c947bd1da044 added: #primUserInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12860
diff changeset
 11722
%{ /* 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
 11723
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11724
#undef xxNI_NUMERICHOST /* remove xx to test gethost...() path */
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11725
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11726
#if !defined(NO_SOCKET)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11727
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11728
# ifndef NI_MAXHOST
8788
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 11729
#  define NI_MAXHOST 1025
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11730
#  define NI_MAXSERV 64
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11731
# endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11732
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11733
    char host[NI_MAXHOST];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11734
    char service[NI_MAXSERV];
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11735
    char *hp = 0, *sp = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11736
    int hsz = 0, ssz = 0;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11737
    int ret, __flags;
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11738
    char *bp;
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11739
    int nInstBytes, sockAddrSize;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11740
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11741
    if (wantHostName == true) {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11742
        hp = host;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11743
        hsz = sizeof(host);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11744
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11745
    if (wantServiceName == true) {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11746
        sp = service;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11747
        ssz = sizeof(service);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11748
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11749
    if (hp == 0 && sp == 0) {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11750
        error = @symbol(badArgument);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11751
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11752
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11753
    if (!__isBytes(socketAddress)) {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11754
        error = @symbol(badArgument1);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11755
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11756
    }
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11757
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11758
    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_ninstvars));
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11759
    sockAddrSize = __byteArraySize(socketAddress);
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11760
    sockAddrSize -= nInstBytes;
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11761
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11762
    if (!__isSmallInteger(flags)) {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11763
        error = @symbol(badArgument5);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11764
        goto err;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11765
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11766
    __flags = __intVal(flags);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11767
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11768
#if defined(NI_NUMERICHOST)
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11769
    if (useDatagram == true) {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11770
        __flags |= NI_DGRAM;
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11771
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11772
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11773
    {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11774
        bp = (char *)(__byteArrayVal(socketAddress));
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11775
        bp += nInstBytes;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11776
        __BEGIN_INTERRUPTABLE__
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11777
        ret = getnameinfo((struct sockaddr *)bp, sockAddrSize,
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11778
                          hp, hsz, sp, ssz, __flags);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11779
        __END_INTERRUPTABLE__
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11780
    } while (ret == EAI_SYSTEM && errno == EINTR);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11781
    if (ret != 0) {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11782
        switch (ret) {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11783
        case EAI_FAMILY:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11784
            error = @symbol(badProtocol);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11785
            break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11786
        case EAI_SOCKTYPE:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11787
            error = @symbol(badSocketType);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11788
            break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11789
        case EAI_BADFLAGS:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11790
            error = @symbol(badFlags);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11791
            break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11792
        case EAI_NONAME:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11793
            error = @symbol(unknownHost);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11794
            break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11795
        case EAI_SERVICE:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11796
            error = @symbol(unknownService);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11797
            break;
11626
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 11798
#ifdef EAI_ADDRFAMILY
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11799
        case EAI_ADDRFAMILY :
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11800
            error = @symbol(unknownHostForProtocol);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11801
            break;
11626
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 11802
#endif
f46e87ad513c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 11625
diff changeset
 11803
#ifdef EAI_NODATA
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11804
        case EAI_NODATA:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11805
            error = @symbol(noAddress);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11806
            break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11807
#endif
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11808
        case EAI_MEMORY:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11809
            error = @symbol(allocationFailure);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11810
            break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11811
        case EAI_FAIL:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11812
            error = @symbol(permanentFailure);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11813
            break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11814
        case EAI_AGAIN:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11815
            error = @symbol(tryAgain);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11816
            break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11817
        case EAI_SYSTEM:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11818
            error = @symbol(systemError);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11819
            break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11820
        default:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11821
            error = @symbol(unknownError);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11822
        }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11823
        errorString = __MKSTRING(gai_strerror(ret));
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11824
        goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11825
    }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11826
# else /* ! NI_NUMERICHOST */
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11827
    {
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11828
        /*
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11829
         * Do it using gethostbyaddr()
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11830
         */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11831
        struct sockaddr_in *sa;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11832
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11833
        if (sockAddrSize < sizeof(*sa)) {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11834
            error = @symbol(badArgument1);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11835
            goto err;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11836
        }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11837
        bp = (char *)(__byteArrayVal(socketAddress));
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11838
        bp += nInstBytes;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11839
        sa = (struct sockaddr_in *)bp;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11840
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11841
        if (sp) {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11842
            struct servent *servp;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11843
            char *__proto = 0;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11844
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11845
            __proto = (useDatagram == true ? "udp" : "tcp");
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11846
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11847
            servp = getservbyport(sa->sin_port, __proto);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11848
            if (servp) {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11849
                sp = servp->s_name;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11850
            }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11851
        }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11852
        if (hp) {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11853
            struct hostent *hostp;
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11854
#  ifdef USE_H_ERRNO
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11855
            do {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11856
                bp = (char *)(__byteArrayVal(socketAddress));
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11857
                bp += nInstBytes;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11858
                sa = (struct sockaddr_in *)bp;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11859
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11860
                /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname uses a static data area
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11861
                 */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11862
                hostp = gethostbyaddr((char *)&sa->sin_addr, sockAddrSize, sa->sin_family);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11863
                /* __END_INTERRUPTABLE__ */
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11864
            } while ((hostp == NULL)
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11865
                      && ((h_errno == TRY_AGAIN)
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11866
                          || errno == EINTR
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11867
#   ifdef IRIX5_3
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11868
                          || (errno == ECONNREFUSED)
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11869
#   endif
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11870
                         )
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11871
            );
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11872
            if (hostp == 0) {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11873
                switch (h_errno) {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11874
                case HOST_NOT_FOUND:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11875
                    errorString = @symbol(unknownHost);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11876
                    break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11877
                case NO_ADDRESS:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11878
                    errorString = @symbol(noAddress);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11879
                    break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11880
                case NO_RECOVERY:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11881
                    errorString = @symbol(permanentFailure);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11882
                    break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11883
                case TRY_AGAIN:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11884
                    errorString = @symbol(tryAgain);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11885
                    break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11886
                default:
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11887
                    errorString = @symbol(unknownError);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11888
                    break;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11889
                }
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11890
                error = __mkSmallInteger(h_errno);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11891
                goto err;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11892
            }
7171
e8eac6f03c77 compilable on sun
Claus Gittinger <cg@exept.de>
parents: 7170
diff changeset
 11893
#  else /* !USE_H_ERRNO */
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11894
            hostp = gethostbyaddr(sa->sin_addr, sockAddrSize, sa->sin_family);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11895
            if (hostp == 0) {
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11896
                errorString = @symbol(unknownHost);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11897
                error = __mkSmallInteger(-1);
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11898
                goto err;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11899
            }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11900
#  endif /* !USE_H_ERRNO*/
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11901
            hp = hostp->h_name;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11902
        }
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11903
    }
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11904
# endif /* ! NI_NUMERICHOST */
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11905
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11906
    if (hp)
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11907
        hostName = __MKSTRING(hp);
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 11908
    if (sp)
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11909
        serviceName = __MKSTRING(sp);
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11910
err:;
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11911
#else
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11912
    error = @symbol(notImplemented);
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11913
#endif
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11914
%}.
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11915
    error notNil ifTrue:[
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11916
        ^ (HostAddressLookupError new
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11917
                parameter:error;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11918
                messageText:' - ', errorString;
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11919
                request:thisContext message) raiseRequest.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11920
    ].
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11921
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11922
    ^ Array with:hostName with:serviceName
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11923
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11924
    "
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11925
     self getNameInfo:
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11926
        (self getAddressInfo:'localhost' serviceName:'echo'
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11927
                domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11928
         wantHostName:true wantServiceName:true datagram:false flags:0
7316
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11929
ea29dbe04f91 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 7315
diff changeset
 11930
     self getNameInfo:
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11931
        (self getAddressInfo:'exept.de' serviceName:'echo'
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11932
                domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11933
         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
 11934
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 11935
     self getNameInfo:
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11936
        (self getAddressInfo:'217.172.183.25' serviceName:'22'
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11937
                domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11938
         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
 11939
562f4f8bb3ed support larger (FQDN) hostnames in #getNameInfo...
Stefan Vogel <sv@exept.de>
parents: 8762
diff changeset
 11940
     self getNameInfo:
12860
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11941
        (self getAddressInfo:'1.2.3.4' serviceName:'22'
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11942
                domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
980b550b72e6 changed: #userInfoOf:
Stefan Vogel <sv@exept.de>
parents: 12834
diff changeset
 11943
         wantHostName:true wantServiceName:true datagram:false flags:0
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 11944
    "
13025
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11945
!
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11946
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11947
primGetAddressInfo:hostName serviceName:serviceName domainCode:domain socketTypeCode:type protocolCode:proto flags:flags
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11948
    "answer an Array of socket addresses for serviceName on hostName
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11949
     Domain, type, protocol may be nil or specify a hint for the socket
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11950
     addresses to be returned."
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11951
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11952
    |error errorString result|
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11953
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11954
%{ /* UNLIMITEDSTACK */  /* Don't know whether DNS, NIS, LDAP or whatever is consulted */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11955
#undef xxAI_NUMERICHOST /* remove xx to test gethost...() path */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11956
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11957
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11958
#if !defined(NO_SOCKET)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11959
    char *__hostName, *__serviceName;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11960
    int ret, cnt = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11961
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11962
    if (hostName == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11963
        __hostName = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11964
    } else if (__isStringLike(hostName)) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11965
        __hostName = __stringVal(hostName);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11966
    } else {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11967
        error = @symbol(badArgument1);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11968
        goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11969
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11970
    if (serviceName == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11971
        __serviceName = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11972
    } else if (__isStringLike(serviceName)) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11973
        __serviceName = __stringVal(serviceName);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11974
    } else {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11975
        error = @symbol(badArgument2);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11976
        goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11977
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11978
    if (__hostName == 0 && __serviceName == 0) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11979
        error = @symbol(badArgument);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11980
        goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11981
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11982
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11983
{
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11984
# if defined(AI_NUMERICHOST)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11985
    /*
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11986
     * Use getaddrinfo()
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11987
     */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11988
    struct addrinfo hints;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11989
    struct addrinfo *info = NULL, *infop;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11990
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11991
    memset(&hints, 0, sizeof(hints));
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11992
    if (__isSmallInteger(domain))
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11993
        hints.ai_family = __intVal(domain);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11994
    if (__isSmallInteger(type))
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11995
        hints.ai_socktype = __intVal(type);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11996
    if (__isSmallInteger(proto))
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11997
        hints.ai_protocol = __intVal(proto);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11998
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 11999
    do {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12000
        if (hostName == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12001
            __hostName = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12002
        } else if (__isStringLike(hostName)) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12003
            __hostName = __stringVal(hostName);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12004
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12005
        if (serviceName == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12006
            __serviceName = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12007
        } else if (__isStringLike(serviceName)) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12008
            __serviceName = __stringVal(serviceName);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12009
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12010
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12011
//        __BEGIN_INTERRUPTABLE__
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12012
        ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12013
//        __END_INTERRUPTABLE__
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12014
    } while (ret == EAI_SYSTEM && errno == EINTR);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12015
    if (ret != 0) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12016
        switch (ret) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12017
        case EAI_FAMILY:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12018
            error = @symbol(badProtocol);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12019
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12020
        case EAI_SOCKTYPE:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12021
            error = @symbol(badSocketType);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12022
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12023
        case EAI_BADFLAGS:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12024
            error = @symbol(badFlags);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12025
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12026
        case EAI_NONAME:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12027
            error = @symbol(unknownHost);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12028
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12029
        case EAI_SERVICE:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12030
            error = @symbol(unknownService);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12031
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12032
#ifdef EAI_ADDRFAMILY
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12033
        case EAI_ADDRFAMILY :
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12034
            error = @symbol(unknownHostForProtocol);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12035
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12036
#endif
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12037
#ifdef EAI_NODATA
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12038
        case EAI_NODATA:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12039
            error = @symbol(noAddress);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12040
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12041
#endif
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12042
        case EAI_MEMORY:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12043
            error = @symbol(allocationFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12044
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12045
        case EAI_FAIL:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12046
            error = @symbol(permanentFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12047
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12048
        case EAI_AGAIN:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12049
            error = @symbol(tryAgain);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12050
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12051
        case EAI_SYSTEM:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12052
            error = @symbol(systemError);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12053
            break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12054
        default:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12055
            error = @symbol(unknownError);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12056
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12057
        errorString = __MKSTRING(gai_strerror(ret));
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12058
        goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12059
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12060
    for (cnt=0, infop=info; infop; infop=infop->ai_next)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12061
        cnt++;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12062
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12063
    result = __ARRAY_NEW_INT(cnt);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12064
    if (result == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12065
        error = @symbol(allocationFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12066
        goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12067
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12068
    for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12069
        OBJ o, resp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12070
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12071
        resp = __ARRAY_NEW_INT(6);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12072
        if (resp == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12073
            error = @symbol(allocationFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12074
            goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12075
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12076
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12077
        __ArrayInstPtr(result)->a_element[cnt] = resp; __STORE(result, resp);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12078
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12079
        __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(infop->ai_flags);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12080
        __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(infop->ai_family);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12081
        __ArrayInstPtr(resp)->a_element[2] = __mkSmallInteger(infop->ai_socktype);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12082
        __ArrayInstPtr(resp)->a_element[3] = __mkSmallInteger(infop->ai_protocol);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12083
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12084
        __PROTECT__(resp);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12085
        o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12086
        __UNPROTECT__(resp);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12087
        if (o == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12088
            error = @symbol(allocationFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12089
            goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12090
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12091
        memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12092
       __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12093
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12094
        if (infop->ai_canonname) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12095
            __PROTECT__(resp);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12096
            o = __MKSTRING(infop->ai_canonname);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12097
            __UNPROTECT__(resp);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12098
            if (o == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12099
                error = @symbol(allocationFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12100
                goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12101
            }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12102
            __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12103
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12104
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12105
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12106
err:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12107
    if (info) freeaddrinfo(info);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12108
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12109
# else /* ! AI_NUMERICHOST =============================================================*/
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12110
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12111
    /*
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12112
     * Use getservbyname() / gethostByName()
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12113
     */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12114
    struct hostent *hp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12115
    char **addrpp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12116
    int port = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12117
    int i;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12118
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12119
    if (__serviceName) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12120
        struct servent *sp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12121
        char *__proto = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12122
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12123
        if (__isStringLike(protoArg))
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12124
            __proto = __stringVal(protoArg);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12125
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12126
        sp = getservbyname(__serviceName, __proto);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12127
        if (sp == NULL) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12128
            errorString = @symbol(unknownService);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12129
            error = __mkSmallInteger(-3);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12130
            goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12131
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12132
        port = sp->s_port;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12133
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12134
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12135
    if (__hostName) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12136
#  ifdef USE_H_ERRNO
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12137
        do {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12138
            if (hostName == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12139
                __hostName = 0;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12140
            } else if (__isStringLike(hostName)) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12141
                __hostName = __stringVal(hostName);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12142
            }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12143
            /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12144
             * uses a static data area
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12145
             */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12146
            __BEGIN_INTERRUPTABLE__
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12147
            hp = gethostbyname(__hostName);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12148
            __END_INTERRUPTABLE__
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12149
        } while ((hp == NULL)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12150
                  && (
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12151
                        (h_errno == TRY_AGAIN)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12152
                      || errno == EINTR
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12153
#   ifdef IRIX5_3
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12154
                      || (errno == ECONNREFUSED)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12155
#   endif
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
        if (hp == 0) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12159
            switch (h_errno) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12160
            case HOST_NOT_FOUND:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12161
                errorString = @symbol(unknownHost);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12162
                break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12163
            case NO_ADDRESS:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12164
                errorString = @symbol(noAddress);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12165
                break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12166
            case NO_RECOVERY:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12167
                errorString = @symbol(permanentFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12168
                break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12169
            case TRY_AGAIN:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12170
                errorString = @symbol(tryAgain);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12171
                break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12172
            default:
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12173
                errorString = @symbol(unknownError);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12174
                break;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12175
            }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12176
            error = __mkSmallInteger(h_errno);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12177
            goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12178
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12179
#  else /* !USE_H_ERRNO */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12180
        hp = gethostbyname(__hostName);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12181
        if (hp == 0) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12182
            errorString = @symbol(unknownHost);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12183
            error = __mkSmallInteger(-1);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12184
            goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12185
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12186
#  endif /* !USE_H_ERRNO*/
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12187
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12188
        if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12189
            errorString = @symbol(unknownHost);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12190
            error = __mkSmallInteger(-2);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12191
            goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12192
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12193
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12194
        for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12195
            cnt++;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12196
        addrpp = hp->h_addr_list;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12197
    } else {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12198
        cnt = 1;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12199
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12200
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12201
    result = __ARRAY_NEW_INT(cnt);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12202
    if (result == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12203
        error = @symbol(allocationFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12204
        goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12205
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12206
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12207
    for (i = 0; i < cnt; i++) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12208
        OBJ o, resp;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12209
        struct sockaddr_in *sa;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12210
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12211
        resp = __ARRAY_NEW_INT(6);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12212
        if (resp == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12213
            error = @symbol(allocationFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12214
            goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12215
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12216
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12217
        __ArrayInstPtr(result)->a_element[i] = resp; __STORE(result, resp);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12218
        __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12219
        __ArrayInstPtr(resp)->a_element[2] = type; __STORE(result, type);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12220
        __ArrayInstPtr(resp)->a_element[3] = proto; __STORE(result, proto);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12221
        __PROTECT__(resp);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12222
        o = __BYTEARRAY_NEW_INT(sizeof(*sa));
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12223
        __UNPROTECT__(resp);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12224
        if (o == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12225
            error = @symbol(allocationFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12226
            goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12227
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12228
        __ArrayInstPtr(resp)->a_element[4] = o; __STORE(resp, o);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12229
        sa = (struct sockaddr_in *)__byteArrayVal(o);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12230
        sa->sin_port = port;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12231
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12232
        if (__hostName) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12233
            sa->sin_family = hp->h_addrtype;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12234
            memcpy(&sa->sin_addr, *addrpp, hp->h_length);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12235
            __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12236
            if (hp->h_name) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12237
                __PROTECT__(resp);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12238
                o = __MKSTRING(hp->h_name);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12239
                __UNPROTECT__(resp);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12240
                if (o == nil) {
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12241
                    error = @symbol(allocationFailure);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12242
                    goto err;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12243
                }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12244
                __ArrayInstPtr(resp)->a_element[5] = o; __STORE(resp, o);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12245
            }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12246
            addrpp++;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12247
        } else{
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12248
            __ArrayInstPtr(resp)->a_element[1] = domain; __STORE(resp, domain);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12249
        }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12250
    }
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12251
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12252
err:;
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12253
# endif /* ! AI_NUMERICHOST */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12254
}
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12255
#else /* ! HAS_SOCKET */
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12256
    error = @symbol(notImplemented);
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12257
#endif
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12258
%}.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12259
    error notNil ifTrue:[
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12260
        errorString notNil ifTrue:[
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12261
            ^ errorString.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12262
        ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12263
        ^ error.
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12264
    ].
c16326b73bf0 getAddressInfo:...
Stefan Vogel <sv@exept.de>
parents: 12967
diff changeset
 12265
    ^ result.
7136
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 12266
! !
aedf0aa8273b New socket support
Stefan Vogel <sv@exept.de>
parents: 7133
diff changeset
 12267
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12268
!UnixOperatingSystem::SocketHandle methodsFor:'accepting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12269
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12270
acceptWithPeerAddressBuffer:peerOrNil
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12271
    "accept a connection on a server port.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12272
     Returns a new SocketHandle or nil if the operation
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12273
     would block.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12274
     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
 12275
     of the connection peer is stored into it."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12276
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12277
    |error newFd|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12278
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12279
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12280
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12281
    int sock, newSock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12282
    struct sockaddr *sap;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12283
    int alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12284
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12285
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12286
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12287
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12288
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12289
    if (peerOrNil != nil &&
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12290
	(!__isNonNilObject(peerOrNil) ||
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12291
	 (__intVal(__ClassInstPtr(__qClass(peerOrNil))->c_flags) & ARRAYMASK) != BYTEARRAY)) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12292
	error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12293
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12294
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12295
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12296
    sock = __smallIntegerVal(__INST(fd));
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
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12299
    if (peerOrNil == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12300
	alen = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12301
	sap = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12302
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12303
	alen =  __byteArraySize(peerOrNil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12304
	sap = (struct sockaddr *)__byteArrayVal(peerOrNil);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12305
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12306
    newSock = accept(sock, sap, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12307
    if (newSock < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12308
	switch (errno) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12309
	case EINTR:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12310
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12311
	    goto again;
6350
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
#ifdef EWOULDBLOCK
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12314
	case EWOULDBLOCK:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12315
# if defined(EAGAIN) && (EAGAIN != EWOULDBLOCK)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12316
	case EAGAIN:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12317
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12318
#else
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12319
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12320
	case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12321
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12322
#endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12323
	    RETURN(nil);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12324
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12325
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12326
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12327
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12328
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12329
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12330
    newFd = __mkSmallInteger(newSock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12331
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12332
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12333
#endif /* not NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12334
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12335
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12336
	^ self error:error.
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12337
    ].
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12338
    ^ self class for:newFd
6350
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12341
!UnixOperatingSystem::SocketHandle methodsFor:'binding'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12342
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12343
bindTo:socketAddress
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12344
    "low level bind -
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12345
     Set the local address of the socket"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12346
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12347
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12348
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12349
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12350
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12351
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12352
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12353
    int ret;
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
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12356
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12357
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12358
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12359
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12360
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12361
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12362
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12363
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12364
    sockaddr_size = __byteArraySize(socketAddress);
6465
043467265ce2 freeBSD changes; bugFix in SocketHandle
Claus Gittinger <cg@exept.de>
parents: 6434
diff changeset
 12365
    sock = __smallIntegerVal(__INST(fd));
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12366
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12367
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12368
    ret = bind(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12369
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12370
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12371
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12372
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12373
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12374
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12375
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12376
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12377
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12378
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12379
    err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12380
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12381
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12382
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12383
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12384
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12385
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12386
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12387
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12388
     (Socket domain:#inet type:#stream)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12389
	 bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12390
	 reuseAddress:false ;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12391
     yourself
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
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12394
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12395
!UnixOperatingSystem::SocketHandle methodsFor:'connecting'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12396
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12397
cancelConnect
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12398
    "cancel an asynchronous connect in progress"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12399
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12400
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12401
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12402
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12403
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12404
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12405
    int ret;
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
 12406
    struct sockaddr sockaddr;
6350
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
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12409
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12410
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12411
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12412
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12413
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12414
    /*
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12415
     * (dis-) connect by connecting to AF_UNSPEC socket
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12416
     */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12417
again:
8307
8e90da896548 no ANSI features please - hpux cannot compile automatic struct-initializers
Claus Gittinger <cg@exept.de>
parents: 8279
diff changeset
 12418
    sockaddr.sa_family = AF_UNSPEC;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12419
    ret = connect(sock, &sockaddr, sizeof(sockaddr));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12420
    if (ret < 0) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12421
       switch(errno) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12422
	   case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12423
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12424
	    case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12425
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12426
		__HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12427
		goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12428
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12429
	    default:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 12430
		error = __mkSmallInteger(errno);
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12431
		break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12432
	}
6350
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12435
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12436
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12437
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12438
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12439
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12440
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12441
    ].
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12442
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12443
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12444
connectTo:socketAddress
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12445
    "low level connect; connect to a socket address.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12446
     Return true if connection has been established,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12447
     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
 12448
     completed. If an error occured, an OSError is raised"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12449
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12450
    |error|
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
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12453
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12454
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12455
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12456
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12457
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12458
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12459
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12460
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12461
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12462
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12463
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12464
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12465
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12466
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12467
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12468
    sockaddr_size = __qSize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12469
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12470
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12471
    ret = connect(sock, (struct sockaddr *)__byteArrayVal(socketAddress), sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12472
    if (ret >= 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12473
	RETURN(true)
6350
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12476
    switch(errno) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12477
	case EINTR:
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12478
# ifdef EAGAIN
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12479
	case EAGAIN:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12480
# endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12481
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12482
	    goto again;
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12483
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12484
# if defined(EINPROGRESS) || defined(EALREADY)
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12485
#  ifdef EINPROGRESS
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12486
	case EINPROGRESS:
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12487
#  endif
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12488
#  ifdef EALREADY
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12489
	case EALREADY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12490
#  endif
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12491
	    RETURN(false);
7152
e89883b01546 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7138
diff changeset
 12492
# endif
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12493
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12494
    default:
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 12495
	error = __mkSmallInteger(errno);
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12496
	break;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12497
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12498
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12499
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12500
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12501
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12502
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12503
	 ^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12504
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12505
    ^ true
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12506
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12507
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12508
     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
 12509
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12510
     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
 12511
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12512
     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
 12513
		   withTimeout:nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12514
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12515
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12516
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12517
!UnixOperatingSystem::SocketHandle methodsFor:'datagram transmission'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12518
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12519
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
 12520
    "receive datagramm data - put address of originating host into
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12521
     anAddressBuffer, data into aBuffer. For ST-80 compatibility,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12522
     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
 12523
     the addressBytes-message (i.e. be a SocketAddress instance).
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12524
     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
 12525
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12526
     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
 12527
     receiving, using #readWait or #readWaitWithTimeout:."
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12528
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12529
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12530
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12531
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12532
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12533
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12534
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12535
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12536
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12537
    int alen0, alen;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12538
    int n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12539
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12540
    int __flags, __startIndex, __nBytes;
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
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12543
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12544
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12545
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12546
    if (!__isSmallInteger(startIndex) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12547
	(__startIndex = __intVal(startIndex)-1) < 0) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12548
	if (startIndex == nil) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12549
	    __startIndex = 0;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12550
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12551
	    error = @symbol(badArgument3);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12552
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12553
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12554
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12555
    if (__isSmallInteger(nBytes)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12556
	__nBytes = __intVal(nBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12557
    } else if (nBytes == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12558
	__nBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12559
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12560
	error = @symbol(badArgument4);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12561
	goto err;
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
    if (!__isInteger(flags)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12564
	error = @symbol(badArgument5);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12565
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12566
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12567
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12568
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12569
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12570
    oClass = __Class(aDataBuffer);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12571
    switch (_intVal(_ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12572
	case BYTEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12573
	case WORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12574
	case SWORDARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12575
	case LONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12576
	case SLONGARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12577
	case FLOATARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12578
	case DOUBLEARRAY:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12579
	    break;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12580
	default:
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12581
	    error = @symbol(badArgument2);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12582
	    goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12583
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12584
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12585
    nInstVars = __intVal(_ClassInstPtr(oClass)->c_ninstvars);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12586
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12587
    objSize = __qSize(aDataBuffer) - nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12588
    nInstBytes += __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12589
    objSize -= __startIndex;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12590
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12591
    if (__nBytes >= 0 &&__nBytes < objSize) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12592
	objSize = __nBytes;
6350
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
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12595
    if (socketAddress == nil) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12596
	alen0 = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12597
    } else {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12598
	if (!__isNonNilObject(socketAddress) ||
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12599
	    (__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12600
	    error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12601
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12602
	}
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12603
	alen0 = __byteArraySize(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12604
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12605
    saPtr = (struct sockaddr *)0;
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
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12608
    alen = alen0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12609
    if (alen)
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12610
	saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12611
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12612
    n = recvfrom(sock, cp, objSize, __flags, saPtr, &alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12613
    if (n < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12614
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12615
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12616
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12617
	} else {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 12618
	    error = __mkSmallInteger(errno);
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12619
	    goto err;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12620
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12621
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12622
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12623
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12624
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12625
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12626
    ^ self error:error.
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
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12629
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
 12630
    "send datagramm data - fetch address of destination host from
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12631
     anAddressBuffer, data from aDataBuffer starting at startIndex,
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12632
     sending count bytes.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12633
     SocketAddress must be an instance of SocketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12634
     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
 12635
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12636
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12637
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12638
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12639
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12640
    OBJ oClass;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12641
    int nInstVars, nInstBytes, objSize;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12642
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12643
    int alen, n;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12644
    struct sockaddr *saPtr;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12645
    char *cp;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12646
    int __flags;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12647
    int offs, __startIndex, __maxBytes;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12648
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12649
    if (!__isSmallInteger(__INST(fd))) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12650
        error = @symbol(badFd);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12651
        goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12652
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12653
    if (!__isSmallInteger(startIndex) ||
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12654
        (__startIndex = __intVal(startIndex)-1) < 0) {
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12655
        if (startIndex == nil) {
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12656
            __startIndex = 0;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12657
        } else {
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12658
            error = @symbol(badArgument3);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12659
            goto err;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12660
        }
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12661
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12662
    if (__isSmallInteger(maxBytes)) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12663
        __maxBytes = __intVal(maxBytes);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12664
    } else if (maxBytes == nil) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12665
        __maxBytes = -1;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12666
    } else {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12667
        error = @symbol(badArgument4);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12668
        goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12669
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12670
    if (!__isInteger(flags)) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12671
        error = @symbol(badArgument5);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12672
        goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12673
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12674
    __flags = __longIntVal(flags);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12675
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12676
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12677
    oClass = __Class(aDataBuffer);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12678
    switch (_intVal(_ClassInstPtr(oClass)->c_flags) & ARRAYMASK) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12679
        case BYTEARRAY:
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12680
            offs = __startIndex;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12681
            break;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12682
        case WORDARRAY:
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12683
        case SWORDARRAY:
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12684
            offs = __startIndex * 2;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12685
            break;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12686
        case LONGARRAY:
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12687
        case SLONGARRAY:
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12688
            offs = __startIndex * 4;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12689
            break;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12690
        case LONGLONGARRAY:
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12691
        case SLONGLONGARRAY:
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12692
            offs = __startIndex * 8;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12693
# ifdef __NEED_LONGLONG_ALIGN
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12694
            offs += 4;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12695
# endif
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12696
        case FLOATARRAY:
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12697
            offs = __startIndex * sizeof(float);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12698
            break;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12699
        case DOUBLEARRAY:
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12700
            offs = __startIndex * sizeof(double);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12701
# ifdef __NEED_DOUBLE_ALIGN
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12702
            offs += 4;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12703
# endif
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12704
            break;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12705
        default:
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12706
            error = @symbol(badArgument2);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12707
            goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12708
    }
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
    nInstVars = __smallIntegerVal(_ClassInstPtr(oClass)->c_ninstvars);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12711
    nInstBytes = OHDR_SIZE + nInstVars * sizeof(OBJ);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12712
    objSize = __qSize(aDataBuffer) - nInstBytes - offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12713
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12714
    if (__maxBytes >= 0 && __maxBytes < objSize) {
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12715
# ifdef DGRAM_DEBUG
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12716
        printf("cut off ...\n");
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12717
# endif
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12718
        objSize = __maxBytes;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12719
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12720
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12721
    if (socketAddress == nil) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12722
        alen = 0;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12723
    } else {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12724
        if (! __isByteArrayLike(socketAddress)) {
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12725
            error = @symbol(badArgument1);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12726
            goto err;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12727
        }
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12728
        alen = __byteArraySize(socketAddress);
6350
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
    saPtr = (struct sockaddr *)0;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12731
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12732
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12733
    if (alen)
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12734
        saPtr = (struct sockaddr *)__byteArrayVal(socketAddress);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12735
    cp = (char *)__InstPtr(aDataBuffer) + nInstBytes + offs;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12736
    n = sendto(sock, cp, objSize, __flags, saPtr, alen);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12737
    if (n < 0) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12738
        if (errno == EINTR) {
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12739
            __HANDLE_INTERRUPTS__;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12740
            goto again;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12741
        } else {
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12742
            error = __mkSmallInteger(errno);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12743
            goto err;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12744
        }
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12745
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12746
    RETURN (__mkSmallInteger(n));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12747
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12748
err: ;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12749
%}.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12750
    ^ self error:error.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12751
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12752
6434
f23d12900e18 category rename
Claus Gittinger <cg@exept.de>
parents: 6421
diff changeset
 12753
!UnixOperatingSystem::SocketHandle methodsFor:'initialization'!
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12754
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12755
domain:domainArg type:typeArg protocol:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12756
    "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
 12757
     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
 12758
     All arguments must be symbols from one of
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12759
     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
 12760
     type: #SOCK_STREAM, #SOCK_DGRAM (#stream, #datagram, #raw) ..
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12761
     protocol: #tcp, #udp, #raw ..
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12762
    "
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12763
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12764
    |error domainCode typeCode protocolNumber|
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12765
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12766
    domainCode := OperatingSystem domainCodeOf:domainArg.
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12767
    typeCode := OperatingSystem socketTypeCodeOf:typeArg.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12768
    protocolArg notNil ifTrue:[
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12769
	protocolNumber := self class protocolCodeOf:protocolArg
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12770
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12771
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12772
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12773
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12774
    int dom, typ, proto = 0, sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12775
    int on = 1;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12776
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12777
    if (__INST(fd) != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12778
	error = @symbol(internalError);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12779
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12780
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12781
    if (! __isSmallInteger(domainCode)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12782
	error = @symbol(badArgument1);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12783
	goto err;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12784
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12785
    if (! __isSmallInteger(typeArg)) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12786
	error = @symbol(badArgument2);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12787
	goto err;
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
    if (protocolNumber != nil) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12790
	if (!__isSmallInteger(protocolNumber)) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12791
	    error = @symbol(badArgument3);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12792
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12793
	}
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12794
	proto = __smallIntegerVal(protocolNumber);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12795
    }
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12796
    dom = __smallIntegerVal(domainCode);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12797
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12798
    /*
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12799
     * get socket-type and protocol-type
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12800
     */
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12801
    typ = __intVal(typeArg);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12802
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12803
againSocket:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12804
    sock = socket(dom, typ, proto);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12805
    if (sock < 0) {
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12806
	if (errno == EINTR) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12807
	    __HANDLE_INTERRUPTS__;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12808
	    goto againSocket;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12809
	} else
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12810
# if defined(EPROTONOSUPPORT) /* for SGI */
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12811
	if (errno == EPROTONOSUPPORT && proto != 0) {
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12812
	    proto = 0;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12813
	    goto againSocket;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12814
	} else
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12815
# endif
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12816
	{
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12817
	    error = __mkSmallInteger(errno);
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12818
	    goto err;
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12819
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12820
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12821
    __INST(fd) = __mkSmallInteger(sock);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12822
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12823
err:;
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12824
# else /* NOSOCKET */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12825
    error := @symbol(notImplemented);
7509
c8964822d8fd moved all socket constant queries from SocketHandle
Claus Gittinger <cg@exept.de>
parents: 7500
diff changeset
 12826
# endif /* NOSOCKET */
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12827
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12828
    error notNil ifTrue:[
7515
2130129a207d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7514
diff changeset
 12829
	^ self error:error.
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
    self register.
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
    "
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12834
     self new domain:#inet type:#stream protocol:nil
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
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12837
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12838
!UnixOperatingSystem::SocketHandle methodsFor:'misc'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12839
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12840
getOptionsLevel:level name:name
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12841
    "answer a ByteArray containing the socket option value
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12842
     named name at level"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12843
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12844
    |error bytes size|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12845
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12846
    bytes := ByteArray new:256.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12847
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
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12850
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12851
    int intval, sz;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12852
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12853
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12854
    if (!__isSmallInteger(__INST(fd))) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12855
	error = @symbol(badFd);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12856
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12857
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12858
    if (!__bothSmallInteger(level, name)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12859
	error = @symbol(badArgument);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12860
	goto err;
6350
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
    if (!__isByteArray(bytes)) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12863
	error = @symbol(internalError);
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12864
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12865
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12866
    p = __byteArrayVal(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12867
    sz = __byteArraySize(bytes);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12868
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12869
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12870
    if (getsockopt(sock, __smallIntegerVal(level), __smallIntegerVal(name), p, &sz) < 0) {
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12871
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12872
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12873
    size = __mkSmallInteger(sz);
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:[
6992
8ed0883dff8f more errnos
Claus Gittinger <cg@exept.de>
parents: 6987
diff changeset
 12879
	^ self error:error
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12880
    ].
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12881
    ^ bytes copyTo:size
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
listenFor:aNumber
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12885
    "start listening.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12886
     aNumber is the number of connect indications queues
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12887
     by the operating system"
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12888
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12889
    |error|
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
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12892
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12893
    int sock, ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12894
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12895
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12896
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12897
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12898
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12899
    if (!__isSmallInteger(aNumber)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12900
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12901
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12902
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12903
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12904
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12905
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12906
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12907
    ret = listen(sock, __smallIntegerVal(aNumber));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12908
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12909
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12910
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12911
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12912
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12913
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12914
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12915
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12916
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12917
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12918
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12919
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12920
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12921
	^ self error:error.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12922
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12923
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12924
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12925
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12926
setOptionsLevel:level name:name value:value
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12927
    "set the socket option name at level to value.
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12928
     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
 12929
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12930
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12931
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12932
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12933
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12934
    int sock;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12935
    int __level, __name, intval, sz;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12936
    char *p;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12937
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12938
    if (!__isSmallInteger(__INST(fd))) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12939
        error = @symbol(badFd);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12940
        goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12941
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12942
    if (__isSmallInteger(level)) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12943
        __level = __smallIntegerVal(level);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12944
    } else if (level == @symbol(SOL_SOCKET)) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12945
        __level = SOL_SOCKET;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12946
    } else {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12947
        error = @symbol(badArgument1);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12948
        goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12949
    }
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12950
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12951
    if (__isSmallInteger(name)) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12952
        __name = __smallIntegerVal(name);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12953
    } else if (name == @symbol(SO_REUSEADDR)) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12954
        __name = SO_REUSEADDR;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12955
    } else {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12956
        error = @symbol(badArgument2);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12957
        goto err;
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12958
    }
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12959
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12960
    if (__isSmallInteger(value)) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12961
        intval = __intVal(value);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12962
        p = (char *) &intval;
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12963
        sz = sizeof(intval);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12964
    } else if (__isByteArrayLike(value)) {
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12965
        p = __byteArrayVal(value);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12966
        sz = __byteArraySize(value);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12967
    } else {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12968
        error = @symbol(badArgument3);
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12969
        goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12970
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12971
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12972
    sock = __smallIntegerVal(__INST(fd));
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12973
    if (setsockopt(sock, __level, __name, p, sz) < 0) {
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12974
        error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12975
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12976
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12977
#endif
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12978
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12979
    error notNil ifTrue:[
12458
c5a9ce0959d8 __isString() to __isStringLike() in ptimitive code
Stefan Vogel <sv@exept.de>
parents: 12451
diff changeset
 12980
        ^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12981
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 12982
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12983
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12984
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 12985
shutdown:anInteger
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12986
    "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
 12987
     anInteger == 0   no reads will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12988
     anInteger == 1   no writes will be performed
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12989
     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
 12990
		      Pending data is discarded. This is faster tha
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12991
		      close, which may wait until pending (written)
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 12992
		      data has been read by the other side"
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12993
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12994
    |error|
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
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12997
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12998
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 12999
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13000
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13001
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13002
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13003
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13004
    if (!__isSmallInteger(anInteger)) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13005
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13006
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13007
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13008
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13009
again:
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13010
    ret = shutdown(__smallIntegerVal(__INST(fd)), __smallIntegerVal(anInteger));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13011
    if (ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13012
	if (errno == EINTR) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13013
	    __HANDLE_INTERRUPTS__;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13014
	    goto again;
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13015
	} else {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13016
	    error = __mkSmallInteger(errno);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13017
	}
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13018
    }
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
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13021
#endif /*NO_SOCKET*/
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13022
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13023
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13024
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13025
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13026
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13027
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13028
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13029
!UnixOperatingSystem::SocketHandle methodsFor:'queries'!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13030
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13031
getNameInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13032
    "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
 13033
     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
 13034
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13035
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13036
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
#ifndef NO_SOCKET
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13039
    int sock;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13040
    int sockaddr_size;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13041
    int ret;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13042
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13043
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13044
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13045
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13046
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13047
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13048
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13049
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13050
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13051
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13052
    sockaddr_size = __byteArraySize(socketAddress);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13053
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13054
    sock = __smallIntegerVal(__INST(fd));
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13055
    ret = getsockname(sock, (struct sockaddr *)__byteArrayVal(socketAddress), &sockaddr_size);
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13056
    if (ret < 0) {
8913
b9498d27a554 64bit; mkSmallInteger
Claus Gittinger <cg@exept.de>
parents: 8902
diff changeset
 13057
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13058
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13059
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13060
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13061
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13062
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13063
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13064
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13065
    ^ nil.
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13066
!
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13067
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13068
getPeerInto:socketAddress
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13069
    "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
 13070
     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
 13071
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13072
    |error|
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13073
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13074
%{
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13075
#ifndef NO_SOCKET
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13076
    int __sock;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13077
    int __sockaddr_size;
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13078
    int __ret;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13079
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13080
    if (!__isSmallInteger(__INST(fd))) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13081
	error = @symbol(badFd);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13082
	goto err;
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13083
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13084
    if (!__isNonNilObject(socketAddress) ||
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13085
	(__intVal(__ClassInstPtr(__qClass(socketAddress))->c_flags) & ARRAYMASK) != BYTEARRAY) {
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13086
	error = @symbol(badArgument1);
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13087
	goto err;
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13088
    }
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13089
    __sockaddr_size = __byteArraySize(socketAddress);
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13090
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13091
    __sock = __smallIntegerVal(__INST(fd));
8279
e16a20ee2c6d wrong STORE macro fixed (getMACAddr)
Claus Gittinger <cg@exept.de>
parents: 8248
diff changeset
 13092
    __ret = getpeername(__sock, (struct sockaddr *)__byteArrayVal(socketAddress),
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13093
				&__sockaddr_size);
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13094
    if (__ret < 0) {
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13095
	error = __mkSmallInteger(errno);
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13096
    }
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13097
err:;
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13098
#endif /* NO_SOCKET */
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13099
%}.
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13100
    error notNil ifTrue:[
7465
1b616e80d565 Fix #getNameInfo:... when doing gethostbyaddr()
Stefan Vogel <sv@exept.de>
parents: 7462
diff changeset
 13101
	^ self error:error
7138
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13102
    ].
4a98076d98fb New socket support
Stefan Vogel <sv@exept.de>
parents: 7137
diff changeset
 13103
    ^ nil
6350
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13104
! !
ccfbaa0daaee New FileDescriptorHandle and SocketHandle stuff.
Stefan Vogel <sv@exept.de>
parents: 6343
diff changeset
 13105
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13106
!UnixOperatingSystem class methodsFor:'documentation'!
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13107
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13108
version
13110
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
 13109
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.279 2010-10-29 15:25:37 stefan Exp $'
12451
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 13110
!
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 13111
0bbbfc569555 changed:19 methods
Stefan Vogel <sv@exept.de>
parents: 11798
diff changeset
 13112
version_CVS
13110
7872ec1f7c6f getCurrentDirectory
Stefan Vogel <sv@exept.de>
parents: 13052
diff changeset
 13113
    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.279 2010-10-29 15:25:37 stefan Exp $'
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13114
! !
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 13115
3496
85e19a68bd61 started to separate into OS-specific classes
Claus Gittinger <cg@exept.de>
parents:
diff changeset
 13116
UnixOperatingSystem initialize!
6772
6bfdc2522ea2 isMountPoint
penk
parents: 6760
diff changeset
 13117
UnixOperatingSystem::FileDescriptorHandle initialize!